From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Huang Ying <ying.huang@intel.com>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
Lai Jiangshan <eag0628@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Possible lock-less list race in scheduler_ipi()
Date: Thu, 5 Mar 2015 23:48:51 +0000 (UTC) [thread overview]
Message-ID: <950470583.228004.1425599331454.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <995381344.227770.1425597484864.JavaMail.zimbra@efficios.com>
Hi,
I recently reviewed the scheduler_ipi() code by
coincidence, and noticed that the use of llist.h
in there seemed a bit odd. So I'd like to have
more eyes to help me look into this.
I've been told that there has been issues with
IPIs lately, so here is one possible scenario
I think might be possible:
- scheduler_ipi()
- sched_ttwu_pending()
- llist_del_all()
(grabs the wake_list with xchg())
- raw_spin_lock_irqsave(&rq->lock, flags);
- iteration on the llist (owned locally by interrupt handler)
(for each item)
p = llist_entry(llist, struct task_struct, wake_entry);
llist = llist_next(llist);
ttwu_do_activate(rq, p, 0);
- raw_spin_unlock_irqrestore(&rq->lock, flags);
ttwu_do_activate() ends up calling
ttwu_activate() and ttwu_do_wakeup(),
I'm worried that ttwu_do_wakeup() might end up
indirectly handing off the task to the following
functions (within another execution context):
- try_to_wake_up()
- ttwu_queue()
- ttwu_queue_remote adds the process to another
wake_list with a cmpxchg()
llist_next() is pretty simple:
static inline struct llist_node *llist_next(struct llist_node *node)
{
return node->next;
}
It is so simple that I wonder if the compiler would be
within its rights to reorder the load of node->next
after some operations within ttwu_do_activate(), thus
causing corruption of this linked-list due to a
concurrent try_to_wake_up() performed by another core.
Am I too paranoid about the possible compiler mishaps
there, or are my concerns justified ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next parent reply other threads:[~2015-03-05 23:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <995381344.227770.1425597484864.JavaMail.zimbra@efficios.com>
2015-03-05 23:48 ` Mathieu Desnoyers [this message]
2015-03-06 1:02 ` Linus Torvalds
2015-03-06 14:35 ` Mathieu Desnoyers
2015-03-06 19:03 ` Steven Rostedt
2015-03-06 19:39 ` Mathieu Desnoyers
2015-03-06 20:38 ` Steven Rostedt
2015-03-06 20:39 ` Steven Rostedt
2015-03-06 22:07 ` Mathieu Desnoyers
2015-03-06 17:09 ` Paul E. McKenney
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=950470583.228004.1425599331454.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=eag0628@gmail.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
--cc=ying.huang@intel.com \
/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
Powered by JetHome