memory usage on Scyld slave nodes (fwd)

Jag agrajag at linuxpower.org
Sat Feb 17 07:51:17 PST 2001


On Sat, 17 Feb 2001, Daniel Ridge wrote:

> 
> One observation -- though -- is that the kernel always _knows_ the amount
> of actually free memory (nr_free_pages) and buffered (buffermem)  and has
> to expensively compute the other statistics by iterating in the snippet
> (from arch/i386/mm/init.c) whenever you look at /proc/meminfo.
> 
>         i = max_mapnr;
>         val->totalram = 0;
>         val->sharedram = 0;
>         val->freeram = nr_free_pages << PAGE_SHIFT;
>         val->bufferram = buffermem;
>         while (i-- > 0)  {
>                 if (PageReserved(mem_map+i))
>                         continue;
>                 val->totalram++;
>                 if (!atomic_read(&mem_map[i].count))
>                         continue;
>                 val->sharedram += atomic_read(&mem_map[i].count) - 1;
>         }
>         val->totalram <<= PAGE_SHIFT;
>         val->sharedram <<= PAGE_SHIFT;
>         return;
> 
> (I suppose this post is now GPLed)
> 
> This can be a hugely expensive function to drive at even a couple of
> hertz.

I'm not quite sure why the kernel needs to computer totalram on the fly,
but this shows that freeram and bufferram are preknown, and if you look
in get_meminfo() in fs/proc/array.c, you'll see that the cache size is
also preknown.  I'd assume that beostatus/libbeostat/etc would be able
to read /proc/meminfo once and store the totalram number, and all the
other numbers that beostatus (with my patch to subtract buffered and
cache from the amount used) are preknown by the kernel.  Is there a way
to easily get this information out of the kernel without having to read
/proc/meminfo which causes all of those calculations to occur.

The best I can think of is to add something to /proc that just gives all
the quick info, but this seems kind of overkill to me.

Unfortunately, we can't speed up the reading the swap usage, which
beostatus also uses.  From mm/swapfile.c:

        unsigned int i, j;

        val->freeswap = val->totalswap = 0;
        for (i = 0; i < nr_swapfiles; i++) {
                if ((swap_info[i].flags & SWP_WRITEOK) != SWP_WRITEOK)
                        continue;
                for (j = 0; j < swap_info[i].max; ++j)
                        switch (swap_info[i].swap_map[j]) {
                                case SWAP_MAP_BAD:
                                        continue;
                                case 0:
                                        ++val->freeswap;
                                default:
                                        ++val->totalswap;
                        }
        }
        val->freeswap <<= PAGE_SHIFT;
        val->totalswap <<= PAGE_SHIFT;
        return;


Jag
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://www.scyld.com/pipermail/beowulf/attachments/20010217/2feb3668/attachment.bin


More information about the Beowulf mailing list