All of lore.kernel.org
 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,
	mgorman@suse.de, bsegall@google.com, arighi@nvidia.com,
	pauld@redhat.com
Subject: [PATCH v4 0/4] sched: Simplify CONFIG_SCHED_SMT ifdef usage
Date: Fri, 15 May 2026 22:54:52 +0530	[thread overview]
Message-ID: <20260515172456.542799-1-sshegde@linux.ibm.com> (raw)

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).

With that, cpu_smt_mask() can be used unconditionally and reduces
CONFIG_SCHED_SMT ifdef usage, improving readability and maintainability.
This leaves the remaining use of CONFIG_SCHED_SMT mainly for topology
handling bits.

Also, remove the explicit use of sched_smt_present. Make use of
sched_smt_active. It differs slightly for update_idle_core, which
used with unlikely flag earlier. Now it will be likely. Should be ok,
since most systems have SMT active today.

Since v3[3]:
- Minor re-order of sched_smt_active to bail out early for !smt
  (Valentin Schneider)
- Collected tags. Thanks again.

Since v2[2]:
- Changed patch 3 significantly to use sched_smt_active check for
  fastpath. (K Prateek Nayak)
- Collected the tags.
  Thanks to Phil Auld, Valentin Schneider, Tejun Heo, K Prateek Nayak.
- Since patch 3 has changed by quite a bit, i have not applied the tags.
  Please review it again. Sorry for the inconvenience.
- Added patch 4 to unify checking on SMT active using
  sched_smt_active().

Since v1[1]:
- Dropped changes for stop_core_cpuslocked. intel_ifs is the only
  user and it gets compiled with SCHED_SMT always. Added comments
  around it why ifdefs are still being kept.
- Decided not to add sched_smt_active checks for sched_core_cpu_deactivate
  and sched_core_cpu_starting, they bail out if weight(smt_mask) == 1.
  Hence core_lock won't be held for long. It is not fastpath either.
- Thanks to Valentin Schneider and Tejun Heo for checking out the series
  and the feedback.

[1]: https://lore.kernel.org/all/20260506110052.9974-1-sshegde@linux.ibm.com/
[2]: https://lore.kernel.org/all/20260512152125.308280-1-sshegde@linux.ibm.com/
[3]: https://lore.kernel.org/all/20260513133934.380347-1-sshegde@linux.ibm.com/

Shrikanth Hegde (4):
  topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n
  sched: Simplify ifdeffery around cpu_smt_mask
  sched/fair: Add sched_smt_active check for fastpaths
  sched: Unify SMT active check via sched_smt_active()

 include/linux/sched/smt.h |  4 ----
 include/linux/topology.h  | 15 ++++++++++++-
 kernel/sched/core.c       |  6 -----
 kernel/sched/core_sched.c |  2 +-
 kernel/sched/ext_idle.c   |  6 -----
 kernel/sched/fair.c       | 46 +++++----------------------------------
 kernel/sched/sched.h      |  8 +------
 kernel/sched/topology.c   |  2 --
 kernel/stop_machine.c     |  5 +++++
 kernel/workqueue.c        |  4 ----
 10 files changed, 26 insertions(+), 72 deletions(-)

-- 
2.47.3


             reply	other threads:[~2026-05-15 17:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 17:24 Shrikanth Hegde [this message]
2026-05-15 17:24 ` [PATCH v4 1/4] topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n Shrikanth Hegde
2026-05-15 17:24 ` [PATCH v4 2/4] sched: Simplify ifdeffery around cpu_smt_mask Shrikanth Hegde
2026-05-15 17:24 ` [PATCH v4 3/4] sched/fair: Add sched_smt_active check for fastpaths Shrikanth Hegde
2026-05-15 17:24 ` [PATCH v4 4/4] sched: Unify SMT active check via sched_smt_active() 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=20260515172456.542799-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=pauld@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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 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.