On Fri, Mar 24, 2023 at 03:11:00PM +0000, Matthew Wilcox wrote: > On Fri, Mar 24, 2023 at 02:58:29PM +0000, Will Deacon wrote: > > Yes, please don't fault everything in as young as it has caused horrible > > vmscan behaviour leading to app-startup slowdown in the past: > > > > https://lore.kernel.org/all/20210111140149.GB7642@willie-the-truck/ > > > > If we have to use the same value for all the ptes, then just base them > > all on arch_wants_old_prefaulted_pte() as iirc hardware AF was pretty > > cheap in practice for us. > > I think that's wrong, because this is a different scenario. > > Before: > > We faulted in N single-page folios. Each page/folio is tracked > independently. That's N entries on whatever LRU list it ends up on. > The prefaulted ones _should_ be marked old -- they haven't been > accessed; we've just decided to put them in the page tables to > speed up faultaround. The unaccessed pages need to fall off the LRU > list as quickly as possible; keeping them around only hurts if the > workload has no locality of reference. > > After: > > We fault in N folios, some possibly consisting of multiple pages. > Each folio is tracked separately, but individual pages in the folio > are not tracked; they belong to their folio. In this scenario, if > the other PTEs for pages in the same folio are marked as young or old > doesn't matter; the entire folio will be tracked as young, because we > referenced one of the pages in this folio. Marking the other PTEs as > young actually helps because we don't take pagefaults on them (whether > we have a HW or SW accessed bit). > > (can i just say that i dislike how we mix up our old/young accessed/not > terminology here?) > > We should still mark the PTEs referencing unaccessed folios as old. > No argument there, and this patch does that. But it's fine for all the > PTEs referencing the accessed folio to have the young bit, at least as > far as I can tell. Ok, thanks for the explanation. So as long as arch_wants_old_prefaulted_pte() is taken into account for the unaccessed folios, then I think we should be good? Unconditionally marking those PTEs as old probably hurts x86. Will