[RFC PATCH 0/2] mm: continue using per-VMA lock when retrying page faults after I/O
Barry Song
21cnbao at gmail.com
Thu Nov 27 15:22:16 AEDT 2025
On Thu, Nov 27, 2025 at 12:09 PM Matthew Wilcox <willy at infradead.org> wrote:
>
> On Thu, Nov 27, 2025 at 09:14:36AM +0800, Barry Song wrote:
> > There is no need to always fall back to mmap_lock if the per-VMA
> > lock was released only to wait for pagecache or swapcache to
> > become ready.
>
> Something I've been wondering about is removing all the "drop the MM
> locks while we wait for I/O" gunk. It's a nice amount of code removed:
I think the point is that page fault handlers should avoid holding the VMA
lock or mmap_lock for too long while waiting for I/O. Otherwise, those
writers and readers will be stuck for a while.
>
> include/linux/pagemap.h | 8 +---
> mm/filemap.c | 98 ++++++++++++-------------------------------------
> mm/internal.h | 21 -----------
> mm/memory.c | 13 +------
> mm/shmem.c | 6 ---
> 5 files changed, 27 insertions(+), 119 deletions(-)
>
> and I'm not sure we still need to do it with per-VMA locks. What I
> have here doesn't boot and I ran out of time to debug it.
I agree there’s room for improvement, but merely removing the "drop the MM
locks while waiting for I/O" code is unlikely to improve performance.
For example, we could change the flow to:
1. Release the VMA lock or mmap_lock
2. Lock the folio
3. Re-acquire the VMA lock or mmap_lock
4. Re-check whether we can still map the PTE
5. Map the PTE
Currently, the flow is always:
1. Release the VMA lock or mmap_lock
2. Lock the folio
3. Unlock the folio
4. Re-enter the page fault handling from the beginning
The change would be much more complex, so I’d prefer to land the current
patchset first. At least this way, we avoid falling back to mmap_lock and
causing contention or priority inversion, with minimal changes.
Thanks
Barry
More information about the Linuxppc-dev
mailing list