linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] cgroups: move cpuset specific checks from generic code to cpuset_can_attach
@ 2015-12-17 15:56 Marcelo Tosatti
  0 siblings, 0 replies; only message in thread
From: Marcelo Tosatti @ 2015-12-17 15:56 UTC (permalink / raw)
  To: linux-kernel, Tejun Heo, Luiz Capitulino; +Cc: Chao Peng, Vikas Shivappa


Move PF_NO_SETAFFINITY check to cpuset cgroups, where it belongs.
This makes it possible to attach PF_NO_SETAFFINITY to Intel CAT cgroups.

Reported-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

v2: "PF_NO_SETAFFINITY check" -> "PF_NO_SETAFFINITY and kthreadd_task
checks"
v3: keep kthreadd_task check for all cgroup controllers

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 470f653..66a1c32 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2740,11 +2740,10 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf,
 		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.
+	 * 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)) {
+	if (tsk == kthreadd_task) {
 		ret = -EINVAL;
 		goto out_unlock_rcu;
 	}
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 02a8ea5..67756bc 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>
@@ -1449,6 +1450,14 @@ static int cpuset_can_attach(struct cgroup_taskset *tset)
 		goto out_unlock;
 
 	cgroup_taskset_for_each(task, css, tset) {
+		/*
+		 * Workqueue threads may acquire PF_NO_SETAFFINITY and
+		 * become trapped in a cpuset.
+		 */
+		if (task->flags & PF_NO_SETAFFINITY) {
+			ret = -EINVAL;
+			goto out_unlock;
+		}
 		ret = task_can_attach(task, cs->cpus_allowed);
 		if (ret)
 			goto out_unlock;


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-12-17 15:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-17 15:56 [PATCH v3] cgroups: move cpuset specific checks from generic code to cpuset_can_attach Marcelo Tosatti

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).