The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: mingo@kernel.org, peterz@infradead.org,
	vincent.guittot@linaro.org, linux-kernel@vger.kernel.org
Cc: sshegde@linux.ibm.com, kprateek.nayak@amd.com,
	juri.lelli@redhat.com, vschneid@redhat.com,
	dietmar.eggemann@arm.com, tj@kernel.org, rostedt@goodmis.org,
	tglx@kernel.org, mgorman@suse.de, bsegall@google.com,
	arighi@nvidia.com
Subject: [PATCH 0/3] sched: Simplify ifdeffery around CONFIG_SCHED_SMT
Date: Wed,  6 May 2026 16:30:49 +0530	[thread overview]
Message-ID: <20260506110052.9974-1-sshegde@linux.ibm.com> (raw)

While working on paravirt series on maintaining preferred CPUs, I wanted
to add/remove a core. To do that, I had to access cpu_smt_mask. For that
had to use CONFIG_SCHED_SMT around the code. That made me think, for
CONFIG_SCHED_SMT=n, it effectively means to just add/remove a CPU. Thats when
I thought of this idea of using cpumask_of(cpu) when CONFIG_SCHED_SMT=n. 

Semantics
=========
- For CONFIG_SCHED_SMT=y:
    No functional change.
- For CONFIG_SCHED_SMT=n:
    - cpu_smt_mask(cpu) becomes cpumask_of(cpu), effectively making it
      per CPU with no siblings.
    - sched_smt_present remains defined, but never becomes active:
    	 Since cpumask_weight(cpumask_of(cpu)) == 1

Performance impact
==================
- CONFIG_SCHED_SMT=y:
    No change in generated code.
- CONFIG_SCHED_SMT=n:
    - Small increase in text size (~0.01%) due to removal of compile-time
      stubs. Most paths remain effectively dead due to static keys.
    - Fast paths are protected using IS_ENABLED(CONFIG_SCHED_SMT).

Testing
=======
- Did build/boot test on powerpc for CONFIG_SCHED_SMT=y/n.
- Ran hackbench on powerpc for CONFIG_SCHED_SMT=y/n. Didn't observe any
  major difference.
- Did build/boot test on x86 for CONFIG_SCHED_SMT=y/n. For x86 i had
  change the code for CONFIG_SCHED_SMT=n


Plus, Major distros make CONFIG_SCHED_SMT=y for all major
archs and few archs unconditionally make CONFIG_SCHED_SMT=y (x86,
s390), So CONFIG_SCHED_SMT=n is a rare case.

With that, cpu_smt_mask() to be used unconditionally and reduces
CONFIG_SCHED_SMT-specific code paths, improving readability and
maintainability.

Please review and consider if this simplification is a worthwhile cleanup.

Shrikanth Hegde (3):
  topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n
  sched: Simplify ifdeffery around cpu_smt_mask
  sched/fair: Add compile time check in fastpaths for CONFIG_SCHED_SMT=n

 include/linux/sched/smt.h |  4 ----
 include/linux/topology.h  | 15 +++++++++++++-
 kernel/sched/core.c       |  6 ------
 kernel/sched/ext_idle.c   |  6 ------
 kernel/sched/fair.c       | 41 +++++----------------------------------
 kernel/sched/sched.h      |  6 ------
 kernel/sched/topology.c   |  2 --
 kernel/stop_machine.c     |  2 --
 kernel/workqueue.c        |  4 ----
 9 files changed, 19 insertions(+), 67 deletions(-)

-- 
2.51.0


             reply	other threads:[~2026-05-06 11:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 11:00 Shrikanth Hegde [this message]
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-06 11:00 ` [PATCH 3/3] sched/fair: Add compile time check in fastpaths for CONFIG_SCHED_SMT=n Shrikanth Hegde

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=20260506110052.9974-1-sshegde@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