The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Valentin Schneider <vschneid@redhat.com>
Cc: kprateek.nayak@amd.com, juri.lelli@redhat.com,
	dietmar.eggemann@arm.com, tj@kernel.org, rostedt@goodmis.org,
	tglx@kernel.org, mgorman@suse.de, bsegall@google.com,
	arighi@nvidia.com, linux-kernel@vger.kernel.org,
	mingo@kernel.org, peterz@infradead.org,
	vincent.guittot@linaro.org
Subject: Re: [PATCH 2/3] sched: Simplify ifdeffery around cpu_smt_mask
Date: Tue, 12 May 2026 15:43:21 +0530	[thread overview]
Message-ID: <a224b92e-c95c-4177-a756-5cc7d194a492@linux.ibm.com> (raw)
In-Reply-To: <09edb32d-774a-4780-bb05-cb227f6cddb7@linux.ibm.com>



On 5/11/26 8:07 PM, Shrikanth Hegde wrote:
> Hi Valentin, Thanks for the reviewing this patchset.
> 
> On 5/11/26 6:23 PM, Valentin Schneider wrote:
>> On 06/05/26 16:30, Shrikanth Hegde wrote:
>>> Now, that cpu_smt_mask is defined as cpumask_of(cpu) for
>>> CONFIG_SCHED_SMT=n, it is possible to get rid of the ifdeffery.
>>>
>>> Effectively,
>>> - This makes sched_smt_present is defined always
>>>
>>> - cpumask_weight(cpumask_of(cpu)) == 1. So sched_smt_present_inc/dec
>>>    will never enable the sched_smt_present. Which is expected.
>>>
>>> - Paths that were compile-time eliminated become runtime guarded
>>>    using static keys.
>>>
>>> - Defines set_idle_cores, test_idle_cores etc which could likely benefit
>>>    the CONFIG_SCHED_SMT=n systems to use the same optimizations 
>>> within the
>>>    LLC at wakeups.
>>>
>>> - This will expose sched_smt_present,stop_core_cpuslocked symbol for
>>>    CONFIG_SCHED_SMT=n. Likely not a concern.
>>>
>>> - There a bloat of code CONFIG_SCHED_SMT=n. (NR_CPUS=2048)
>>>    add/remove: 25/18 grow/shrink: 26/19 up/down: 6696/-3064 (3632)
>>>    Total: Before=30771823, After=30775455, chg +0.01%
>>>
>>> - No code bloat for CONFIG_SCHED_SMT=y, which is expected.
>>>
>>
>> Some nitpicks below, otherwise this LGTM except the sched_ext bits which
>> I'm not familiar enough with.
> 
> sched_ext just added the ifdefs for the masks i think.
> It has sched_smt_active() already.
> 
>>
>>> @@ -8703,9 +8699,7 @@ int sched_cpu_deactivate(unsigned int cpu)
>>>         */
>>>        sched_smt_present_dec(cpu);
>>>
>>> -#ifdef CONFIG_SCHED_SMT
>>>        sched_core_cpu_deactivate(cpu);
>>> -#endif
>>
>> That ends up grabbing @core_lock, arguably this is during hotplug but 
>> still
>> seems a bit wasteful when, with CONFIG_SCHED_SMT=1, we know the mask 
>> weight
>> will never exceed 1. Probably worth adding a sched_smt_active() check
>> within the callee.
>>
> 
> Ok. Fair enough. Even cpu bringup path too could use the same opt.
> Something like below?
> ---
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 084ec3987d7c..add0fcc8ba90 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6494,6 +6494,10 @@ static void sched_core_cpu_starting(unsigned int 
> cpu)
>          struct rq *rq = cpu_rq(cpu), *core_rq = NULL;
>          int t;
> 
> +       /* No point in doing anything further if SMT is not active */
> +       if (!sched_smt_active())
> +               return;
> +
>          guard(core_lock)(&cpu);
> 
>          WARN_ON_ONCE(rq->core != rq);
> @@ -6533,6 +6537,10 @@ static void sched_core_cpu_deactivate(unsigned 
> int cpu)
>          struct rq *rq = cpu_rq(cpu), *core_rq = NULL;
>          int t;
> 
> +       /* No point in doing anything further if SMT is not active */
> +       if (!sched_smt_active())
> +               return;
> +
>          guard(core_lock)(&cpu);
> 
>          /* if we're the last man standing, nothing to do */
> 
> 

This isn't necessary. Both sched_core_cpu_starting/sched_core_cpu_deactivate bail out
quickly when cpumask_weight(cpu_smt_mask) == 1.

Given that it is not fastpath, I will skip the above diff.


  parent reply	other threads:[~2026-05-12 10:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 11:00 [PATCH 0/3] sched: Simplify ifdeffery around CONFIG_SCHED_SMT Shrikanth Hegde
2026-05-06 11:00 ` [PATCH 1/3] topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n Shrikanth Hegde
2026-05-06 11:00 ` [PATCH 2/3] sched: Simplify ifdeffery around cpu_smt_mask Shrikanth Hegde
2026-05-11 12:53   ` Valentin Schneider
2026-05-11 14:37     ` Shrikanth Hegde
2026-05-11 18:46       ` Tejun Heo
2026-05-12 10:13       ` Shrikanth Hegde [this message]
2026-05-12 10:58       ` Valentin Schneider
2026-05-06 11:00 ` [PATCH 3/3] sched/fair: Add compile time check in fastpaths for CONFIG_SCHED_SMT=n Shrikanth Hegde
2026-05-12 10:59 ` [PATCH 0/3] sched: Simplify ifdeffery around CONFIG_SCHED_SMT Valentin Schneider
2026-05-12 12:25   ` Shrikanth Hegde
2026-05-12 15:32     ` 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=a224b92e-c95c-4177-a756-5cc7d194a492@linux.ibm.com \
    --to=sshegde@linux.ibm.com \
    --cc=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    --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