[PATCH v2 10/20] mm: add mmap_read_lock_killable_nested()

From: Anthony Yznaga
Date: Thu Apr 03 2025 - 22:24:51 EST


This will be used to support mshare functionality where the read
lock on an mshare host mm is taken while holding the lock on a
process mm.

Signed-off-by: Anthony Yznaga <anthony.yznaga@xxxxxxxxxx>
---
include/linux/mmap_lock.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/linux/mmap_lock.h b/include/linux/mmap_lock.h
index 4706c6769902..a14d74822846 100644
--- a/include/linux/mmap_lock.h
+++ b/include/linux/mmap_lock.h
@@ -185,6 +185,13 @@ static inline void mmap_read_lock(struct mm_struct *mm)
__mmap_lock_trace_acquire_returned(mm, false, true);
}

+static inline void mmap_read_lock_nested(struct mm_struct *mm, int subclass)
+{
+ __mmap_lock_trace_start_locking(mm, false);
+ down_read_nested(&mm->mmap_lock, subclass);
+ __mmap_lock_trace_acquire_returned(mm, false, true);
+}
+
static inline int mmap_read_lock_killable(struct mm_struct *mm)
{
int ret;
--
2.43.5