This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Allow explicit shrinking of arena heaps using anenvironment variable


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]