From: Paul Jackson <pj@sgi.com>
To: David Rientjes <rientjes@google.com>
Cc: menage@google.com, akpm@linux-foundation.org,
nickpiggin@yahoo.com.au, a.p.zijlstra@chello.nl,
serue@us.ibm.com, clg@fr.ibm.com, linux-kernel@vger.kernel.org,
ebiederm@xmission.com, svaidy@linux.vnet.ibm.com,
xemul@openvz.org, containers@lists.osdl.org,
balbir@linux.vnet.ibm.com
Subject: Re: [PATCH] task containersv11 add tasks file interface fix for cpusets
Date: Thu, 11 Oct 2007 16:15:59 -0700 [thread overview]
Message-ID: <20071011161559.378e7766.pj@sgi.com> (raw)
In-Reply-To: <alpine.DEB.0.9999.0710101351400.4771@chino.kir.corp.google.com>
David wrote:
> you could protect the whole thing by sched_hotcpu_mutex, which is
> expressly designed for migrations.
>
> Something like this:
>
> struct cgroup_iter it;
> struct task_struct *p, **tasks;
> int i = 0;
>
> cgroup_iter_start(cs->css.cgroup, &it);
> while ((p = cgroup_iter_next(cs->css.cgroup, &it))) {
> get_task_struct(p);
> tasks[i++] = p;
> }
> cgroup_iter_end(cs->css.cgroup, &it);
>
> while (--i >= 0) {
> sched_migrate_task(tasks[i], cs->cpus_allowed);
> put_task_struct(tasks[i]);
> }
>
> kernel/sched.c:
>
> void sched_migrate_task(struct task_struct *task,
> cpumask_t cpus_allowed)
> {
> mutex_lock(&sched_hotcpu_mutex);
> set_cpus_allowed(task, cpus_allowed);
> mutex_unlock(&sched_hotcpu_mutex);
> }
Hmmm ... I hadn't noticed that sched_hotcpu_mutex before.
I wonder what it is guarding? As best as I can guess, it seems, at
least in part, to be keeping the following two items consistent:
1) cpu_online_map
2) the per-task cpus_allowed masks
That is, it seems to ensure that a task is allowed to run on some
online CPU.
If that's approximately true, then shouldn't I take sched_hotcpu_mutex
around the entire chunk of code that handles updating a cpusets 'cpus',
from the time it verifies that the requested CPUs are online, until the
time that every affected task has its cpus_allowed updated?
Furthermore, I should probably guard changes to and verifications
against the top_cpuset's cpus_allowed with this mutex as well, as it is
supposed to be a copy of cpu_online_map.
And since all descendent cpusets have to have 'cpus' masks that are
subsets of their parents, this means guarding other chunks of cpuset
code that depend on the consistency of various per-cpuset cpus_allowed
masks and cpu_online_map.
My current intuition is that this expanded use of sched_hotcpu_mutex in
the cpuset code involving various cpus_allowed masks would be a good
thing.
In sum, perhaps sched_hotcpu_mutex is guarding the dispersed kernel
state that depends on what CPUs are online. This includes the per-task
and per-cpuset cpus_allowed masks, all of which are supposed to be some
non-empty subset of the online CPUs.
Taking and dropping the sched_hotcpu_mutex for each task, just around
the call to set_cpus_allowed(), as you suggested above, doesn't seem to
accomplish much that I can see, and certainly doesn't seem to guard the
consistency of cpu_online_map with the tasks cpus_allowed masks.
... lurkers beware ... good chance I haven't a friggin clue ;).
In other words: Thirty minutes ago I couldn't even spell
sched_hotcpu_mutex, and now I'm pontificating on it ;);).
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.925.600.0401
next prev parent reply other threads:[~2007-10-11 23:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-03 8:42 [PATCH] task containersv11 add tasks file interface fix for cpusets Paul Jackson
2007-10-03 15:51 ` Paul Menage
2007-10-03 17:58 ` Paul Jackson
2007-10-03 18:10 ` Paul Menage
2007-10-03 18:25 ` Paul Menage
2007-10-03 20:16 ` Paul Jackson
2007-10-03 20:31 ` Paul Menage
2007-10-03 20:52 ` Paul Jackson
2007-10-03 20:58 ` Paul Menage
2007-10-06 8:24 ` Paul Jackson
2007-10-06 17:54 ` David Rientjes
2007-10-06 19:59 ` Paul Jackson
2007-10-06 21:09 ` Paul Menage
2007-10-06 21:41 ` Paul Jackson
2007-10-11 22:03 ` Paul Jackson
2007-10-11 23:20 ` Eric W. Biederman
2007-10-12 1:23 ` Paul Jackson
2007-10-07 6:13 ` David Rientjes
2007-10-06 21:11 ` Paul Menage
2007-10-07 6:15 ` David Rientjes
2007-10-10 20:46 ` Paul Menage
2007-10-10 20:59 ` David Rientjes
2007-10-11 23:15 ` Paul Jackson [this message]
2007-10-12 15:13 ` David Rientjes
2007-10-06 20:53 ` Paul Menage
2007-10-03 20:56 ` Paul Jackson
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=20071011161559.378e7766.pj@sgi.com \
--to=pj@sgi.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=balbir@linux.vnet.ibm.com \
--cc=clg@fr.ibm.com \
--cc=containers@lists.osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
--cc=nickpiggin@yahoo.com.au \
--cc=rientjes@google.com \
--cc=serue@us.ibm.com \
--cc=svaidy@linux.vnet.ibm.com \
--cc=xemul@openvz.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