diff mbox series

[RFC,05/14] mm/khugepaged: add mmap_assert_locked() checks to scan_pmd()

Message ID 20220308213417.1407042-6-zokeefe@google.com (mailing list archive)
State New
Headers show
Series mm: userspace hugepage collapse | expand

Commit Message

Zach O'Keefe March 8, 2022, 9:34 p.m. UTC
scan_pmd() requires mmap_lock held in read. Add a lockdep assertion to
guard this condition, as scan_pmd() will be called from other contexts
later in the series.

Signed-off-by: Zach O'Keefe <zokeefe@google.com>
---
 mm/khugepaged.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index b204bc1eefa7..56f2ef7146c7 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1253,6 +1253,7 @@  struct scan_pmd_result {
 	struct page *head;
 };
 
+/* Called with mmap_lock held and does not drop it. */
 static void scan_pmd(struct mm_struct *mm,
 		     struct vm_area_struct *vma,
 		     unsigned long address,
@@ -1267,6 +1268,7 @@  static void scan_pmd(struct mm_struct *mm,
 	spinlock_t *ptl;
 	int node = NUMA_NO_NODE;
 
+	mmap_assert_locked(mm);
 	VM_BUG_ON(address & ~HPAGE_PMD_MASK);
 
 	pmd = mm_find_pmd(mm, address);