MADV_DONTNEED, etc.

From: Albert D. Cahalan (acahalan@cs.uml.edu)
Date: Fri Apr 14 2000 - 21:42:03 EST


Given the multiple useful and incompatible behaviors for MADV_DONTNEED,
users should be expected to define it themselves as one of a few more
descriptive choices:

MADV_DONTNEED_WIPE zero the memory
MADV_DONTNEED_KEEP don't need it NOW, so swap it out
MADV_DONTNEED_TRAP app will handle SIGBUS if the memory is taken away
MADV_DONTNEED_JUNK the OS can substitute random unzeroed pages

(that last one being subject to security limitations of course)

Note the MADV_DONTNEED_* names. This is to reduce confusion.
Users (well, app developers) need to be aware of their choices.
Creating new names out of the blue sky means more to learn,
without the obvious naming hint to assist.

Plain MADV_DONTNEED should just go away. Users have #ifdef, and
this isn't exactly portable code anyway.

BTW, we are getting too many memory-related system calls.
Solaris seems to use a generic call to handle it all.
Using truss (like Linux strace) on /bin/cp reveals this call:
memcntl(0xEF730000, 262144, MC_ADVISE, 0x0002, 0, 0) = 0

>From the man page:
int memcntl(caddr_t addr, size_t len, int cmd, caddr_t arg,
  int attr, int mask);
The function memcntl() allows the calling process to apply a
variety of control operations over the address space identified by
the mappings established for the address range [addr, addr + len).

See http://doc.sun.com/ or http://docs.sun.com/ for details.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:25 EST