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


On Fri, Jul 20, 2012 at 02:47:53PM -0700, Roland McGrath wrote:
> > 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.

I believe you are talking about the madvise mode that has been discussed a
few years ago, but unfortunately wasn't implemented in the end.
MADV_DONTNEED I think forces all pages to be cleared upon touching them
again, while what was discussed was just the possibility for the kernel
to throw the pages away if it needs them usefully for something else,
but if not, keep them around dirty and allow them to be accessed again at no
cost.

	Jakub


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