On Fri, Apr 7, 2023 at 2:36 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote: > > On Fri, Apr 07, 2023 at 01:26:08PM -0700, Suren Baghdasaryan wrote: > > True. do_swap_page() has the same issue. Can we move these > > count_vm_event() calls to the end of handle_mm_fault(): > > I was going to suggest something similar, so count that as an > Acked-by. This will change the accounting for the current retry > situation, where we drop the mmap_lock in filemap_fault(), initiate I/O > and return RETRY. I think that's probably a good change though; I don't > see why applications should have their fault counters incremented twice > for that situation. > > > mm_account_fault(regs, address, flags, ret); > > +out: > > + if (ret != VM_FAULT_RETRY) { > > + count_vm_event(PGFAULT); > > + count_memcg_event_mm(vma->vm_mm, PGFAULT); > > + } > > Nit: this is a bitmask, so we should probably have: > > if (!(ret & VM_FAULT_RETRY)) { > > in case somebody's ORed it with VM_FAULT_MAJOR or something. The fix is posted at https://lore.kernel.org/all/20230414175444.1837474-1-surenb@xxxxxxxxxx/ > > Hm, I wonder if we're handling that correctly; if we need to start I/O, > do we preserve VM_FAULT_MAJOR returned from the first attempt? Not > in a position where I can look at the code right now.