From: Vishal Chourasia <vishalc@linux.ibm.com>
To: Steve Wahl <steve.wahl@hpe.com>
Cc: 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>,
Valentin Schneider <vschneid@redhat.com>,
linux-kernel@vger.kernel.org, Russ Anderson <rja@hpe.com>,
Dimitri Sivanich <sivanich@hpe.com>
Subject: Re: [PATCH] sched/topology: improve topology_span_sane speed
Date: Wed, 23 Oct 2024 18:49:15 +0530 [thread overview]
Message-ID: <Zxj30yQDRmLd2EGO@linux.ibm.com> (raw)
In-Reply-To: <ZxZ_arDwEu489GkN@swahl-home.5wahls.com>
On Mon, Oct 21, 2024 at 11:20:58AM -0500, Steve Wahl wrote:
> On Fri, Oct 18, 2024 at 05:05:43PM +0530, Vishal Chourasia wrote:
> > On Thu, Oct 10, 2024 at 10:51:11AM -0500, Steve Wahl wrote:
> > @@ -2417,9 +2446,6 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
> > > sd = NULL;
> > > for_each_sd_topology(tl) {
> > >
> > > - if (WARN_ON(!topology_span_sane(tl, cpu_map, i)))
> > > - goto error;
> > > -
> > > sd = build_sched_domain(tl, cpu_map, attr, sd, i);
> > >
> > > has_asym |= sd->flags & SD_ASYM_CPUCAPACITY;
> > > @@ -2433,6 +2459,9 @@ build_sched_domains(const struct cpumask *cpu_map, struct sched_domain_attr *att
> > > }
> > > }
> > >
> > > + if (WARN_ON(!topology_span_sane(cpu_map)))
> > > + goto error;
> > Hi Steve,
>
> Vishal, thank you for taking the time to review.
>
> > Is there any reason why above check is done after initializing
> > sched domain struct for all the CPUs in the cpu_map?
>
> The original check was done in the same for_each_sd_topology(tl) loop
> that calls build_sched_domain(). I had trouble 100% convincing myself
> that calls to build_sched_domain() on the previous levels couldn't
> affect calls to tl->mask() in later levels, so I placed the new check
> after all calls to build_sched_domain were complete.
>
Yeah, I don't see build_sched_domain() modifying the cpumask
returned from tl->mask(cpu)
> > It looks to me, that this check can be performed before the call to
> > __visit_domain_allocation_hell() in the build_sched_domains()
> > resulting in early return if topology_span_sane() detects incorrect
> > topology.
>
> This might be OK to do. I would greatly appreciate somebody well
> versed in this code area telling me for certain that it would work.
>
Same.
> > Also, the error path in the current code only cleans up d->rd struct, keeping
> > all the work done by build_sched_domain() inside the loop and __alloc_sdt()
> > called from __visit_domain_allocation_hell()
> >
> > is it because we need all that work to remain intact?
>
> I'm not seeing this. The return from __visit_domain_allocation_hell()
> is stored in alloc_state immediately checked to be == sa_rootdomain;
> if not, the error path is taken, deallocating everything and
> returning.
>
> The rest of the function does not touch alloc_state, so any error from
> that point on makes the call to __free_domain_allocs with what ==
> sa_rootdomain, which seems to undo everything.
>
> Are you possibly missing the fallthroughs in __free_domain_allocs()
> even though they're clearly emphasized?
>
Yes, you are right. Thank you for pointing that out.
> > static void __free_domain_allocs(struct s_data *d, enum s_alloc what,
> > const struct cpumask *cpu_map)
> > {
> > switch (what) {
> > case sa_rootdomain:
> > if (!atomic_read(&d->rd->refcount))
> > free_rootdomain(&d->rd->rcu);
> > fallthrough;
> > case sa_sd:
> > free_percpu(d->sd);
> > fallthrough;
> > case sa_sd_storage:
> > __sdt_free(cpu_map);
> > fallthrough;
> > case sa_none:
> > break;
> > }
> > }
> >
>
> Thanks,
>
> --> Steve Wahl
>
> --
> Steve Wahl, Hewlett Packard Enterprise
next prev parent reply other threads:[~2024-10-23 13:19 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 [this message]
2024-10-23 15:16 ` Shrikanth Hegde
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=Zxj30yQDRmLd2EGO@linux.ibm.com \
--to=vishalc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.