public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Mike Galbraith <umgwanakikbuti@gmail.com>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Chao Peng <chao.p.peng@linux.intel.com>,
	Vikas Shivappa <vikas.shivappa@intel.com>
Subject: [PATCH] cgroups: move cpuset specific checks from generic code to cpuset_can_attach (v2)
Date: Thu, 26 Nov 2015 20:32:32 -0200	[thread overview]
Message-ID: <20151126223230.GA16962@amt.cnet> (raw)
In-Reply-To: <1448539767.7954.214.camel@gmail.com>


Move PF_NO_SETAFFINITY and kthreadd_task checks to cpuset cgroups,  
where they belong. This makes it possible to attach PF_NO_SETAFFINITY 
tasks to Intel CAT cgroup.

Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reviewed-by: Chao Peng <chao.p.peng@linux.intel.com>

v2: "PF_NO_SETAFFINITY check" -> "PF_NO_SETAFFINITY and kthreadd_task
checks"

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index f89d929..0603652 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2466,16 +2466,6 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf,
 	if (threadgroup)
 		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.
-	 */
-	if (tsk == kthreadd_task || (tsk->flags & PF_NO_SETAFFINITY)) {
-		ret = -EINVAL;
-		goto out_unlock_rcu;
-	}
-
 	get_task_struct(tsk);
 	rcu_read_unlock();
 
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index f0acff0..9fff4d6 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -53,6 +53,7 @@
 #include <linux/time.h>
 #include <linux/backing-dev.h>
 #include <linux/sort.h>
+#include <linux/kthread.h>
 
 #include <asm/uaccess.h>
 #include <linux/atomic.h>
@@ -1445,6 +1446,17 @@ static int cpuset_can_attach(struct cgroup_subsys_state *css,
 		goto out_unlock;
 
 	cgroup_taskset_for_each(task, tset) {
+		/*
+		 * 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.
+		 */
+		if (task == kthreadd_task ||
+		    (task->flags & PF_NO_SETAFFINITY)) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
+
 		ret = task_can_attach(task, cs->cpus_allowed);
 		if (ret)
 			goto out_unlock;


  reply	other threads:[~2015-11-26 22:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 22:01 [PATCH] cgroups: move cpuset specific checks from generic code to cpuset_can_attach Marcelo Tosatti
2015-11-26  8:00 ` Chao Peng
2015-11-26 12:09 ` Mike Galbraith
2015-11-26 22:32   ` Marcelo Tosatti [this message]
2015-11-26 23:42     ` [PATCH] cgroups: move cpuset specific checks from generic code to cpuset_can_attach (v2) Mike Galbraith
2015-12-01 16:49     ` Tejun Heo
2015-12-02  6:21       ` Mike Galbraith

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=20151126223230.GA16962@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=lcapitulino@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=umgwanakikbuti@gmail.com \
    --cc=vikas.shivappa@intel.com \
    /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