[tip: sched/urgent] sched/topology, cpuset: Account for housekeeping CPUs to avoid empty cpumasks

From: tip-bot2 for Valentin Schneider
Date: Fri Nov 15 2019 - 13:13:25 EST


The following commit has been merged into the sched/urgent branch of tip:

Commit-ID: 48a723d23b0d957e5b5861b974864e53c6841de8
Gitweb: https://git.kernel.org/tip/48a723d23b0d957e5b5861b974864e53c6841de8
Author: Valentin Schneider <valentin.schneider@xxxxxxx>
AuthorDate: Mon, 04 Nov 2019 00:39:06
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Fri, 15 Nov 2019 11:02:20 +01:00

sched/topology, cpuset: Account for housekeeping CPUs to avoid empty cpumasks

Michal noted that a cpuset's effective_cpus can be a non-empy mask, but
because of the masking done with housekeeping_cpumask(HK_FLAG_DOMAIN)
further down the line, we can still end up with an empty cpumask being
passed down to partition_sched_domains_locked().

Do the proper thing and don't just check the mask is non-empty - check
that its intersection with housekeeping_cpumask(HK_FLAG_DOMAIN) is
non-empty.

Reported-by: Michal Koutnà <mkoutny@xxxxxxxx>
Signed-off-by: Valentin Schneider <valentin.schneider@xxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Cc: Dietmar.Eggemann@xxxxxxx
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: hannes@xxxxxxxxxxx
Cc: lizefan@xxxxxxxxxx
Cc: morten.rasmussen@xxxxxxx
Cc: qperret@xxxxxxxxxx
Cc: tj@xxxxxxxxxx
Cc: vincent.guittot@xxxxxxxxxx
Fixes: cd1cb3350561 ("sched/topology: Don't try to build empty sched domains")
Link: https://lkml.kernel.org/r/20191104003906.31476-1-valentin.schneider@xxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
kernel/cgroup/cpuset.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index c87ee64..e4c1078 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -798,8 +798,14 @@ static int generate_sched_domains(cpumask_var_t **domains,
cpumask_subset(cp->cpus_allowed, top_cpuset.effective_cpus))
continue;

+ /*
+ * Skip cpusets that would lead to an empty sched domain.
+ * That could be because effective_cpus is empty, or because
+ * it's only spanning CPUs outside the housekeeping mask.
+ */
if (is_sched_load_balance(cp) &&
- !cpumask_empty(cp->effective_cpus))
+ cpumask_intersects(cp->effective_cpus,
+ housekeeping_cpumask(HK_FLAG_DOMAIN)))
csa[csn++] = cp;

/* skip @cp's subtree if not a partition root */