Skip to contentSkip to conversation

cpuset: Check if the cpus allowed is a subset of the cpuset's cpus for PF_THREAD_BOUND threads

PATCH Dhaval Giani 3 participants 4 messages Mar 12, 2009 – Mar 13, 2009

lore
Share & tools
lore
#0 lore raw

When a kernel thread which has been bound to a CPU is moved to a cpuset which is a superset of the CPU it is bound to, the movement fails.

[root@llm11 cgroups]# mkdir a
[root@llm11 cgroups]# echo 3 > a/cpuset.cpus
[root@llm11 cgroups]# echo 0 > a/cpuset.mems
[root@llm11 cgroups]# echo 12 > a/tasks
[root@llm11 cgroups]# echo 12 > tasks
-bash: echo: write error: Invalid argument
[root@llm11 cgroups]# cat cpuset.cpus
0-7
[root@llm11 cgroups]#

(pid 12 is the migration thread bound to CPU 3)

Change the check to see if the cpus allowed is a subset of the cpus allowed for that cpuset.

---
 kernel/cpuset.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cpuset.c +1 -1
@@ -1362,7 +1362,7 @@ static int cpuset_can_attach(struct cgro
 
 	if (tsk->flags & PF_THREAD_BOUND) {
 		mutex_lock(&callback_mutex);
-		if (!cpumask_equal(&tsk->cpus_allowed, cs->cpus_allowed))
+		if (!cpumask_subset(&tsk->cpus_allowed, cs->cpus_allowed))
 			ret = -EINVAL;
 		mutex_unlock(&callback_mutex);
 	}
Signature · 2 lines
regards,
Dhaval
#1 lore raw
Commit-ID:  5a98d36112f4301f068b638d6e0db2357f7deb75
Gitweb:     http://git.kernel.org/tip/5a98d36112f4301f068b638d6e0db2357f7deb75
Author:     Dhaval Giani <[email protected]>
AuthorDate: Thu, 12 Mar 2009 23:15:01 +0530
Commit:     Ingo Molnar <[email protected]>
CommitDate: Fri, 13 Mar 2009 00:21:25 +0100

cpuset: Check if the cpus allowed is a subset of the cpuset's cpus for PF_THREAD_BOUND threads

When a kernel thread which has been bound to a CPU is moved to a cpuset which is a superset of the CPU it is bound to, the movement fails.

[root@llm11 cgroups]# mkdir a
[root@llm11 cgroups]# echo 3 > a/cpuset.cpus
[root@llm11 cgroups]# echo 0 > a/cpuset.mems
[root@llm11 cgroups]# echo 12 > a/tasks
[root@llm11 cgroups]# echo 12 > tasks
-bash: echo: write error: Invalid argument
[root@llm11 cgroups]# cat cpuset.cpus
0-7
[root@llm11 cgroups]#

(pid 12 is the migration thread bound to CPU 3)

Change the check to see if the cpus allowed is a subset of the cpus allowed for that cpuset.

Cc Balbir Singh <[email protected]>
Cc Srivatsa Vaddagiri <[email protected]>
Cc Andrew Morton <[email protected]>

LKML-Reference: <[email protected]>

---
 kernel/cpuset.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cpuset.c +1 -1
index f76db9d..34cfd46 100644
@@ -1362,7 +1362,7 @@ static int cpuset_can_attach(struct cgroup_subsys *ss,
 
 	if (tsk->flags & PF_THREAD_BOUND) {
 		mutex_lock(&callback_mutex);
-		if (!cpumask_equal(&tsk->cpus_allowed, cs->cpus_allowed))
+		if (!cpumask_subset(&tsk->cpus_allowed, cs->cpus_allowed))
 			ret = -EINVAL;
 		mutex_unlock(&callback_mutex);
 	}
#2 lore raw
Quoted 9 lines · Dhaval Giani
Commit-ID:  5a98d36112f4301f068b638d6e0db2357f7deb75
Gitweb:     http://git.kernel.org/tip/5a98d36112f4301f068b638d6e0db2357f7deb75
Author:     Dhaval Giani <[email protected]>
AuthorDate: Thu, 12 Mar 2009 23:15:01 +0530
Commit:     Ingo Molnar <[email protected]>
CommitDate: Fri, 13 Mar 2009 00:21:25 +0100

cpuset: Check if the cpus allowed is a subset of the cpuset's cpus for PF_THREAD_BOUND threads

Dropped this patch for now - Andrew says it got NAK-ed and he's handling it with other fixes.

Ingo

#3 lore raw
CC David Rientjes <[email protected]>
Quoted 9 lines · Ingo Molnar
Quoted 7 lines · Dhaval Giani
Commit-ID:  5a98d36112f4301f068b638d6e0db2357f7deb75
Gitweb:     http://git.kernel.org/tip/5a98d36112f4301f068b638d6e0db2357f7deb75
Author:     Dhaval Giani <[email protected]>
AuthorDate: Thu, 12 Mar 2009 23:15:01 +0530
Commit:     Ingo Molnar <[email protected]>
CommitDate: Fri, 13 Mar 2009 00:21:25 +0100
Quoted 6 lines
Quoted 2 lines

cpuset: Check if the cpus allowed is a subset of the cpuset's cpus for PF_THREAD_BOUND threads

Dropped this patch for now - Andrew says it got NAK-ed and he's handling it with other fixes.

It's not a bug, it's David Rientjes that introduced this behavior:

	9985b0bab332289f14837eff3c6e0bcc658b58f7

And here was the discussion:

	http://lkml.org/lkml/2008/6/5/310