From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Carsten Emde <C.Emde@osadl.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
John Kacur <jkacur@redhat.com>,
Clark Williams <clark.williams@gmail.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH RT 3/3] swait: Add smp_mb() after setting h->list
Date: Mon, 19 Aug 2013 11:35:33 -0400 [thread overview]
Message-ID: <20130819153619.148613482@goodmis.org> (raw)
In-Reply-To: 20130819153530.409041534@goodmis.org
[-- Attachment #1: 0003-swait-Add-smp_mb-after-setting-h-list.patch --]
[-- Type: text/plain, Size: 1387 bytes --]
From: Steven Rostedt <rostedt@goodmis.org>
The raw_spin_unlock() is not a full memory barrier. It only keeps
things from leaking past it, but does not prevent leaks from entering
the critical section. That is:
p = 1;
raw_spin_lock();
[...]
raw_spin_unlock();
y = x
Can turn into:
p = 1;
raw_spin_lock();
load x
store p = 1
raw_spin_unlock();
y = x
This means that the condition check in __swait_event() (and friends)
can be seen before the h->list is set.
raw_spin_lock();
load condition;
store h->list;
raw_spin_unlock();
And the other CPU can see h->list as empty, and this CPU see condition
as not set, and possibly miss the wake up.
To prevent this from happening, add an mb() after setting the h->list.
Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/wait-simple.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/wait-simple.c b/kernel/wait-simple.c
index 9725a11..2c85626 100644
--- a/kernel/wait-simple.c
+++ b/kernel/wait-simple.c
@@ -16,6 +16,8 @@
static inline void __swait_enqueue(struct swait_head *head, struct swaiter *w)
{
list_add(&w->node, &head->list);
+ /* We can't let the condition leak before the setting of head */
+ smp_mb();
}
/* Removes w from head->list. Must be called with head->lock locked. */
--
1.7.10.4
next prev parent reply other threads:[~2013-08-19 15:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-19 15:35 [PATCH RT 0/3] rt/rcu/swait: Fix boot up when RCU NOCB_ALL is enabled Steven Rostedt
2013-08-19 15:35 ` [PATCH RT 1/3] rcu/swait: Fix RCU conversion of wake_up_all() to swait_wake() Steven Rostedt
2013-08-19 15:35 ` [PATCH RT 2/3] swait: Add memory barrier before checking list empty Steven Rostedt
2013-08-19 15:51 ` Steven Rostedt
2013-08-19 16:49 ` Steven Rostedt
2013-08-19 15:35 ` Steven Rostedt [this message]
2013-08-21 13:41 ` [PATCH RT 0/3] rt/rcu/swait: Fix boot up when RCU NOCB_ALL is enabled Sebastian Andrzej Siewior
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=20130819153619.148613482@goodmis.org \
--to=rostedt@goodmis.org \
--cc=C.Emde@osadl.org \
--cc=bigeasy@linutronix.de \
--cc=clark.williams@gmail.com \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).