From: Peter Zijlstra <peterz@infradead.org>
To: Valentin Schneider <valentin.schneider@arm.com>
Cc: linux-kernel@vger.kernel.org, sudeep.holla@arm.com,
prime.zeng@hisilicon.com, dietmar.eggemann@arm.com,
morten.rasmussen@arm.com, mingo@kernel.org
Subject: Re: [PATCH] sched/topology: Assert non-NUMA topology masks don't (partially) overlap
Date: Thu, 16 Jan 2020 11:44:28 +0100 [thread overview]
Message-ID: <20200116104428.GP2827@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20200115160915.22575-1-valentin.schneider@arm.com>
On Wed, Jan 15, 2020 at 04:09:15PM +0000, Valentin Schneider wrote:
> A "less intrusive" alternative is to assert the sd->groups list doesn't get
> re-written, which is a symptom of such bogus topologies. I've briefly
> tested this, you can have a look at it here:
>
> http://www.linux-arm.org/git?p=linux-vs.git;a=commit;h=e0ead72137332cbd3d69c9055ab29e6ffae5b37b
Something like that might still make sense. Can't never be too careful,
right ;-)
> kernel/sched/topology.c | 39 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 6ec1e595b1d4..dfb64c08a407 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -1879,6 +1879,42 @@ static struct sched_domain *build_sched_domain(struct sched_domain_topology_leve
> return sd;
> }
>
> +/*
> + * Ensure topology masks are sane, i.e. there are no conflicts (overlaps) for
> + * any two given CPUs at this (non-NUMA) topology level.
> + */
> +static bool topology_span_sane(struct sched_domain_topology_level *tl,
> + const struct cpumask *cpu_map, int cpu)
> +{
> + int i;
> +
> + /* NUMA levels are allowed to overlap */
> + if (tl->flags & SDTL_OVERLAP)
> + return true;
> +
> + /*
> + * Non-NUMA levels cannot partially overlap - they must be either
> + * completely equal or completely disjoint. Otherwise we can end up
> + * breaking the sched_group lists - i.e. a later get_group() pass
> + * breaks the linking done for an earlier span.
> + */
> + for_each_cpu(i, cpu_map) {
> + if (i == cpu)
> + continue;
> + /*
> + * We should 'and' all those masks with 'cpu_map' to exactly
> + * match the topology we're about to build, but that can only
> + * remove CPUs, which only lessens our ability to detect
> + * overlaps
> + */
> + if (!cpumask_equal(tl->mask(cpu), tl->mask(i)) &&
> + cpumask_intersects(tl->mask(cpu), tl->mask(i)))
> + return false;
> + }
> +
> + return true;
> +}
> +
> /*
> * Find the sched_domain_topology_level where all CPU capacities are visible
> * for all CPUs.
> @@ -1975,6 +2011,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
> has_asym = true;
> }
>
> + if (WARN_ON(!topology_span_sane(tl, cpu_map, i)))
> + goto error;
> +
> sd = build_sched_domain(tl, cpu_map, attr, sd, dflags, i);
>
> if (tl == sched_domain_topology)
This is O(nr_cpus), but then, that function already is, so I don't see a
problem with this.
I'll take it, thanks!
next prev parent reply other threads:[~2020-01-16 10:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 16:09 Valentin Schneider
2020-01-16 10:44 ` Peter Zijlstra [this message]
2020-01-16 10:48 ` Valentin Schneider
2020-01-16 15:19 ` Peter Zijlstra
2020-01-16 15:30 ` Valentin Schneider
2020-01-17 10:08 ` [tip: sched/core] " tip-bot2 for Valentin Schneider
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200116104428.GP2827@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=prime.zeng@hisilicon.com \
--cc=sudeep.holla@arm.com \
--cc=valentin.schneider@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®