Skip to content

sched: Simplify CONFIG_SCHED_SMT ifdef usage

Shrikanth Hegde lkml 4 versions – Applied

Status from this message: The following commit has been merged into the sched/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest4 patches 1 replyApplied
  2. v34 patches 3 repliesSuperseded
  3. v23 patches 11 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v13 patches8 repliesSuperseded

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/4topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=ninclude/linux/topology.h+14 -10 replies
2/4sched: Simplify ifdeffery around cpu_smt_maskinclude/linux/sched/smt.h kernel/sched/core.c kernel/sched/ext_idle.c +5 more+5 -630 replies
3/4sched/fair: Add sched_smt_active check for fastpathskernel/sched/fair.c+4 -51 reply
4/4sched: Unify SMT active check via sched_smt_active()kernel/sched/core_sched.c kernel/sched/fair.c kernel/sched/sched.h+3 -30 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchK Prateek NayakPhil AuldValentin SchneiderTejun Heo
1/4T-b R-b R-b
2/4T-b R-b R-b A-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v4 thread

Cover letter [PATCH v4 0/4] sched: Simplify CONFIG_SCHED_SMT ifdef usage

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/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
[3]: https://lore.kernel.org/all/[email protected]/

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(-)
Signature · 1 line
2.47.3