|
|
Log in / Subscribe / Register

Use killable vma write locking in most places

From:  Suren Baghdasaryan <surenb-AT-google.com>
To:  akpm-AT-linux-foundation.org
Subject:  [PATCH v4 0/4] Use killable vma write locking in most places
Date:  Sat, 21 Mar 2026 22:43:04 -0700
Message-ID:  <20260322054309.898214-1-surenb@google.com>
Cc:  willy-AT-infradead.org, david-AT-kernel.org, ziy-AT-nvidia.com, matthew.brost-AT-intel.com, joshua.hahnjy-AT-gmail.com, rakie.kim-AT-sk.com, byungchul-AT-sk.com, gourry-AT-gourry.net, ying.huang-AT-linux.alibaba.com, apopple-AT-nvidia.com, lorenzo.stoakes-AT-oracle.com, baolin.wang-AT-linux.alibaba.com, Liam.Howlett-AT-oracle.com, npache-AT-redhat.com, ryan.roberts-AT-arm.com, dev.jain-AT-arm.com, baohua-AT-kernel.org, lance.yang-AT-linux.dev, vbabka-AT-suse.cz, jannh-AT-google.com, rppt-AT-kernel.org, mhocko-AT-suse.com, pfalcato-AT-suse.de, kees-AT-kernel.org, maddy-AT-linux.ibm.com, npiggin-AT-gmail.com, mpe-AT-ellerman.id.au, chleroy-AT-kernel.org, borntraeger-AT-linux.ibm.com, frankja-AT-linux.ibm.com, imbrenda-AT-linux.ibm.com, hca-AT-linux.ibm.com, gor-AT-linux.ibm.com, agordeev-AT-linux.ibm.com, svens-AT-linux.ibm.com, gerald.schaefer-AT-linux.ibm.com, linux-mm-AT-kvack.org, linuxppc-dev-AT-lists.ozlabs.org, kvm-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org, linux-s390-AT-vger.kernel.org, surenb-AT-google.com
Archive-link:  Article

Now that we have vma_start_write_killable() we can replace most of the
vma_start_write() calls with it, improving reaction time to the kill
signal.

There are several places which are left untouched by this patchset:

1. free_pgtables() because function should free page tables even if a
fatal signal is pending.

2. userfaultd code, where some paths calling vma_start_write() can
handle EINTR and some can't without a deeper code refactoring.

3. mpol_rebind_mm() which is used by cpusset controller for migrations
and operates on a remote mm. Incomplete operations here would result
in an inconsistent cgroup state.

4. vm_flags_{set|mod|clear} require refactoring that involves moving
vma_start_write() out of these functions and replacing it with
vma_assert_write_locked(), then callers of these functions should
lock the vma themselves using vma_start_write_killable() whenever
possible.

A cleanup patch is added in the beginning to make later changes more
readable. The second patch contains most of the changes. The third patch
is a small error handling fixup. The last patch contains the changes
associated with process_vma_walk_lock() error handling.

Changes since v3 [1]:
- rebased over mm-unstable
- added Reviewed-by, per Liam R. Howlett and Lorenzo Stoakes
- moved locking before vma_iter_prealloc in vma_shrink and in vma_link,
per Liam R. Howlett
- added a separate jump label for vma lock failure case in do_brk_flags(),
per Liam R. Howlett
- fixed cpusset -> cpuset, per Lorenzo Stoakes
- added comments explaining vma_start_write moves, per Lorenzo Stoakes
- amended patch description with explanation why vma_start_write moves
are safe, per Lorenzo Stoakes
- added comments listing EINTR as a new possible error code,
per Lorenzo Stoakes
- moved comments in mlock_fixup() and apply_mlockall_flags() to more
appropriate places, per Lorenzo Stoakes
- replaced check for EINTR with fatal_signal_pending() with a comment why
it is safe, per Lorenzo Stoakes
- fixed error check in mprotect_fixup(), per Lorenzo Stoakes
- moved vma_start_write_killable() before allocations inside __split_vma()
with a clarifying comment
- changed mmap_region() to set err for each failing case,
per Lorenzo Stoakes
- changed label names in expand_upwards() and expand_downwards(),
per Lorenzo Stoakes
- changed "if (err < 0)" to "if (err)" for consistency,
per Lorenzo Stoakes
- separated error checking fix for s390 into its own patch,
per Lorenzo Stoakes
- removed special handling for EINTR, per Lorenzo Stoakes
- dropped changes trying to propagate EINTR during vma merge,
per Lorenzo Stoakes

[1] https://lore.kernel.org/all/20260226070609.3072570-1-sure...

Suren Baghdasaryan (4):
  mm/vma: cleanup error handling path in vma_expand()
  mm: replace vma_start_write() with vma_start_write_killable()
  KVM: s390: avoid kvm_s390_handle_pv() error overwrite
  mm: use vma_start_write_killable() in process_vma_walk_lock()

 arch/powerpc/kvm/book3s_hv_uvmem.c |   5 +-
 arch/s390/kvm/kvm-s390.c           |   2 +
 fs/proc/task_mmu.c                 |   5 +-
 mm/khugepaged.c                    |   5 +-
 mm/madvise.c                       |   4 +-
 mm/memory.c                        |   2 +
 mm/mempolicy.c                     |  13 ++-
 mm/mlock.c                         |  28 ++++--
 mm/mprotect.c                      |   5 +-
 mm/mremap.c                        |   4 +-
 mm/pagewalk.c                      |  20 +++--
 mm/vma.c                           | 133 +++++++++++++++++++++--------
 mm/vma_exec.c                      |   6 +-
 13 files changed, 173 insertions(+), 59 deletions(-)


base-commit: 8c65073d94c8b7cc3170de31af38edc9f5d96f0e
-- 
2.53.0.1018.g2bb0e51243-goog




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds