mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Valentin Schneider <vschneid@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Leon Romanovsky <leon@kernel.org>,
	linux-kernel@vger.kernel.org
Cc: Steve Wahl <steve.wahl@hpe.com>, Borislav Petkov <bp@alien8.de>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>
Subject: Re: [PATCH v3] sched/fair: Use sched_domain_span() for topology_span_sane()
Date: Wed, 9 Jul 2025 09:31:14 +0530	[thread overview]
Message-ID: <fb527d60-f31b-4383-ab03-e17f0ba96a0c@amd.com> (raw)
In-Reply-To: <xhsmhldoyq547.mognet@vschneid-thinkpadt14sgen2i.remote.csb>

Hello Valentin,

Thank you for taking a look!

On 7/8/2025 5:14 PM, Valentin Schneider wrote:
>> @@ -2418,22 +2419,34 @@ static bool topology_span_sane(const struct cpumask *cpu_map)
>>                * breaks the linking done for an earlier span.
>>                */
>>               for_each_cpu(cpu, cpu_map) {
>> -			const struct cpumask *tl_cpu_mask = tl->mask(cpu);
>> +			struct sched_domain *sd = *per_cpu_ptr(sdd->sd, cpu);
>> +			struct cpumask *sd_span = sched_domain_span(sd);
>>                       int id;
>>
>> +			/*
>> +			 * If a child level for a CPU has already covered
>> +			 * the entire cpumap, build_sched_domain() for the
>> +			 * domains above is skipped. Use sd->private to detect
>> +			 * levels that have not been initialized in the CPU's
>> +			 * hierarchy and skip them.
>> +			 */
>> +			if (!sd->private)
>> +				continue;
>> +
> 
> So this works, but how about using a cpumask_empty(sd_span) check instead?
> It's IMO a bit more future proof than relying on how sd->private is used.

How about the following instead of cpumask_empty() to avoid two cpumask
operation in the common case where sd is initialized:

diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index e682bf991ce6..e889ae012c17 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -2423,19 +2423,13 @@ static bool topology_span_sane(const struct cpumask *cpu_map)
 			struct cpumask *sd_span = sched_domain_span(sd);
 			int id;
 
-			/*
-			 * If a child level for a CPU has already covered
-			 * the entire cpumap, build_sched_domain() for the
-			 * domains above is skipped. Use sd->private to detect
-			 * levels that have not been initialized in the CPU's
-			 * hierarchy and skip them.
-			 */
-			if (!sd->private)
-				continue;
-
 			/* lowest bit set in this mask is used as a unique id */
 			id = cpumask_first(sd_span);
 
+			/* Skip if span is empty */
+			if (id >= nr_cpu_ids)
+				continue;
+
 			if (cpumask_test_cpu(id, id_seen)) {
 				/* First CPU has already been seen, ensure identical sd spans */
 				sd = *per_cpu_ptr(sdd->sd, id);
---

-- 
Thanks and Regards,
Prateek


  reply	other threads:[~2025-07-09  4:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-07 10:53 K Prateek Nayak
2025-07-08 11:44 ` Valentin Schneider
2025-07-09  4:01   ` K Prateek Nayak [this message]
2025-07-09 13:05     ` 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=fb527d60-f31b-4383-ab03-e17f0ba96a0c@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=bp@alien8.de \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --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

all inboxes | Powered by JetHome®