Skip to content

RFC mm: use VMA lock for kernel faults on user addresses

Barry Song (Xiaomi) linux-arm-kernel linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2x86/mm: use VMA lock for kernel faults on user addressesarch/x86/mm/fault.c+0 -36 replies
2/2arm64/mm: use VMA lock for kernel faults on user addressesarch/arm64/mm/fault.c+3 -12 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH v1 0/2] mm: use VMA lock for kernel faults on user addresses

Right now, kernel faults on user addresses, such as those from copy_from_user() and copy_to_user(), unconditionally fall back to the mmap_lock path.

This patchset switches them to the per-VMA lock path for three reasons:

1. These faults are common. On a typical Ubuntu system, hundreds of kernel faults on user addresses occur every second in python3, apt-esm-hook, package-data-do, teamviewerd, bash, scudo, cscope, gnome-shell, systemd, and many other applications. Handling these faults under mmap_lock unnecessarily increases lock contention.

2. It removes one obstacle to simplifying filemap_fault(). Matthew has proposed removing the page fault retry path and performing I/O while holding locks [1]. Based on that approach, Hongru has already reported regressions caused by performing I/O under mmap_lock for kernel faults on user addresses [2]. This patchset removes that obstacle.

Another source of I/O under mmap_lock is GUP, which also relies on mmap_lock today and has been reported by Hongru to exhibit similar regressions [2]. It appears Rik van Riel may be addressing this separately [3].

3. The current implementation is inconsistent. Although kernel faults on user addresses always fall back to mmap_lock, arch/*/mm/fault.c still performs !user_mode checks in the per-VMA lock path, making that code effectively dead.

As an RFC, this patchset demonstrates the approach on x86 and arm64 only. Other architectures will need to be updated as well.

[1] https://lore.kernel.org/linux-mm/[email protected]/
[2] https://lore.kernel.org/linux-mm/[email protected]/
[3] https://lore.kernel.org/linux-mm/[email protected]/

Barry Song (Xiaomi) (2):
x86/mm: use VMA lock for kernel faults on user addresses arm64/mm: use VMA lock for kernel faults on user addresses

 arch/arm64/mm/fault.c | 4 +++-
 arch/x86/mm/fault.c   | 3 ---
 2 files changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.39.3 (Apple Git-146)