From: Frederic Weisbecker <fweisbec@gmail.com>
To: Tejun Heo <tj@kernel.org>, Li Zefan <lizf@cn.fujitsu.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Mandeep Singh Baines <msb@chromium.org>,
Oleg Nesterov <oleg@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [RFC][PATCH 0/2] cgroup: Fix some races against css_set task links
Date: Wed, 8 Feb 2012 03:37:25 +0100 [thread overview]
Message-ID: <1328668647-24125-1-git-send-email-fweisbec@gmail.com> (raw)
Hi,
This is trying to fix some races in the way to link all the tasks to
the css_set links. I hope some people can have a look at this, especially
as I'm definetly not an SMP ordering expert.
To give you the big picture, as long as nobody never calls
cgroup_iter_start(), we don't link the tasks to their css_set (this 'link'
is a simple list_add()).
But once somebody calls cgroup_iter_start(), we call
cgroup_enable_task_cg_lists() that grossly does this:
cgroup_enable_task_cg_lists() {
use_task_set_css_links = 1;
do_each_thread(g, p) {
link p to css_set
} while_each_thread(g, p);
}
But this links only existing tasks, we also need to link all the tasks
that will be created later, this is what does cgroup_post_fork():
cgroup_post_fork() {
if (use_task_set_css_links)
link p to css_set
}
So we have some races here:
- cgroup_enable_task_cg_lists() iterates over the tasklist
without protection. The comments are advertizing we are using RCU
but we don't. And in fact RCU doesn't yet protect against
while_each_thread().
- Moreover with RCU there is a risk that we iterate the tasklist but
we don't immediately see all the last updates that happened. For
example if a task forks and passes cgroup_post_fork() while
use_task_set_css_links = 0 then another CPU calling
cgroup_enable_task_cg_list() can miss the new child while walking the
tasklist with RCU as it doesn't appear immediately.
- There is no ordering constraint on use_task_set_css_links read/write
against the tasklist traversal and modification. cgroup_post_fork()
may deal with a stale value.
The second patch of the series is a proposal to fix the three above
points. Tell me what you think.
Thanks.
Frederic Weisbecker (2):
cgroup: Remove wrong comment on cgroup_enable_task_cg_list()
cgroup: Walk task list under tasklist_lock in
cgroup_enable_task_cg_list
kernel/cgroup.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
--
1.7.5.4
next reply other threads:[~2012-02-08 2:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-08 2:37 Frederic Weisbecker [this message]
2012-02-08 2:37 ` [PATCH 1/2] cgroup: Remove wrong comment on cgroup_enable_task_cg_list() Frederic Weisbecker
2012-02-08 2:37 ` [PATCH 2/2] cgroup: Walk task list under tasklist_lock in cgroup_enable_task_cg_list Frederic Weisbecker
2012-02-21 22:23 ` Mandeep Singh Baines
2012-02-22 0:55 ` Frederic Weisbecker
2012-02-22 1:00 ` Tejun Heo
2012-02-22 1:04 ` Frederic Weisbecker
2012-02-22 1:06 ` Tejun Heo
2012-02-22 1:10 ` Frederic Weisbecker
2012-02-22 1:19 ` Paul E. McKenney
2012-02-22 1:33 ` Frederic Weisbecker
2012-02-22 18:03 ` Oleg Nesterov
2012-02-27 18:57 ` Frederic Weisbecker
2012-02-17 5:41 ` [RFC][PATCH 0/2] cgroup: Fix some races against css_set task links Li Zefan
2012-02-21 17:16 ` Tejun Heo
2012-02-21 17:42 ` Frederic Weisbecker
2012-02-21 17:46 ` Tejun Heo
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=1328668647-24125-1-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizf@cn.fujitsu.com \
--cc=msb@chromium.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tj@kernel.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®