Skip to content

[Deepin-Kernel-SIG] [linux 6.18.y] [Upstream] sched_ext: idle: Prioritize idle SMT sibling#1743

Open
Avenger-285714 wants to merge 2 commits into
deepin-community:linux-6.18.yfrom
Avenger-285714:Prioritize-SMT
Open

[Deepin-Kernel-SIG] [linux 6.18.y] [Upstream] sched_ext: idle: Prioritize idle SMT sibling#1743
Avenger-285714 wants to merge 2 commits into
deepin-community:linux-6.18.yfrom
Avenger-285714:Prioritize-SMT

Conversation

@Avenger-285714
Copy link
Copy Markdown
Member

@Avenger-285714 Avenger-285714 commented May 18, 2026

[Upstream commit 2197cecdb02c57b08340059452540fcf101fa30d]

In the default built-in idle CPU selection policy, when @prev_cpu is busy and no fully idle core is available, try to place the task on its SMT sibling if that sibling is idle, before searching any other idle CPU in the same LLC.

Migration to the sibling is cheap and keeps the task on the same core, preserving L1 cache and reducing wakeup latency.

On large SMT systems this appears to consistently boost throughput by roughly 2-3% on CPU-bound workloads (running a number of tasks equal to the number of SMT cores).

Cc: Cheng-Yang Chou yphbchou0911@gmail.com

Summary by Sourcery

Enhancements:

  • Update the default idle CPU selection policy to first select an idle SMT sibling of the previous CPU when the previous CPU is busy and no fully idle core is available.

[Upstream commit 2197cecdb02c57b08340059452540fcf101fa30d]

In the default built-in idle CPU selection policy, when @prev_cpu is
busy and no fully idle core is available, try to place the task on its
SMT sibling if that sibling is idle, before searching any other idle CPU
in the same LLC.

Migration to the sibling is cheap and keeps the task on the same core,
preserving L1 cache and reducing wakeup latency.

On large SMT systems this appears to consistently boost throughput by
roughly 2-3% on CPU-bound workloads (running a number of tasks equal to
the number of SMT cores).

Cc: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
@Avenger-285714 Avenger-285714 requested review from Copilot and opsiff May 18, 2026 09:24
@deepin-ci-robot deepin-ci-robot requested review from huangbibo and myml May 18, 2026 09:24
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 18, 2026

Reviewer's Guide

This PR updates the default sched_ext idle CPU selection policy to prefer scheduling on an idle SMT sibling of the previous CPU before searching other idle CPUs in the same LLC, and updates the documented selection steps accordingly.

File-Level Changes

Change Details Files
Prefer an idle SMT sibling of the previous CPU in the default sched_ext idle CPU selection path before scanning the LLC for idle CPUs.
  • Updated the documented step ordering in the scx_select_cpu_dfl policy comment block to insert a new SMT-sibling preference step and renumber subsequent steps.
  • Added a runtime check using sched_smt_active() and for_each_cpu_and() over cpu_smt_mask(prev_cpu) intersected with the allowed mask to scan prev_cpu's SMT siblings.
  • Within that loop, skipped prev_cpu itself and used scx_idle_test_and_clear_cpu() on each sibling, returning early when an idle sibling is found before falling back to LLC-based idle CPU search.
kernel/sched/ext_idle.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from avenger-285714. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Avenger-285714 Avenger-285714 changed the title sched_ext: idle: Prioritize idle SMT sibling [Deepin-Kernel-SIG] [linux 6.18.y] [Upstream] sched_ext: idle: Prioritize idle SMT sibling May 18, 2026
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the default sched_ext built-in idle CPU selection policy to prefer waking/migrating onto an idle SMT sibling of prev_cpu before searching wider domains, aiming to keep work on the same physical core for better cache locality and lower wakeup latency.

Changes:

  • Document the new selection step to prioritize prev_cpu’s idle SMT sibling when no fully-idle core is available.
  • Add an SMT-sibling idle-CPU scan in scx_select_cpu_dfl() before the LLC/NUMA idle searches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kernel/sched/ext_idle.c
Comment on lines +625 to +635
/*
* Use @prev_cpu's sibling if it's idle.
*/
if (sched_smt_active()) {
for_each_cpu_and(cpu, cpu_smt_mask(prev_cpu), allowed) {
if (cpu == prev_cpu)
continue;
if (scx_idle_test_and_clear_cpu(cpu))
goto out_unlock;
}
}
@opsiff
Copy link
Copy Markdown
Member

opsiff commented May 18, 2026

commit 63f500c32a37d490ec623a3130e488cdb9bd6cf7
Author: Andrea Righi arighi@nvidia.com
Date: Sun Mar 22 07:51:46 2026 +0100

sched_ext: Guard cpu_smt_mask() with CONFIG_SCHED_SMT

Wrap cpu_smt_mask() usage with CONFIG_SCHED_SMT to avoid build failures
on kernels built without SMT support.

Fixes: 2197cecdb02c ("sched_ext: idle: Prioritize idle SMT sibling")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202603221422.XIueJOE9-lkp@intel.com/
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Reviewed-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

[Upstream commit 63f500c32a37d490ec623a3130e488cdb9bd6cf7]

Wrap cpu_smt_mask() usage with CONFIG_SCHED_SMT to avoid build failures
on kernels built without SMT support.

Fixes: 2197cecdb02c ("sched_ext: idle: Prioritize idle SMT sibling")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202603221422.XIueJOE9-lkp@intel.com/
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Reviewed-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Suggested-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
@Avenger-285714
Copy link
Copy Markdown
Member Author

commit 63f500c32a37d490ec623a3130e488cdb9bd6cf7 Author: Andrea Righi arighi@nvidia.com Date: Sun Mar 22 07:51:46 2026 +0100

sched_ext: Guard cpu_smt_mask() with CONFIG_SCHED_SMT

Wrap cpu_smt_mask() usage with CONFIG_SCHED_SMT to avoid build failures
on kernels built without SMT support.

Fixes: 2197cecdb02c ("sched_ext: idle: Prioritize idle SMT sibling")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202603221422.XIueJOE9-lkp@intel.com/
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Reviewed-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants