From: Steven Rostedt <rostedt@goodmis.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Alexey Dobriyan <adobriyan@gmail.com>,
richard -rw- weinberger <richard.weinberger@gmail.com>,
linux-kernel@vger.kernel.org, mingo@redhat.com,
torvalds@linux-foundation.org, srostedt@redhat.com,
tglx@linutronix.de, linux-tip-commits@vger.kernel.org
Subject: Re: [tip:core/urgent] WARN_ON_SMP(): Add comment to explain ({0;})
Date: Tue, 29 Mar 2011 10:47:28 -0400 [thread overview]
Message-ID: <1301410048.14261.279.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <8fa65ade-2b9f-4f05-9b52-dfd770326f44@email.android.com>
On Tue, 2011-03-29 at 07:32 -0700, H. Peter Anvin wrote:
> I think the question is what are the expected semantics if WARN_ON_SMP
> is used in an if... especially for UP.
Well, actually this whole patchset was created because we added the
semantic if (WARN_ON_SMP(x)).
This patch: https://lkml.org/lkml/2011/3/11/463
Added the following code:
+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)))
+ return;
+
+ hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock);
+ plist_del(&q->list, &hb->chain);
+}
Which on !CONFIG_SMP broke, because that "|| !spin_is_locked()" always
return true and we trigger the WARN_ON() as well as returning early,
breaking the code, and triggering bugs, as we never do the
"plist_del()".
To fix this, I added: https://lkml.org/lkml/2011/3/17/312
Which does this change:
@@ -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);
But as WARN_ON_SMP() currently had no if () context, I needed to first
make the change of: https://lkml.org/lkml/2011/3/17/313
#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
But if this is such a problem, we can revert all this and do:
@@ -785,8 +785,11 @@ 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)))
+#ifdef CONFIG_SMP
+ if (WARN_ON(!q->lock_ptr || !spin_is_locked(q->lock_ptr))
+ return;
+#endif
+ if (WARN_ON(plist_node_empty(&q->list)))
return;
hb = container_of(q->lock_ptr, struct futex_hash_bucket, lock);
And leave the WARN_ON_SMP() alone.
-- Steve
next prev parent reply other threads:[~2011-03-29 14:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <tip-ccd0d44fad38dc1bb4b26dcc7a30e9f2c3b36870@git.kernel.org>
2011-03-28 14:51 ` H. Peter Anvin
2011-03-28 14:56 ` richard -rw- weinberger
2011-03-28 14:58 ` H. Peter Anvin
2011-03-28 15:09 ` Steven Rostedt
2011-03-28 18:18 ` Alexey Dobriyan
2011-03-29 7:30 ` Ingo Molnar
[not found] ` <8fa65ade-2b9f-4f05-9b52-dfd770326f44@email.android.com>
2011-03-29 14:47 ` Steven Rostedt [this message]
2011-03-29 11:36 ` 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=1301410048.14261.279.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=adobriyan@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=richard.weinberger@gmail.com \
--cc=srostedt@redhat.com \
--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
all inboxes | Powered by JetHome®