[RFC PATCH 1/2] cpuset: Don't change the cpumask on attach if it is a subset.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a task it attached to a cgroup then its CPU-mask will be set to the
mask of the cgroup. Upon enabling the cpuset controller it will be set
to all online CPUs. All running user tasks, that changed their CPU-mask,
will have their mask altered without knowing it. Tasks with unchanged
CPU-mask are set to all online CPUs and this change is a nop.

If the task is already using a subset of the allowed (new) CPUs, skip
changing the mask. This will preserve the CPU-mask as long as it
contains only allowed CPUs from the new CPU-mask.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
 kernel/cgroup/cpuset.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index b474289c15b82..8d5126684f9e6 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2527,7 +2527,8 @@ static void cpuset_attach(struct cgroup_taskset *tset)
 		 * can_attach beforehand should guarantee that this doesn't
 		 * fail.  TODO: have a better way to handle failure here
 		 */
-		WARN_ON_ONCE(set_cpus_allowed_ptr(task, cpus_attach));
+		if (!cpumask_subset(&task->cpus_mask, cpus_attach))
+			WARN_ON_ONCE(set_cpus_allowed_ptr(task, cpus_attach));
 
 		cpuset_change_task_nodemask(task, &cpuset_attach_nodemask_to);
 		cpuset_update_task_spread_flag(cs, task);
-- 
2.37.2




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux