linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] mm: pass VM_BUG_ON() reason to dump_page()
@ 2014-04-11 20:42 Dave Hansen
  2014-04-11 21:23 ` Davidlohr Bueso
  2014-04-16 23:07 ` Andrew Morton
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Hansen @ 2014-04-11 20:42 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, linux-mm, Dave Hansen, dave.hansen, kirill.shutemov


Changes from v1:
 * Fix tabs before spaces in the multi-line #define

--
From: Dave Hansen <dave.hansen@linux.intel.com>

I recently added a patch to let folks pass a "reason" string
dump_page() which gets dumped out along with the page's data.
This essentially saves the bug-reader a trip in to the source
to figure out why we BUG_ON()'d.

The new VM_BUG_ON_PAGE() passes in NULL for "reason".  It seems
like we might as well pass the BUG_ON() condition if we have it.
This will bloat kernels a bit with ~160 new strings, but this
is all under a debugging option anyway.

	page:ffffea0008560280 count:1 mapcount:0 mapping:(null) index:0x0
	page flags: 0xbfffc0000000001(locked)
	page dumped because: VM_BUG_ON_PAGE(PageLocked(page))
	------------[ cut here ]------------
	kernel BUG at /home/davehans/linux.git/mm/filemap.c:464!
	invalid opcode: 0000 [#1] SMP
	CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.14.0+ #251
	Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
	...


Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---

 b/include/linux/mmdebug.h |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff -puN include/linux/mmdebug.h~pass-VM_BUG_ON-reason-to-dump_page include/linux/mmdebug.h
--- a/include/linux/mmdebug.h~pass-VM_BUG_ON-reason-to-dump_page	2014-04-11 13:39:26.313125298 -0700
+++ b/include/linux/mmdebug.h	2014-04-11 13:40:26.417835916 -0700
@@ -9,8 +9,13 @@ extern void dump_page_badflags(struct pa
 
 #ifdef CONFIG_DEBUG_VM
 #define VM_BUG_ON(cond) BUG_ON(cond)
-#define VM_BUG_ON_PAGE(cond, page) \
-	do { if (unlikely(cond)) { dump_page(page, NULL); BUG(); } } while (0)
+#define VM_BUG_ON_PAGE(cond, page)						\
+	do {									\
+		if (unlikely(cond)) {						\
+			dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\
+			BUG();							\
+		}								\
+	} while (0)
 #else
 #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond)
 #define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [v2] mm: pass VM_BUG_ON() reason to dump_page()
  2014-04-11 20:42 [PATCH] [v2] mm: pass VM_BUG_ON() reason to dump_page() Dave Hansen
@ 2014-04-11 21:23 ` Davidlohr Bueso
  2014-04-16 23:07 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Davidlohr Bueso @ 2014-04-11 21:23 UTC (permalink / raw)
  To: Dave Hansen; +Cc: akpm, linux-kernel, linux-mm, dave.hansen, kirill.shutemov

On Fri, 2014-04-11 at 13:42 -0700, Dave Hansen wrote:
> Changes from v1:
>  * Fix tabs before spaces in the multi-line #define
> 
> --
> From: Dave Hansen <dave.hansen@linux.intel.com>
> 
> I recently added a patch to let folks pass a "reason" string
> dump_page() which gets dumped out along with the page's data.
> This essentially saves the bug-reader a trip in to the source
> to figure out why we BUG_ON()'d.
> 
> The new VM_BUG_ON_PAGE() passes in NULL for "reason".  It seems
> like we might as well pass the BUG_ON() condition if we have it.
> This will bloat kernels a bit with ~160 new strings, but this
> is all under a debugging option anyway.
> 
> 	page:ffffea0008560280 count:1 mapcount:0 mapping:(null) index:0x0
> 	page flags: 0xbfffc0000000001(locked)
> 	page dumped because: VM_BUG_ON_PAGE(PageLocked(page))
> 	------------[ cut here ]------------
> 	kernel BUG at /home/davehans/linux.git/mm/filemap.c:464!
> 	invalid opcode: 0000 [#1] SMP
> 	CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.14.0+ #251
> 	Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
> 	...
> 
> 
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

Acked-by: Davidlohr Bueso <davidlohr@hp.com>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [v2] mm: pass VM_BUG_ON() reason to dump_page()
  2014-04-11 20:42 [PATCH] [v2] mm: pass VM_BUG_ON() reason to dump_page() Dave Hansen
  2014-04-11 21:23 ` Davidlohr Bueso
@ 2014-04-16 23:07 ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2014-04-16 23:07 UTC (permalink / raw)
  To: Dave Hansen; +Cc: linux-kernel, linux-mm, dave.hansen, kirill.shutemov

On Fri, 11 Apr 2014 13:42:32 -0700 Dave Hansen <dave@sr71.net> wrote:

> 
> I recently added a patch to let folks pass a "reason" string
> dump_page() which gets dumped out along with the page's data.
> This essentially saves the bug-reader a trip in to the source
> to figure out why we BUG_ON()'d.
> 
> The new VM_BUG_ON_PAGE() passes in NULL for "reason".  It seems
> like we might as well pass the BUG_ON() condition if we have it.
> This will bloat kernels a bit with ~160 new strings, but this
> is all under a debugging option anyway.
> 
> 	page:ffffea0008560280 count:1 mapcount:0 mapping:(null) index:0x0
> 	page flags: 0xbfffc0000000001(locked)
> 	page dumped because: VM_BUG_ON_PAGE(PageLocked(page))
> 	------------[ cut here ]------------
> 	kernel BUG at /home/davehans/linux.git/mm/filemap.c:464!
> 	invalid opcode: 0000 [#1] SMP
> 	CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.14.0+ #251
> 	Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
> 	...
>
> ...
>
> --- a/include/linux/mmdebug.h~pass-VM_BUG_ON-reason-to-dump_page	2014-04-11 13:39:26.313125298 -0700
> +++ b/include/linux/mmdebug.h	2014-04-11 13:40:26.417835916 -0700
> @@ -9,8 +9,13 @@ extern void dump_page_badflags(struct pa
>  
>  #ifdef CONFIG_DEBUG_VM
>  #define VM_BUG_ON(cond) BUG_ON(cond)
> -#define VM_BUG_ON_PAGE(cond, page) \
> -	do { if (unlikely(cond)) { dump_page(page, NULL); BUG(); } } while (0)
> +#define VM_BUG_ON_PAGE(cond, page)						\
> +	do {									\
> +		if (unlikely(cond)) {						\
> +			dump_page(page, "VM_BUG_ON_PAGE(" __stringify(cond)")");\
> +			BUG();							\
> +		}								\
> +	} while (0)

This seems prudent:

--- a/include/linux/mmdebug.h~mm-pass-vm_bug_on-reason-to-dump_page-fix
+++ a/include/linux/mmdebug.h
@@ -1,6 +1,8 @@
 #ifndef LINUX_MM_DEBUG_H
 #define LINUX_MM_DEBUG_H 1
 
+#include <linux/stringify.h>
+
 struct page;
 
 extern void dump_page(struct page *page, const char *reason);
_

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-16 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-11 20:42 [PATCH] [v2] mm: pass VM_BUG_ON() reason to dump_page() Dave Hansen
2014-04-11 21:23 ` Davidlohr Bueso
2014-04-16 23:07 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox