linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/3] add and use vma_assert_stabilised() helper
@ 2026-01-16 13:36 Lorenzo Stoakes
  2026-01-16 13:36 ` [PATCH RESEND 1/3] locking: add rwsem_is_write_locked(), update non-lockdep asserts Lorenzo Stoakes
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Lorenzo Stoakes @ 2026-01-16 13:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: David Hildenbrand, Liam R . Howlett, Vlastimil Babka,
	Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Shakeel Butt,
	Jann Horn, linux-mm, linux-kernel, linux-rt-devel,
	Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
	Waiman Long, Sebastian Andrzej Siewior, Clark Williams,
	Steven Rostedt

Sometimes we wish to assert that a VMA is stable, that is - the VMA cannot
be changed underneath us. This will be the case if EITHER the VMA lock or
the mmap lock is held.

We already open-code this in two places - anon_vma_name() in mm/madvise.c
and vma_flag_set_atomic() in include/linux/mm.h.

This series adds a number of pre-requisite predicates and adds
vma_assert_stablisied() which can be used in these callsites instead.

However the asserts implemented there subtly wrong - if CONFIG_PER_VMA_LOCK
is not implemented and the mmap lock is not held, then we don't actually
assert anything.

Since this is an assert that only fires when CONFIG_DEBUG_VM is set and the
test bots will largely be running with CONFIG_PER_VMA_LOCK set, this is
likely in practice not a real-world issue.

In any case, this series additionally fixes this issue.

As part of this change we also reduce duplication of code in VMA lock
asserts.

This change also lays the foundation for future series to add this assert
in further appropriate places to account for us now living in a world where
a VMA may be stablised by either lock.


REVIEWER NOTE: The prior-to-resend version of the series was sent with
insufficient caffeination + my having inevitably got seasonally unwell so
isn't worth looking at :) Treat this one as the only version of the series!

Lorenzo Stoakes (3):
  locking: add rwsem_is_write_locked(), update non-lockdep asserts
  mm/vma: add vma_is_*_locked() helpers
  mm: add + use vma_is_stabilised(), vma_assert_stabilised() helpers

 include/linux/mm.h        |  4 +--
 include/linux/mmap_lock.h | 65 +++++++++++++++++++++++++++++++++------
 include/linux/rwsem.h     | 20 +++++++++---
 mm/madvise.c              |  4 +--
 4 files changed, 73 insertions(+), 20 deletions(-)

--
2.52.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-01-17  2:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-16 13:36 [PATCH RESEND 0/3] add and use vma_assert_stabilised() helper Lorenzo Stoakes
2026-01-16 13:36 ` [PATCH RESEND 1/3] locking: add rwsem_is_write_locked(), update non-lockdep asserts Lorenzo Stoakes
2026-01-16 15:08   ` Zi Yan
2026-01-16 16:29     ` Lorenzo Stoakes
2026-01-16 15:12   ` Peter Zijlstra
2026-01-16 15:50     ` Lorenzo Stoakes
2026-01-16 15:57       ` Sebastian Andrzej Siewior
2026-01-16 16:21         ` Lorenzo Stoakes
2026-01-16 16:41           ` Sebastian Andrzej Siewior
2026-01-16 16:56             ` Lorenzo Stoakes
2026-01-17  2:30           ` Boqun Feng
2026-01-16 13:36 ` [PATCH RESEND 2/3] mm/vma: add vma_is_*_locked() helpers Lorenzo Stoakes
2026-01-16 13:36 ` [PATCH RESEND 3/3] mm: add + use vma_is_stabilised(), vma_assert_stabilised() helpers Lorenzo Stoakes
2026-01-16 20:45   ` Zi Yan
2026-01-16 20:47   ` Zi Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox