<p dir="ltr">Yes, exactly; I'm trying to understand (for my own sake, really, but maybe others too) what this patch adds over letting kernel manage physical pages on its own given it has a better global view of the system.   madvise(MADV_DONTNEED) appears to actively unmap the pages, rather than just marking them (so, e.g., swap decisions can be made later about them); if there's no pressure/shortage for physical pages, this will just create unneeded overhead (both with this initial syscall and later if pages need to mapped again), won't it?</p>

<p dir="ltr">Also, if an app has spikey usage but where spikes are frequent, this patch would probably be a net negative since it's not based on ergonomics/statistics/trend/etc.  Since your patch makes this new behavior "toggleable" it's probably not an issue.</p>

<p dir="ltr">Thanks</p>
<p dir="ltr">Sent from my phone</p>
<div class="gmail_quote">On Jan 28, 2013 6:28 PM, "Hiroshi Yamauchi" <<a href="mailto:yamauchi@google.com">yamauchi@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 3:29 PM, Vitaly Davidovich <span dir="ltr"><<a href="mailto:vitalyd@gmail.com" target="_blank">vitalyd@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><p dir="ltr">Hiroshi,</p>
<p dir="ltr">I'll second your explanation for #1 - we also have some server workloads that fluctuate.</p>
<p dir="ltr">Since the kernel will page out memory if need arises on its own, the main benefit I'm seeing in your patch is that it removes the possibility that kernel will page out the wrong pages.  That is, if it's using LRU page replacement (or whatever the latest heuristic might be) and GC just freed up those pages (but ended up marking them dirty in the process), then if kernel needs to swap out it may overlook these pages because they don't fit the replacement policy(I guess it also ensures that these pages don't need swap backing either). Otherwise, if the server app has not been using those extra pages for a while anyway, I'm thinking kernel will pick up on that.</p>



<p dir="ltr">Is that right? Just want to make sure I understand.</p></blockquote><div>Vitaly, do you mean that without this feature/patch, the kernel might choose to swap out a page with valid data as opposed to a page that has garbage data and would have been deallocated with this feature/patch if it follows an LRU-like policy or something similar? If so, you are probably right about that.</div>

</div></div></div>
</blockquote></div>