From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Shrikanth Hegde <sshegde@linux.ibm.com>, <mingo@kernel.org>,
<peterz@infradead.org>, <vincent.guittot@linaro.org>,
<linux-kernel@vger.kernel.org>
Cc: <juri.lelli@redhat.com>, <vschneid@redhat.com>,
<dietmar.eggemann@arm.com>, <tj@kernel.org>,
<rostedt@goodmis.org>, <mgorman@suse.de>, <bsegall@google.com>,
<arighi@nvidia.com>
Subject: Re: [PATCH v2 3/3] sched/fair: Add compile time check in fastpaths for CONFIG_SCHED_SMT=n
Date: Wed, 13 May 2026 12:27:37 +0530 [thread overview]
Message-ID: <35f10be6-1e2f-4a6f-ae9f-a09754221011@amd.com> (raw)
In-Reply-To: <0b3d8b79-6743-4f35-abc8-da4f2a6a2d80@linux.ibm.com>
Hello Shrikanth,
On 5/13/2026 12:09 PM, Shrikanth Hegde wrote:
>
> Hi Prateek.
>
>> ... I think the if() above can simply check for sched_smt_active()
>> before calling is_core_idle() like:
>>
>> if (sched_smt_active() &&
>> !(env->sd->flags & SD_SHARE_CPUCAPACITY) &&
>> !is_core_idle(cpu)) {
>> ...
>> }
>>
>> That way, we ensure we don't call is_core_idle() and the cpumask_and()
>> unnecessarily on topologies that don't have SMT domain similar to how
>> sched_use_asym_prio() guards the call to is_core_idle().
>>
>> Thoughts?
>>
> In addition, Do you think it makes sense to consolidate use of
> sched_smt_present always using sched_smt_active() ?
>
>
> static __always_inline bool sched_smt_active(void)
> {
> return static_branch_likely(&sched_smt_present);
> }
>
> kernel/sched/core_sched.c: if (!static_branch_likely(&sched_smt_present))
> kernel/sched/fair.c: if (!static_branch_likely(&sched_smt_present) ||
> kernel/sched/sched.h: if (static_branch_unlikely(&sched_smt_present))
>
>
> The last being differing with unlikely in update_idle_core.
> Does it make sense to call sched_smt_active there as well?
I think using sched_smt_active() everywhere should be fine.
I'm not sure what made update_idle_core() special; Perhaps there was
a greater chance of running it on systems with CONFIG_SCHED_SMT
enabled but doesn't physically have SMT.
This came from commit 1b568f0aabf2 ("sched/core: Optimize SCHED_SMT")
in 2016 when SMT was perhaps not so common and sched_smt_active()
came later in 2018 with the spectre mitigation optimizations on x86
where SMT was more prevalent so it defaulted to likely.
I'll let Peter comment if he prefers keeping this branch unlikely
but from my side, unifying eveything under sched_smt_active() looks
better.
--
Thanks and Regards,
Prateek
next prev parent reply other threads:[~2026-05-13 6:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 15:21 [PATCH v2 0/3] sched: Simplify ifdeffery around CONFIG_SCHED_SMT Shrikanth Hegde
2026-05-12 15:21 ` [PATCH v2 1/3] topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n Shrikanth Hegde
2026-05-12 16:56 ` Phil Auld
2026-05-12 15:21 ` [PATCH v2 2/3] sched: Simplify ifdeffery around cpu_smt_mask Shrikanth Hegde
2026-05-12 16:57 ` Phil Auld
2026-05-12 15:21 ` [PATCH v2 3/3] sched/fair: Add compile time check in fastpaths for CONFIG_SCHED_SMT=n Shrikanth Hegde
2026-05-12 16:59 ` Phil Auld
2026-05-13 4:15 ` Shrikanth Hegde
2026-05-13 11:53 ` Phil Auld
2026-05-13 6:07 ` K Prateek Nayak
2026-05-13 6:16 ` Shrikanth Hegde
2026-05-13 6:39 ` Shrikanth Hegde
2026-05-13 6:57 ` K Prateek Nayak [this message]
2026-05-12 17:48 ` [PATCH v2 0/3] sched: Simplify ifdeffery around CONFIG_SCHED_SMT Valentin Schneider
2026-05-13 6:20 ` K Prateek Nayak
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=35f10be6-1e2f-4a6f-ae9f-a09754221011@amd.com \
--to=kprateek.nayak@amd.com \
--cc=arighi@nvidia.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@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sshegde@linux.ibm.com \
--cc=tj@kernel.org \
--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