cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Tejun Heo <tj@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>, Chris Mason <clm@fb.com>,
	linux-kernel@vger.kernel.org, kernel-team@fb.com,
	Li Zefan <lizefan@huawei.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	cgroups@vger.kernel.org
Subject: Re: [PATCH 2/2] kthread, cgroup: close race window where new kthreads can be migrated to non-root cgroups
Date: Thu, 16 Mar 2017 16:02:34 +0100	[thread overview]
Message-ID: <20170316150233.GB24478@redhat.com> (raw)
In-Reply-To: <20170315231920.GB13656@htj.duckdns.org>

On 03/15, Tejun Heo wrote:
>
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -2425,11 +2425,13 @@ ssize_t __cgroup_procs_write(struct kern
>  		tsk = tsk->group_leader;
>  
>  	/*
> -	 * Workqueue threads may acquire PF_NO_SETAFFINITY and become
> -	 * trapped in a cpuset, or RT worker may be born in a cgroup
> -	 * with no rt_runtime allocated.  Just say no.
> +	 * kthreads may acquire PF_NO_SETAFFINITY during initialization.
> +	 * If userland migrates such kthread to a non-root cgroup, it can
> +	 * become trapped in a cpuset, or RT kthread may be born in a
> +	 * cgroup with no rt_runtime allocated.  Just say no.
>  	 */
> -	if (tsk == kthreadd_task || (tsk->flags & PF_NO_SETAFFINITY)) {
> +	if (tsk == kthreadd_task || (tsk->flags & PF_NO_SETAFFINITY) ||
> +	    ((tsk->flags & PF_KTHREAD) && !kthread_initialized(tsk))) {
>  		ret = -EINVAL;

...

> +bool kthread_initialized(struct task_struct *k)
> +{
> +	struct kthread *kthread = to_kthread(k);
> +
> +	return kthread && test_bit(KTHREAD_INITIALIZED, &kthread->flags);
> +}

Not sure I understand...

With this patch you can no longer migrate a kernel thread created by
kernel_thread() ? Note that to_kthread() is NULL unless it was created
by kthread_create().

Oleg.


  reply	other threads:[~2017-03-16 15:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170315231827.GA13656@htj.duckdns.org>
2017-03-15 23:19 ` [PATCH 2/2] kthread, cgroup: close race window where new kthreads can be migrated to non-root cgroups Tejun Heo
2017-03-16 15:02   ` Oleg Nesterov [this message]
     [not found]     ` <20170316150233.GB24478-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-03-16 15:39       ` Oleg Nesterov
     [not found]         ` <20170316153925.GA26391-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-03-16 16:07           ` Tejun Heo
     [not found]             ` <20170316160734.GD15810-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2017-03-16 16:31               ` Oleg Nesterov
2017-03-16 17:41                 ` Tejun Heo
2017-03-16 16:05     ` Tejun Heo
     [not found]       ` <20170316160544.GC15810-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2017-03-16 16:17         ` Oleg Nesterov
2017-03-16 17:03           ` Tejun Heo
     [not found]   ` <20170315231920.GB13656-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2017-03-16 20:54     ` [PATCH v2] cgroup, kthread: " Tejun Heo
2017-03-17 13:50       ` Oleg Nesterov
2017-03-17 14:44         ` 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=20170316150233.GB24478@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=clm@fb.com \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).