diff mbox series

[v2,18/36] mm: Update vma_iter_store() to use MAS_WARN_ON()

Message ID 20230505174204.2665599-19-Liam.Howlett@oracle.com (mailing list archive)
State New
Headers show
Series Maple tree mas_{next,prev}_range() and cleanup | expand

Commit Message

Liam R. Howlett May 5, 2023, 5:41 p.m. UTC
MAS_WARN_ON() will provide more information on the maple state and can
be more useful for debugging.  Use this version of WARN_ON() in the
debugging code when storing to the tree.

Update the printk to a pr_warn(), but this will only be printed when
maple tree debug is enabled anyways.

Making all print statements into one will keep them together on a busy
terminal.

Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 mm/internal.h | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

Comments

Sergey Senozhatsky May 6, 2023, 2:42 a.m. UTC | #1
On (23/05/05 13:41), Liam R. Howlett wrote:
> MAS_WARN_ON() will provide more information on the maple state and can
> be more useful for debugging.  Use this version of WARN_ON() in the
> debugging code when storing to the tree.
> 
> Update the printk to a pr_warn(), but this will only be printed when
> maple tree debug is enabled anyways.
> 
> Making all print statements into one will keep them together on a busy
> terminal.
> 
> Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Sergey Senozhatsky May 6, 2023, 2:47 a.m. UTC | #2
On (23/05/05 13:41), Liam R. Howlett wrote:
>  #if defined(CONFIG_DEBUG_VM_MAPLE_TREE)
> -	if (WARN_ON(vmi->mas.node != MAS_START && vmi->mas.index > vma->vm_start)) {
> -		printk("%lu > %lu\n", vmi->mas.index, vma->vm_start);
> -		printk("store of vma %lu-%lu", vma->vm_start, vma->vm_end);
> -		printk("into slot    %lu-%lu", vmi->mas.index, vmi->mas.last);
> -		vma_iter_dump_tree(vmi);
> +	if (MAS_WARN_ON(&vmi->mas, vmi->mas.node != MAS_START &&
> +			vmi->mas.index > vma->vm_start)) {
> +		pr_warn("%lx > %lx\n"
> +		       "store of vma %lx-%lx\n"
> +		       "into slot    %lx-%lx\n",

A minor side note: we usually prefer to avoid breaking printk() format
strings because it makes grep-ing difficult. But in this particular case
it's fine, since all the format sub-strings end with a new line character.
diff mbox series

Patch

diff --git a/mm/internal.h b/mm/internal.h
index 8d1a8bd001247..6112108322461 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1047,18 +1047,23 @@  static inline void vma_iter_store(struct vma_iterator *vmi,
 {
 
 #if defined(CONFIG_DEBUG_VM_MAPLE_TREE)
-	if (WARN_ON(vmi->mas.node != MAS_START && vmi->mas.index > vma->vm_start)) {
-		printk("%lu > %lu\n", vmi->mas.index, vma->vm_start);
-		printk("store of vma %lu-%lu", vma->vm_start, vma->vm_end);
-		printk("into slot    %lu-%lu", vmi->mas.index, vmi->mas.last);
-		vma_iter_dump_tree(vmi);
+	if (MAS_WARN_ON(&vmi->mas, vmi->mas.node != MAS_START &&
+			vmi->mas.index > vma->vm_start)) {
+		pr_warn("%lx > %lx\n"
+		       "store of vma %lx-%lx\n"
+		       "into slot    %lx-%lx\n",
+		       vmi->mas.index, vma->vm_start,
+		       vma->vm_start, vma->vm_end,
+		       vmi->mas.index, vmi->mas.last);
 	}
-	if (WARN_ON(vmi->mas.node != MAS_START && vmi->mas.last <  vma->vm_start)) {
-		printk("%lu < %lu\n", vmi->mas.last, vma->vm_start);
-		printk("store of vma %lu-%lu", vma->vm_start, vma->vm_end);
-		printk("into slot    %lu-%lu", vmi->mas.index, vmi->mas.last);
-		mt_dump(vmi->mas.tree, mt_dump_hex);
-		vma_iter_dump_tree(vmi);
+	if (MAS_WARN_ON(&vmi->mas, vmi->mas.node != MAS_START &&
+			vmi->mas.last <  vma->vm_start)) {
+		pr_warn("%lx < %lx\n"
+		       "store of vma %lx-%lx\n"
+		       "into slot    %lx-%lx\n",
+		       vmi->mas.last, vma->vm_start,
+		       vma->vm_start, vma->vm_end,
+		       vmi->mas.index, vmi->mas.last);
 	}
 #endif