Re: missing madvise functionality

From: Ulrich Drepper
Date: Tue Apr 03 2007 - 19:08:13 EST


Andi Kleen wrote:
> If you know in advance you need them it might be possible to
> batch that. e.g. MADV_WILLNEED could be extended to
> work on anonymous memory and establish the mappings in the syscall.
> Would that be useful?

Not in the exact way you think. The problem is that not all pages would
be needed right away. An allocator requests address space from the
kernel in larger chunks and then uses it piece by piece. The so-far
unused memory remains untouched and therefore not mapped. It would be
wasteful to allocate all pages. It would mean the allocator has to
request smaller blocks from the kernel which in turn means more system
calls.

The behavior is also not good for the malloc()'ed blocks. A large block
might also not be used fully or at least not necessary.

But I definitely could see cases where I would want that functionality.
For instance, for memory regions which contain only administrative data
and where every page is used right away. Substituting N page faults for
one madvise call probably is a win.

--
â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â

Attachment: signature.asc
Description: OpenPGP digital signature