From 210463b39ccc3687fad59b4ee0b77d90fc045eee Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Tue, 10 Nov 2020 18:21:28 +0000 Subject: [PATCH] FROMLIST: cpuset: Don't use the cpu_possible_mask as a last resort for cgroup v1 If the scheduler cannot find an allowed CPU for a task, cpuset_cpus_allowed_fallback() will widen the affinity to cpu_possible_mask if cgroup v1 is in use. In preparation for allowing architectures to provide their own fallback mask, just return early if we're not using cgroup v2 and allow select_fallback_rq() to figure out the mask by itself. Cc: Li Zefan Cc: Tejun Heo Cc: Johannes Weiner Reviewed-by: Quentin Perret Signed-off-by: Will Deacon [will: Check task_cpu_possible_mask() in v2 mode as per on-list comments] Link: https://lore.kernel.org/r/20201217121552.ds7g2icvqp5nvtha@e107158-lin.cambridge.arm.com Bug: 178507149 Link: https://lore.kernel.org/linux-arch/20201208132835.6151-8-will@kernel.org/ Signed-off-by: Will Deacon Change-Id: I7a6b234c28495bae6feeecceafb841aae4de6046 --- kernel/cgroup/cpuset.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index c97065eda7fa..30998e7d54b1 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -3336,9 +3336,14 @@ void cpuset_cpus_allowed(struct task_struct *tsk, struct cpumask *pmask) void cpuset_cpus_allowed_fallback(struct task_struct *tsk) { + const struct cpumask *cs_mask = task_cs(tsk)->cpus_allowed; + const struct cpumask *possible_mask = task_cpu_possible_mask(tsk); + + if (!is_in_v2_mode() || !cpumask_subset(cs_mask, possible_mask)) + return; /* select_fallback_rq will try harder */ + rcu_read_lock(); - do_set_cpus_allowed(tsk, is_in_v2_mode() ? - task_cs(tsk)->cpus_allowed : cpu_possible_mask); + do_set_cpus_allowed(tsk, cs_mask); rcu_read_unlock(); /*