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: Propose to Use madvise API on Runtime Loader


Hi Rich,
On Thu, May 22, 2014 at 10:57:30PM -0400, Rich Felker wrote:
> As written this code is definitely not appropriate; it could even end
> up applying MADV_DONTNEED to writable memory, which does not just
> affect caching but actually obliterates any changes made to it (e.g.
> relocations) and restores the mapping to the original on-disk state.
> 
    I think you have not read my code carefully. My code means I want to
    drop the pages & page tables from elf header to .rel.dyn, which is a
    readonly region. My point is to drop these pages which is readonly
    and clean and will not need after relocation.
> Another lesser problem is that it will tend to make loading the same
> library by multiple processes much slower since each load will have to
> go back to the disk (due to dumping the cache).
> 
    Definitely this will not happen. madvise_dontneed function doesn't
    effect page cache. And according to the following code:
				if (pte_young(ptent) &&
				    likely(!(vma->vm_flags & VM_SEQ_READ)))
					mark_page_accessed(page);
    it makes the page lives longer in the LRU. Active pages live longer.

> Basically requesting the kernel to drop caches is always wrong as a
> default, and usually wrong even if you think you want to do so. It has
> no bearing on how much memory is tied up, and just leads to suboptimal
> use of memory. The kernel can choose much better what to keep cached
> and what to drop than a naive rule like the one you proposed could do.
> 
    Again my code does not effect page caches. So I am not doing it
    wrong right?
> Rich


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