diff mbox series

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

Message ID 1572973416-18532-1-git-send-email-yang.shi@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series mm: rmap: use VM_BUG_ON() in __page_check_anon_rmap() | expand

Commit Message

Yang Shi Nov. 5, 2019, 5:03 p.m. UTC
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().

Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
---
 mm/rmap.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Kirill A. Shutemov Nov. 6, 2019, 8:28 a.m. UTC | #1
On Wed, Nov 06, 2019 at 01:03:36AM +0800, Yang Shi wrote:
> 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().
> 
> Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
> ---
>  mm/rmap.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/rmap.c b/mm/rmap.c
> index d17cbf3..39178eb 100644
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -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));

Why not VM_BUG_ON_PAGE()?
Yang Shi Nov. 6, 2019, 5:42 p.m. UTC | #2
On 11/6/19 12:28 AM, Kirill A. Shutemov wrote:
> On Wed, Nov 06, 2019 at 01:03:36AM +0800, Yang Shi wrote:
>> 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().
>>
>> Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
>> ---
>>   mm/rmap.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/rmap.c b/mm/rmap.c
>> index d17cbf3..39178eb 100644
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -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));
> 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.

>
diff mbox series

Patch

diff --git a/mm/rmap.c b/mm/rmap.c
index d17cbf3..39178eb 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -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));
 }
 
 /**