linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/5] bug: When !CONFIG_BUG, simplify WARN_ON_ONCE and family
@ 2014-02-26  3:48 Josh Triplett
  2014-02-26  3:48 ` [PATCH v2 2/5] include/asm-generic/bug.h: Style fix: s/while(0)/while (0)/ Josh Triplett
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Josh Triplett @ 2014-02-26  3:48 UTC (permalink / raw)
  To: Andrew Morton, Arnd Bergmann, linux-arch, linux-kernel

When !CONFIG_BUG, WARN_ON and family become simple passthroughs of their
condition argument; however, WARN_ON_ONCE and family still have
conditions and a boolean to detect one-time invocation, even though the
warning they'd emit doesn't exist.  Make the existing definitions
conditional on CONFIG_BUG, and add definitions for !CONFIG_BUG that map
to the passthrough versions of WARN and WARN_ON.

This saves 4.4k on a minimized configuration (smaller than
allnoconfig), and 20.6k with defconfig plus CONFIG_BUG=n.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
v2: Incorporate feedback from Arnd Bergmann: make the WARN_* variants with
    format strings and arguments call WARN and pass along those arguments,
    rather than calling WARN_ON.  Used by the new patch 3, which makes the stub
    version of WARN call no_printk.

 include/asm-generic/bug.h | 57 +++++++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 7d10f96..7ecd398 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -106,33 +106,6 @@ extern void warn_slowpath_null(const char *file, const int line);
 	unlikely(__ret_warn_on);					\
 })
 
-#else /* !CONFIG_BUG */
-#ifndef HAVE_ARCH_BUG
-#define BUG() do {} while(0)
-#endif
-
-#ifndef HAVE_ARCH_BUG_ON
-#define BUG_ON(condition) do { if (condition) ; } while(0)
-#endif
-
-#ifndef HAVE_ARCH_WARN_ON
-#define WARN_ON(condition) ({						\
-	int __ret_warn_on = !!(condition);				\
-	unlikely(__ret_warn_on);					\
-})
-#endif
-
-#ifndef WARN
-#define WARN(condition, format...) ({					\
-	int __ret_warn_on = !!(condition);				\
-	unlikely(__ret_warn_on);					\
-})
-#endif
-
-#define WARN_TAINT(condition, taint, format...) WARN_ON(condition)
-
-#endif
-
 #define WARN_ON_ONCE(condition)	({				\
 	static bool __section(.data.unlikely) __warned;		\
 	int __ret_warn_once = !!(condition);			\
@@ -163,6 +136,36 @@ extern void warn_slowpath_null(const char *file, const int line);
 	unlikely(__ret_warn_once);				\
 })
 
+#else /* !CONFIG_BUG */
+#ifndef HAVE_ARCH_BUG
+#define BUG() do {} while(0)
+#endif
+
+#ifndef HAVE_ARCH_BUG_ON
+#define BUG_ON(condition) do { if (condition) ; } while(0)
+#endif
+
+#ifndef HAVE_ARCH_WARN_ON
+#define WARN_ON(condition) ({						\
+	int __ret_warn_on = !!(condition);				\
+	unlikely(__ret_warn_on);					\
+})
+#endif
+
+#ifndef WARN
+#define WARN(condition, format...) ({					\
+	int __ret_warn_on = !!(condition);				\
+	unlikely(__ret_warn_on);					\
+})
+#endif
+
+#define WARN_ON_ONCE(condition) WARN_ON(condition)
+#define WARN_ONCE(condition, format...) WARN(condition, format)
+#define WARN_TAINT(condition, taint, format...) WARN(condition, format)
+#define WARN_TAINT_ONCE(condition, taint, format...) WARN(condition, format)
+
+#endif
+
 /*
  * WARN_ON_SMP() is for cases that the warning is either
  * meaningless for !SMP or may even cause failures.
-- 
1.9.0


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

end of thread, other threads:[~2014-03-11 17:49 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-26  3:48 [PATCH v2 1/5] bug: When !CONFIG_BUG, simplify WARN_ON_ONCE and family Josh Triplett
2014-02-26  3:48 ` [PATCH v2 2/5] include/asm-generic/bug.h: Style fix: s/while(0)/while (0)/ Josh Triplett
2014-02-26 13:25   ` Arnd Bergmann
2014-02-26  3:49 ` [PATCH v2 3/5] bug: When !CONFIG_BUG, make WARN call no_printk to check format and args Josh Triplett
2014-02-26 13:25   ` Arnd Bergmann
2014-02-26  3:49 ` [PATCH v2 4/5] bug: Use a common definition of BUG_ON regardless of CONFIG_BUG Josh Triplett
2014-02-26 13:26   ` Arnd Bergmann
2014-02-26  3:49 ` [PATCH v2 5/5] bug: Make BUG() call unreachable() Josh Triplett
2014-02-26 13:29   ` Arnd Bergmann
2014-02-26 14:58     ` Josh Triplett
2014-02-27 19:19       ` Arnd Bergmann
2014-02-28  0:16         ` Josh Triplett
2014-02-28  8:55           ` Arnd Bergmann
2014-03-10  1:00             ` [PATCH v3 1/5] bug: When !CONFIG_BUG, simplify WARN_ON_ONCE and family Josh Triplett
2014-03-10  1:01               ` [PATCH v3 2/5] include/asm-generic/bug.h: Style fix: s/while(0)/while (0)/ Josh Triplett
2014-03-10  1:02               ` [PATCH v3 3/5] bug: When !CONFIG_BUG, make WARN call no_printk to check format and args Josh Triplett
2014-03-10  1:02               ` [PATCH v3 4/5] bug: Make BUG() always stop the machine Josh Triplett
2014-03-10  1:03               ` [PATCH v3 5/5] x86: Always define BUG() and HAVE_ARCH_BUG, even with !CONFIG_BUG Josh Triplett
2014-03-11 16:40               ` [PATCH v3 1/5] bug: When !CONFIG_BUG, simplify WARN_ON_ONCE and family Arnd Bergmann
2014-03-11 17:49                 ` Josh Triplett
2014-02-26 13:24 ` [PATCH v2 " Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).