[PATCH v5 01/14] mmdebug: Always evaluate the arguments to VM_BUG_ON_*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I recently got the order of arguments to VM_BUG_ON_VMA the wrong way
around, which was only noticable when compiling with CONFIG_DEBUG_VM.
Prevent the next mistake of this kind by making the macros evaluate both
their arguments at compile time (this has no effect on the built kernel).

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@xxxxxxxxx>
---
 include/linux/mmdebug.h | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h
index de7be78..abfc316 100644
--- a/include/linux/mmdebug.h
+++ b/include/linux/mmdebug.h
@@ -41,9 +41,24 @@ void dump_mm(const struct mm_struct *mm);
 #define VM_WARN_ONCE(cond, format...) WARN_ONCE(cond, format)
 #else
 #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond)
-#define VM_BUG_ON_PAGE(cond, page) VM_BUG_ON(cond)
-#define VM_BUG_ON_VMA(cond, vma) VM_BUG_ON(cond)
-#define VM_BUG_ON_MM(cond, mm) VM_BUG_ON(cond)
+#define VM_BUG_ON_PAGE(cond, page)					\
+	do {								\
+		if (0) dump_page(page, "");				\
+		VM_BUG_ON(cond);					\
+	} while (0)
+
+#define VM_BUG_ON_VMA(cond, vma)					\
+	do {								\
+		if (0) dump_vma(vma);					\
+		VM_BUG_ON(cond);					\
+	} while (0)
+
+#define VM_BUG_ON_MM(cond, mm)						\
+	do {								\
+		if (0) dump_mm(mm);					\
+		VM_BUG_ON(cond);					\
+	} while (0)
+
 #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond)
 #define VM_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)
 #define VM_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)
-- 
2.7.0

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux