Skip to contentSkip to conversation

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

PATCH Superseded Yang Shi 2 participants 3 messages Nov 5, 2019 – Nov 6, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yang Shi

author
#0 lore raw

PATCH 1/1 mm: rmap: use VM_BUG_ON() 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().

---
 mm/rmap.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
mm/rmap.c +2 -4
index d17cbf3..39178eb 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,8 @@ 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_anon_vma(page)->root != vma->anon_vma->root);
+	VM_BUG_ON(page_to_pgoff(page) != linear_page_index(vma, address));
 }
 
 /**
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 21 lines · Yang Shi

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().

---
 mm/rmap.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
mm/rmap.c +0 -1
index d17cbf3..39178eb 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.

mm/rmap.c static void __page_check_anon_rmap(struct page *page, · line 1071

Quoted 8 lines
mm/rmap.c +2 -3
@@ -1068,9 +1067,8 @@ 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_anon_vma(page)->root != vma->anon_vma->root);
+	VM_BUG_ON(page_to_pgoff(page) != linear_page_index(vma, address));

Why not VM_BUG_ON_PAGE()?

Signature · 1 line
 Kirill A. Shutemov
author
#2 lore raw
Quoted 23 lines · Kirill A. Shutemov
Quoted 22 lines · Yang Shi

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().

---
  mm/rmap.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
mm/rmap.c +0 -1
index d17cbf3..39178eb 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,8 @@ static void __page_check_anon_rmap(struct page *page,
  	 * are initially only visible via the pagetables, and the pte is locked
Quoted 8 lines

mm/rmap.c static void __page_check_anon_rmap(struct page *page, · line 1071

Quoted 7 lines
mm/rmap.c +2 -3
  	 * 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_anon_vma(page)->root != vma->anon_vma->root);
+	VM_BUG_ON(page_to_pgoff(page) != linear_page_index(vma, address));

Why not VM_BUG_ON_PAGE()?

Because I was not intended to change the behavior, just cleanup. We definitely could use VM_BUG_ON_PAGE() if that is preferred.

Quoted 1 line