From: tip-bot for Steven Rostedt <srostedt@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
torvalds@linux-foundation.org, dvhart@linux.intel.com,
peterz@infradead.org, akpm@linux-foundation.org,
rostedt@goodmis.org, srostedt@redhat.com, tglx@linutronix.de,
laijs@cn.fujitsu.com, mingo@elte.hu
Subject: [tip:core/urgent] WARN_ON_SMP(): Allow use in if() statements on UP
Date: Fri, 25 Mar 2011 10:48:52 GMT [thread overview]
Message-ID: <tip-2092e6be82ec71ecbf5a8ceeef004bbcbdb78812@git.kernel.org> (raw)
In-Reply-To: <20110317192208.444147791@goodmis.org>
Commit-ID: 2092e6be82ec71ecbf5a8ceeef004bbcbdb78812
Gitweb: http://git.kernel.org/tip/2092e6be82ec71ecbf5a8ceeef004bbcbdb78812
Author: Steven Rostedt <srostedt@redhat.com>
AuthorDate: Thu, 17 Mar 2011 15:21:06 -0400
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Fri, 25 Mar 2011 11:32:09 +0100
WARN_ON_SMP(): Allow use in if() statements on UP
Both WARN_ON() and WARN_ON_SMP() should be able to be used in
an if statement.
if (WARN_ON_SMP(foo)) { ... }
Because WARN_ON_SMP() is defined as a do { } while (0) on UP,
it can not be used this way.
Convert it to the same form that WARN_ON() is, even when
CONFIG_SMP is off.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <20110317192208.444147791@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/asm-generic/bug.h | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index c2c9ba0..f2d2faf 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -165,10 +165,36 @@ extern void warn_slowpath_null(const char *file, const int line);
#define WARN_ON_RATELIMIT(condition, state) \
WARN_ON((condition) && __ratelimit(state))
+/*
+ * WARN_ON_SMP() is for cases that the warning is either
+ * meaningless for !SMP or may even cause failures.
+ * This is usually used for cases that we have
+ * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
+ * returns 0 for uniprocessor settings.
+ * It can also be used with values that are only defined
+ * on SMP:
+ *
+ * struct foo {
+ * [...]
+ * #ifdef CONFIG_SMP
+ * int bar;
+ * #endif
+ * };
+ *
+ * void func(struct foo *zoot)
+ * {
+ * WARN_ON_SMP(!zoot->bar);
+ *
+ * For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(),
+ * and should be a nop and return false for uniprocessor.
+ *
+ * if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set
+ * and x is true.
+ */
#ifdef CONFIG_SMP
# define WARN_ON_SMP(x) WARN_ON(x)
#else
-# define WARN_ON_SMP(x) do { } while (0)
+# define WARN_ON_SMP(x) ({0;})
#endif
#endif
next prev parent reply other threads:[~2011-03-25 10:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-17 19:21 [PATCH 0/2] [GIT PULL] futex: Fix WARN_ON triggering on UP Steven Rostedt
2011-03-17 19:21 ` [PATCH 1/2] WARN_ON_SMP(): Allow use in if statements " Steven Rostedt
2011-03-17 20:46 ` Darren Hart
2011-03-25 9:35 ` Peter Zijlstra
2011-03-25 10:48 ` tip-bot for Steven Rostedt [this message]
2011-03-25 16:45 ` [tip:core/urgent] WARN_ON_SMP(): Allow use in if() " Linus Torvalds
2011-03-25 18:16 ` Steven Rostedt
2011-03-25 18:19 ` Steven Rostedt
2011-03-25 19:31 ` Alexey Dobriyan
2011-03-25 19:36 ` Steven Rostedt
2011-03-25 19:40 ` Steven Rostedt
2011-03-25 19:47 ` Alexey Dobriyan
2011-03-25 19:53 ` Steven Rostedt
2011-03-25 19:56 ` Ingo Molnar
2011-03-17 19:21 ` [PATCH 2/2] futex: Fix WARN_ON() test for UP Steven Rostedt
2011-03-17 20:00 ` Darren Hart
2011-03-25 9:35 ` Peter Zijlstra
2011-03-25 10:49 ` [tip:core/urgent] " tip-bot for Steven Rostedt
2011-03-17 19:27 ` [PATCH 0/2] [GIT PULL] futex: Fix WARN_ON triggering on UP Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-2092e6be82ec71ecbf5a8ceeef004bbcbdb78812@git.kernel.org \
--to=srostedt@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dvhart@linux.intel.com \
--cc=hpa@zytor.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox