linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched/topology, cpuset: Account for housekeeping CPUs to avoid empty cpumasks
@ 2019-11-02  0:14 Valentin Schneider
  2019-11-03 19:09 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Valentin Schneider @ 2019-11-02  0:14 UTC (permalink / raw)
  To: linux-kernel, cgroups
  Cc: lizefan, tj, hannes, mingo, peterz, vincent.guittot,
	Dietmar.Eggemann, morten.rasmussen, qperret, Michal Koutný

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.

Fixes: cd1cb3350561 ("sched/topology: Don't try to build empty sched domains")
Reported-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
---
 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 c87ee6412b36..e4c10785dc7c 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -798,9 +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 */
--
2.22.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/topology, cpuset: Account for housekeeping CPUs to avoid empty cpumasks
  2019-11-02  0:14 [PATCH] sched/topology, cpuset: Account for housekeeping CPUs to avoid empty cpumasks Valentin Schneider
@ 2019-11-03 19:09 ` Ingo Molnar
  2019-11-04  0:37   ` Valentin Schneider
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2019-11-03 19:09 UTC (permalink / raw)
  To: Valentin Schneider
  Cc: linux-kernel, cgroups, lizefan, tj, hannes, peterz,
	vincent.guittot, Dietmar.Eggemann, morten.rasmussen, qperret,
	Michal Koutný


* Valentin Schneider <valentin.schneider@arm.com> wrote:

> 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.
> 
> Fixes: cd1cb3350561 ("sched/topology: Don't try to build empty sched domains")
> Reported-by: Michal Koutný <mkoutny@suse.com>
> Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
> ---
>  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 c87ee6412b36..e4c10785dc7c 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -798,9 +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;


This patch doesn't apply cleanly to Linus's latest tree - which tree is 
this against?

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched/topology, cpuset: Account for housekeeping CPUs to avoid empty cpumasks
  2019-11-03 19:09 ` Ingo Molnar
@ 2019-11-04  0:37   ` Valentin Schneider
  0 siblings, 0 replies; 3+ messages in thread
From: Valentin Schneider @ 2019-11-04  0:37 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, cgroups, lizefan, tj, hannes, peterz,
	vincent.guittot, Dietmar.Eggemann, morten.rasmussen, qperret,
	Michal Koutný

On 03/11/2019 19:09, Ingo Molnar wrote:
> This patch doesn't apply cleanly to Linus's latest tree - which tree is 
> this against?
> 

This was against Linus' tree at the time (31408fbe33d1), but my local .patch
doesn't apply either. I regenerated a fresh one and there's an off-by-one in
original chunk size - I suspect my editor trying to be smart when I edited
the changelog.

I'll look into preventing this from happening again, in the meantime I'll
send an apply-able version. Apologies for that mess.

> Thanks,
> 
> 	Ingo
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-04  0:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-02  0:14 [PATCH] sched/topology, cpuset: Account for housekeeping CPUs to avoid empty cpumasks Valentin Schneider
2019-11-03 19:09 ` Ingo Molnar
2019-11-04  0:37   ` Valentin Schneider

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