From: Frederic Weisbecker <fweisbec@gmail.com>
To: Christoph Lameter <cl@linux.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Gilad Ben-Yossef <gilad@benyossef.com>,
Thomas Gleixner <tglx@linutronix.de>,
Mike Frysinger <vapier@gentoo.org>,
linux-kernel@vger.kernel.org,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [RFC] Restrict kernel spawning of threads to a specified set of cpus.
Date: Thu, 12 Sep 2013 20:30:25 +0200 [thread overview]
Message-ID: <20130912183023.GA25386@somewhere> (raw)
In-Reply-To: <0000014112d66287-d0abaeb1-71ff-48a0-8740-f984d47400a7-000000@email.amazonses.com>
On Thu, Sep 12, 2013 at 03:42:21PM +0000, Christoph Lameter wrote:
> Let me just say that the user space approach does not work because the
> kernel sets the cpumask to all and then spawns a thread f.e. for
> usermodehelper.
>
> This mean we would have to run a daemon that keeps scanning for errand
> threads and then move them. But at that point the damage would already
> have been done. Short term threads would never be caught.
>
> So I think the kernel based approach is unavoidable.
>
> Look at this in kernel/kmod.c:
>
> static int ____call_usermodehelper(void *data)
> {
> struct subprocess_info *sub_info = data;
> struct cred *new;
> int retval;
>
> spin_lock_irq(¤t->sighand->siglock);
> flush_signal_handlers(current, 1);
> spin_unlock_irq(¤t->sighand->siglock);
>
> /* We can run anywhere, unlike our parent keventd(). */
> set_cpus_allowed_ptr(current, cpu_all_mask);
>
>
> !!!!! No chance to catch this from user space.
>
>
>
> ....
>
> retval = do_execve(sub_info->path,
> (const char __user *const __user *)sub_info->argv,
> (const char __user *const __user *)sub_info->envp);
> if (!retval)
>
>
> ....
>
Yeah, setting the threads affinity is racy from userspace in any case. By the time
one scan /proc for tasks, some others can be forked concurrently.
So yeah it's a problem in theory. Now in practice, I have yet to be convinced because
this should be solved after a few iterations in /proc in most cases.
Now the issue doesn't only concern kthreads but all tasks in the system.
If we really want to solve that race, then may be we can think of a kernel_parameter
that sets the initial affinity of init and then lets get it naturally inherited
through the whole tree.
next prev parent reply other threads:[~2013-09-12 18:30 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-05 20:07 [RFC] Restrict kernel spawning of threads to a specified set of cpus Christoph Lameter
2013-09-10 6:05 ` Gilad Ben-Yossef
2013-09-10 6:47 ` Mike Galbraith
2013-09-10 6:59 ` Gilad Ben-Yossef
2013-09-10 7:26 ` Mike Galbraith
2013-09-10 7:56 ` Gilad Ben-Yossef
2013-09-10 8:53 ` Mike Galbraith
2013-09-10 21:10 ` Christoph Lameter
2013-09-11 3:20 ` Mike Galbraith
2013-09-11 14:21 ` Christoph Lameter
2013-09-11 14:53 ` Mike Galbraith
2013-09-11 16:56 ` Christoph Lameter
2013-09-11 21:36 ` Frederic Weisbecker
2013-09-12 3:30 ` Mike Galbraith
2013-09-10 21:08 ` Christoph Lameter
2013-09-10 7:39 ` Rob Landley
2013-09-10 21:11 ` Christoph Lameter
2013-09-11 22:02 ` Frederic Weisbecker
2013-09-12 14:10 ` Christoph Lameter
2013-09-12 14:16 ` Frederic Weisbecker
2013-09-12 14:22 ` Christoph Lameter
2013-09-12 14:31 ` Frederic Weisbecker
2013-09-12 14:52 ` Christoph Lameter
2013-09-12 15:11 ` Frederic Weisbecker
2013-09-12 15:32 ` Christoph Lameter
2013-09-12 18:45 ` Frederic Weisbecker
2013-09-12 15:39 ` Paul E. McKenney
2013-09-12 18:35 ` Frederic Weisbecker
2013-09-12 18:51 ` Paul E. McKenney
2013-09-15 13:53 ` Gilad Ben-Yossef
[not found] ` <alpine.DEB.2.02.1309121030390.21473@gentwo.org>
2013-09-12 15:42 ` Christoph Lameter
2013-09-12 18:30 ` Frederic Weisbecker [this message]
2013-09-13 9:25 ` Peter Zijlstra
2013-09-13 13:54 ` Christoph Lameter
2013-09-13 14:40 ` Peter Zijlstra
2013-09-13 15:15 ` Christoph Lameter
[not found] ` <alpine.DEB.2.02.1309131010480.26487@gentwo.org>
2013-09-13 15:40 ` Christoph Lameter
2013-09-16 6:02 ` Peter Zijlstra
2013-09-13 13:45 ` Christoph Lameter
2013-09-13 14:04 ` Frederic Weisbecker
2013-09-13 14:25 ` Christoph Lameter
2013-09-15 13:47 ` Gilad Ben-Yossef
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=20130912183023.GA25386@somewhere \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=gilad@benyossef.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vapier@gentoo.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