Re: meminfo

Linus Torvalds (torvalds@cs.helsinki.fi)
Sat, 23 Mar 1996 14:39:09 +0200 (EET)


On 23 Mar 1996, Bernd Eckenfels wrote:
> if (mem_map[i].uptodate) uptodate++;
> if (mem_map[i].reserved) reserved++;
> if (mem_map[i].error) error++;
> if (mem_map[i].referenced) referenced++;
> if (mem_map[i].locked) locked++;
> if (mem_map[i].free_after) free_after++;
> if (mem_map[i].unused) unused++;

Note that this will _not_ give exact answers, even though the code looks
"obviously correct". The reason for that is that the linux page
allocation code is a powers-of-two buddy system, and if somebody
allocates a area larger than one page then only the mem_map[] entry that
is relevant to the _first_ page in the area is updated.

> nr_free_pages=76 fp=86 su=1520 mu=113 sharedram=655
> all=2048 uptodate=910 reserved=329 error=0 referenced=163 locked=0 free_after=0 unused=0
>
> Generally there is a difference of 10 pages between nr_free_pages and fp.

"nr_free_pages" is correct, "fp" is not. "fp" gives a larger value
because the accounting code above thinks that some pages are free (count
== 0), even though they aren't (they are part of a multi-page
allocation).

> The only time this difference changed was while i did some floppy access.

The floppy driver (among some other things) allocates large multi-page
buffers, sot hat's why you probably saw the difference go up even more.

Linus