[PATCH][RFC] Allow explicit shrinking of arena heaps using an environment variable
Roland McGrath
roland@hack.frob.com
Fri Jul 20 21:48:00 GMT 2012
> Using madvise (MADV_DONTNEED) then mprotect should be equivalent to
> mmap, but it's unclear to me which will be faster.
They're not equivalent from a security paranoia point of view.
madvise just gives the kernel license to drop the pages. It doesn't
require that it do so. A kernel could very well do nothing
immediately at all in response to the madvise call, and it would be
right to do nothing if that's the quickest thing and there is no
memory pressure at all. (If memory pressure arises later on, then
it may well choose those pages as the first to reclaim.) If the
kernel didn't in fact drop the pages, then mprotect doesn't affect
whether the old data is still there in those pages. A later
mprotect could very well make the old data accessible again.
Thanks,
Roland
More information about the Libc-alpha
mailing list