From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Steve Wahl <steve.wahl@hpe.com>,
Valentin Schneider <vschneid@redhat.com>
Cc: Russ Anderson <rja@hpe.com>, Dimitri Sivanich <sivanich@hpe.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/topology: improve topology_span_sane speed
Date: Wed, 23 Oct 2024 20:46:53 +0530 [thread overview]
Message-ID: <32e0b995-eb81-42bf-904b-225a3b7c0e87@linux.ibm.com> (raw)
In-Reply-To: <20241010155111.230674-1-steve.wahl@hpe.com>
On 10/10/24 21:21, Steve Wahl wrote:
> Use a different approach to topology_span_sane(), that checks for the
> same constraint of no partial overlaps for any two CPU sets for
> non-NUMA topology levels, but does so in a way that is O(N) rather
> than O(N^2).
>
> Instead of comparing with all other masks to detect collisions, keep
> one mask that includes all CPUs seen so far and detect collisions with
> a single cpumask_intersects test.
>
> If the current mask has no collisions with previously seen masks, it
> should be a new mask, which can be uniquely identified by the lowest
> bit set in this mask. Keep a pointer to this mask for future
> reference (in an array indexed by the lowest bit set), and add the
> CPUs in this mask to the list of those seen.
>
> If the current mask does collide with previously seen masks, it should
> be exactly equal to a mask seen before, looked up in the same array
> indexed by the lowest bit set in the mask, a single comparison.
>
> Move the topology_span_sane() check out of the existing topology level
> loop, let it use its own loop so that the array allocation can be done
> only once, shared across levels.
>
> On a system with 1920 processors (16 sockets, 60 cores, 2 threads),
> the average time to take one processor offline is reduced from 2.18
> seconds to 1.01 seconds. (Off-lining 959 of 1920 processors took
> 34m49.765s without this change, 16m10.038s with this change in place.)
>
> Signed-off-by: Steve Wahl <steve.wahl@hpe.com>
I was trying to go through this issue and observed below.
Looks like the computations are repeated in below manner.
Assume SMT4 system.
[[0 2 4 6] [1 3 5 7] ] [ [8 10 12 14] [9 11 13 15] ]
<--SMT--> <--SMT--> <---SMT----> <----SMT--->
<---------PKG----------> <------------PKG------------->
Lets say it happening for CPU0, at SMT level, then it will do, masking
in below manner.
2: [0 2 4 6] & [0 2 4 6]
4: [0 2 4 6] & [0 2 4 6]
6: [0 2 4 6] & [0 2 4 6]
1: [0 2 4 6] & [1 3 5 7]
3: [0 2 4 6] & [1 3 5 7]
5: [0 2 4 6] & [1 3 5 7]
7: [0 2 4 6] & [1 3 5 7]
8: [0 2 4 6] & [8 10 12 14]
10:[0 2 4 6] & [8 10 12 14]
12:[0 2 4 6] & [8 10 12 14]
14:[0 2 4 6] & [8 10 12 14]
9: [0 2 4 6] & [9 11 13 15]
11:[0 2 4 6] & [9 11 13 15]
13:[0 2 4 6] & [9 11 13 15]
15:[0 2 4 6] & [9 11 13 15]
And when it happens for CPU2, it will do the exact same computation.
Maybe that can be avoided with something like below. Do the computation
if it is the first cpu in that topology level mask.
Not sure if it works in all scenarios. Tested very very lightly on
power10 system with SMT=4.
Please correct me if i got it all wrong.
------------------------------------------------------------------------
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 9748a4c8d668..541631ca32bd 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2367,6 +2367,13 @@ static bool topology_span_sane(struct
sched_domain_topology_level *tl,
if (tl->flags & SDTL_OVERLAP)
return true;
+ /* Do the computation only if this cpu is first CPU
+ * in the topology level mask. Same computation is kind of
+ * Repetitions on other CPUS */
+ if (!(cpu == cpumask_first(tl->mask(cpu)))) {
+ return true;
+ }
+
/*
* Non-NUMA levels cannot partially overlap - they must be either
* completely equal or completely disjoint. Otherwise we can end up
next prev parent reply other threads:[~2024-10-23 15:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 15:51 [PATCH] sched/topology: improve topology_span_sane speed Steve Wahl
2024-10-15 10:20 ` K Prateek Nayak
2024-10-15 11:05 ` Peter Zijlstra
2024-10-15 22:32 ` Steve Wahl
2024-10-15 22:19 ` Steve Wahl
2024-10-15 14:37 ` Valentin Schneider
2024-10-16 8:10 ` Valentin Schneider
2024-10-16 16:08 ` Steve Wahl
2024-10-25 15:06 ` Steve Wahl
2024-10-25 17:21 ` Valentin Schneider
2024-10-18 11:35 ` Vishal Chourasia
2024-10-21 16:20 ` Steve Wahl
2024-10-23 13:19 ` Vishal Chourasia
2024-10-23 15:16 ` Shrikanth Hegde [this message]
2024-10-29 17:34 ` samir
2024-11-01 20:05 ` Steve Wahl
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=32e0b995-eb81-42bf-904b-225a3b7c0e87@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rja@hpe.com \
--cc=rostedt@goodmis.org \
--cc=sivanich@hpe.com \
--cc=steve.wahl@hpe.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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