* [PATCH 0/2 v2] [GIT PULL] futex: Fix WARN_ON trigging on UP
@ 2011-03-17 21:56 Steven Rostedt
2011-03-17 21:56 ` [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements " Steven Rostedt
2011-03-17 21:56 ` [PATCH 2/2 v2] futex: Fix WARN_ON() test for UP Steven Rostedt
0 siblings, 2 replies; 7+ messages in thread
From: Steven Rostedt @ 2011-03-17 21:56 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
Lai Jiangshan, Darren Hart
Thomas,
Changes for v2:
o Added Darren's Acked-by to 2/2
o Two be's or not two be's... THAT is the question!
(the answer is one be)
Please pull the futex patches from:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-rt.git
branch: tip/futex/devel
Steven Rostedt (2):
WARN_ON_SMP(): Allow use in if statements on UP
futex: Fix WARN_ON() test for UP
----
include/asm-generic/bug.h | 28 +++++++++++++++++++++++++++-
kernel/futex.c | 4 ++--
2 files changed, 29 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements on UP
2011-03-17 21:56 [PATCH 0/2 v2] [GIT PULL] futex: Fix WARN_ON trigging on UP Steven Rostedt
@ 2011-03-17 21:56 ` Steven Rostedt
2011-03-18 9:12 ` Peter Zijlstra
2011-03-17 21:56 ` [PATCH 2/2 v2] futex: Fix WARN_ON() test for UP Steven Rostedt
1 sibling, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2011-03-17 21:56 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
Lai Jiangshan, Darren Hart
[-- Attachment #1: 0001-WARN_ON_SMP-Allow-use-in-if-statements-on-UP.patch --]
[-- Type: text/plain, Size: 1734 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
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>
---
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
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements on UP
2011-03-17 21:56 ` [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements " Steven Rostedt
@ 2011-03-18 9:12 ` Peter Zijlstra
2011-03-18 12:14 ` Steven Rostedt
2011-03-24 13:36 ` Steven Rostedt
0 siblings, 2 replies; 7+ messages in thread
From: Peter Zijlstra @ 2011-03-18 9:12 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
Lai Jiangshan, Darren Hart
On Thu, 2011-03-17 at 17:56 -0400, Steven Rostedt wrote:
> + * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
> + * returns 0 for uniprocessor settings.
Arguably most spin_is_locked() usages should be removed in favour of
something like lockdep_assert_held().
The latter only emits code then built with lockdep enabled and it checks
we are indeed the owner, not some random other cpu.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements on UP
2011-03-18 9:12 ` Peter Zijlstra
@ 2011-03-18 12:14 ` Steven Rostedt
2011-03-18 12:27 ` Peter Zijlstra
2011-03-24 13:36 ` Steven Rostedt
1 sibling, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2011-03-18 12:14 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
Lai Jiangshan, Darren Hart
On Fri, 2011-03-18 at 10:12 +0100, Peter Zijlstra wrote:
> On Thu, 2011-03-17 at 17:56 -0400, Steven Rostedt wrote:
> > + * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
> > + * returns 0 for uniprocessor settings.
>
> Arguably most spin_is_locked() usages should be removed in favour of
> something like lockdep_assert_held().
>
> The latter only emits code then built with lockdep enabled and it checks
> we are indeed the owner, not some random other cpu.
>
Perhaps we should have lockdep_assert_held() also be in
"spin_is_locked()". The warning with spin_is_locked() is still nice to
have because it can trigger on production systems that might find a code
path that it's not locked. lockdep is too heavy to run on production
systems. But if lockdep is enabled, the spin_is_locked() should probably
check ownership too.
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements on UP
2011-03-18 12:14 ` Steven Rostedt
@ 2011-03-18 12:27 ` Peter Zijlstra
0 siblings, 0 replies; 7+ messages in thread
From: Peter Zijlstra @ 2011-03-18 12:27 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
Lai Jiangshan, Darren Hart
On Fri, 2011-03-18 at 08:14 -0400, Steven Rostedt wrote:
> On Fri, 2011-03-18 at 10:12 +0100, Peter Zijlstra wrote:
> > On Thu, 2011-03-17 at 17:56 -0400, Steven Rostedt wrote:
> > > + * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
> > > + * returns 0 for uniprocessor settings.
> >
> > Arguably most spin_is_locked() usages should be removed in favour of
> > something like lockdep_assert_held().
> >
> > The latter only emits code then built with lockdep enabled and it checks
> > we are indeed the owner, not some random other cpu.
> >
>
> Perhaps we should have lockdep_assert_held() also be in
> "spin_is_locked()".
Can't since its got stronger requirements.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements on UP
2011-03-18 9:12 ` Peter Zijlstra
2011-03-18 12:14 ` Steven Rostedt
@ 2011-03-24 13:36 ` Steven Rostedt
1 sibling, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2011-03-24 13:36 UTC (permalink / raw)
To: Peter Zijlstra
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Thomas Gleixner,
Lai Jiangshan, Darren Hart
On Fri, 2011-03-18 at 10:12 +0100, Peter Zijlstra wrote:
> On Thu, 2011-03-17 at 17:56 -0400, Steven Rostedt wrote:
> > + * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked()
> > + * returns 0 for uniprocessor settings.
>
> Arguably most spin_is_locked() usages should be removed in favour of
> something like lockdep_assert_held().
>
> The latter only emits code then built with lockdep enabled and it checks
> we are indeed the owner, not some random other cpu.
>
Without going into the issue that spin_is_locked() should go into the
lockdep category, and we should restructure every user of it to use
lockdep instead...
Peter, for the immediate fix (eg. this merge window), can I have your
acked-by for this patch?
Thanks,
-- Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2 v2] futex: Fix WARN_ON() test for UP
2011-03-17 21:56 [PATCH 0/2 v2] [GIT PULL] futex: Fix WARN_ON trigging on UP Steven Rostedt
2011-03-17 21:56 ` [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements " Steven Rostedt
@ 2011-03-17 21:56 ` Steven Rostedt
1 sibling, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2011-03-17 21:56 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Thomas Gleixner, Peter Zijlstra,
Lai Jiangshan, Darren Hart, Richard Weinberger
[-- Attachment #1: 0002-futex-Fix-WARN_ON-test-for-UP.patch --]
[-- Type: text/plain, Size: 1124 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
An update of the futex code had a
WARN_ON(!spin_is_locked(q->lock_ptr))
But on UP, spin_is_locked() is always false, and will
trigger this warning, and even worse, it will exit the function
without doing the necessary work.
Converting this to a WARN_ON_SMP() fixes the problem.
Reported-by: Richard Weinberger <richard@nod.at>
Tested-by: Richard Weinberger <richard@nod.at>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/futex.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index 9fe9131..850d00b 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -785,8 +785,8 @@ static void __unqueue_futex(struct futex_q *q)
{
struct futex_hash_bucket *hb;
- if (WARN_ON(!q->lock_ptr || !spin_is_locked(q->lock_ptr)
- || plist_node_empty(&q->list)))
+ if (WARN_ON_SMP(!q->lock_ptr || !spin_is_locked(q->lock_ptr))
+ || WARN_ON(plist_node_empty(&q->list)))
return;
hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-03-24 13:36 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-17 21:56 [PATCH 0/2 v2] [GIT PULL] futex: Fix WARN_ON trigging on UP Steven Rostedt
2011-03-17 21:56 ` [PATCH 1/2 v2] WARN_ON_SMP(): Allow use in if statements " Steven Rostedt
2011-03-18 9:12 ` Peter Zijlstra
2011-03-18 12:14 ` Steven Rostedt
2011-03-18 12:27 ` Peter Zijlstra
2011-03-24 13:36 ` Steven Rostedt
2011-03-17 21:56 ` [PATCH 2/2 v2] futex: Fix WARN_ON() test for UP Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.