9fans archive / 1997 / 07 / 74 /    prev next

From: David Hogan dhog@lor...
Subject: [9fans] Plan 9 on PC - memory and swap
Date: Thu, 24 Jul 1997 03:43:55 +1000

> Loading a version of 9pccpudisk, I get the following message:

> 	2531 free pages, 10124K bytes, swap 55564K, highwater 504K, headroom 
> 628K

> a "cat /dev/swap" yields:

> 	641/2531 memory 0/11360 swap

> on an idle CPU/auth server.

> I've not bothered with the details before, but now I'm curious.  
> Evidently, the swap value in the kernel message is displayed 
> incorrectly, specially in view of the fact that swap has not been 
> enabled at the time the kernel loads.

> Given that the CPU server has 16 meg of RAM, I'd also be curious as to 
> why only 2531K remains available.  Pointers to reading material are 
> welcome.

The numbers in /dev/swap are in units of pages, and on a PC
the page size is 4K.  [Aside: why is there no /dev/pagesize?]

So, 2531 * 4K = 10124K, ie of the 16M that you have, 10M is
available for user processes.  The other 6M is kept by
the kernel for its text and data space, in-kernel bitmap
storage, scsi and ethernet buffers, stream blocks, etc etc...

According to /dev/swap you have 11360*4K = 45440K available
for swap.  If you add 10124K, you get 55564K, the value printed
at startup.  This number represents the total amount of
virtual memory available when swapping is enabled (and
when the swap partition is >= BY2PG*conf.nswap).  See
pageinit() in /sys/src/9/port/page.c, where the message
is printed...