Skip to contentSkip to conversation

mm: rmap: use VM_BUG_ON_PAGE() in __page_check_anon_rmap()

PATCH In review Yang Shi 2 participants 2 messages Nov 7, 2019 – Nov 11, 2019

Subsystems (2)
lore
Share & tools
lore

Yang Shi

author
#0 lore raw

PATCH v2 1/1 mm: rmap: use VM_BUG_ON_PAGE() in __page_check_anon_rmap()

The __page_check_anon_rmap() just calls two BUG_ON()s protected by CONFIG_DEBUG_VM, the #ifdef could be eliminated by using VM_BUG_ON_PAGE().

Cc Kirill A. Shutemov <[email protected]>

---
v2: Use VM_BUG_ON_PAGE() per Kirill and update the subject accordingly.

 mm/rmap.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
mm/rmap.c +3 -4
index d17cbf3..71d58d6 100644
@@ -1055,7 +1055,6 @@ static void __page_set_anon_rmap(struct page *page,
 static void __page_check_anon_rmap(struct page *page,
 	struct vm_area_struct *vma, unsigned long address)
 {
-#ifdef CONFIG_DEBUG_VM
 	/*
 	 * The page's anon-rmap details (mapping and index) are guaranteed to
 	 * be set up correctly at this point.
@@ -1068,9 +1067,9 @@ static void __page_check_anon_rmap(struct page *page,
 	 * are initially only visible via the pagetables, and the pte is locked
 	 * over the call to page_add_new_anon_rmap.
 	 */
-	BUG_ON(page_anon_vma(page)->root != vma->anon_vma->root);
-	BUG_ON(page_to_pgoff(page) != linear_page_index(vma, address));
-#endif
+	VM_BUG_ON_PAGE(page_anon_vma(page)->root != vma->anon_vma->root, page);
+	VM_BUG_ON_PAGE(page_to_pgoff(page) != linear_page_index(vma, address),
+		       page);
 }
 
 /**
Signature · 1 line
1.8.3.1