mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Paul Menage <menage@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	lkml <linux-kernel@vger.kernel.org>
Subject: On cgroup, cpuset and rcu and a patch.
Date: Tue, 15 Dec 2009 18:17:59 +0100	[thread overview]
Message-ID: <1260897479.8023.603.camel@laptop> (raw)

Hi Paul,

I'm wanting to use cpuset_cpus_allowed_locked() from within a scheduler
path (to break affinity in some rare cases), this however precludes that
I hold any mutex.

>From what I can see, its perfectly safe to use guarantee_online_cpus()
without holding any mutex, or even task_lock(), as long as I hold the
RCU read-lock, since cgroups are RCU-freed and task_cs() includes the
appropriate rcu_dereference(), and cgroup_attach_task() includes the
matching rcu_assign_pointer() call.

Or is there still any merit to the cpuset comments and am I missing some
detail -- which then ought to get fixed?

Also, while looking over the cgroup code, I found the below...

---
Subject: cgroup: fix RCU assumptions

The code relies on RCU read-lock to iterate the task list, but fails to
actually take it.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 kernel/cgroup.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-2.6/kernel/cgroup.c
===================================================================
--- linux-2.6.orig/kernel/cgroup.c
+++ linux-2.6/kernel/cgroup.c
@@ -2127,6 +2127,7 @@ static void cgroup_enable_task_cg_lists(
 	struct task_struct *p, *g;
 	write_lock(&css_set_lock);
 	use_task_css_set_links = 1;
+	rcu_read_lock();
 	do_each_thread(g, p) {
 		task_lock(p);
 		/*
@@ -2138,6 +2139,7 @@ static void cgroup_enable_task_cg_lists(
 			list_add(&p->cg_list, &p->cgroups->tasks);
 		task_unlock(p);
 	} while_each_thread(g, p);
+	rcu_read_unlock();
 	write_unlock(&css_set_lock);
 }
 



                 reply	other threads:[~2009-12-15 17:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1260897479.8023.603.camel@laptop \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=menage@google.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

all inboxes | Powered by JetHome®