Skip to content

Conversation

@opsiff
Copy link
Member

@opsiff opsiff commented Jan 27, 2026

deepin inclusion
category: kabi

some kabi whitelist symbol changed, such as set_cpus_allowed_ptr..etc. the symbol chain is:
int wake_up_process(struct task_struct *tsk);->struct task_struct ->struct sched_dl_entity dl,*dl_server;
->struct rq *rq;
->struct sched_domain __rcu *sd;
->
+unsigned int newidle_call;
+unsigned int newidle_success;
+unsigned int newidle_ratio;

Before find the way to solve it, disable it for CONFIG_DEEPIN_KABI_RESERVE.

Log:

change set_cpus_allowed_ptr
change wake_up_process
change set_user_nice

Fixes: 97d5537 ("sched/fair: Proportional newidle balance")

Summary by Sourcery

Disable proportional newidle balancing when Deepin KABI reservation is enabled to preserve kernel ABI stability.

Enhancements:

  • Guard newidle balancing statistics and randomized NI_RANDOM feature behind CONFIG_DEEPIN_KABI_RESERVE to avoid KABI-visible struct sched_domain changes.
  • Initialize sched_domain instances without newidle statistics fields when KABI reservation is active.

Summary by Sourcery

Guard proportional newidle balancing and its statistics behind Deepin KABI reservation to avoid changing the sched_domain ABI layout.

Enhancements:

  • Wrap newidle balance statistics fields in sched_domain and related initialization in sd_init() with CONFIG_DEEPIN_KABI_RESERVE to keep the struct layout stable.
  • Disable NI_RANDOM-based proportional newidle balancing and its feature flag when Deepin KABI reservation is enabled.
  • Include Deepin KABI header in scheduler topology to support the new configuration guard.

@deepin-ci-robot
Copy link

[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 opsiff. 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

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 27, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR conditionally disables the proportional newidle balancing feature and its associated statistics when Deepin KABI reservation is enabled, to keep sched_domain’s layout stable for KABI while preserving existing behavior otherwise.

Class diagram for sched_domain layout under CONFIG_DEEPIN_KABI_RESERVE

classDiagram
    class SchedulerConfig {
        <<config>>
        +bool CONFIG_DEEPIN_KABI_RESERVE
    }

    class sched_domain_non_kabi {
        +unsigned int nr_balance_failed
        +unsigned int newidle_call
        +unsigned int newidle_success
        +unsigned int newidle_ratio
        +u64 max_newidle_lb_cost
        +unsigned long last_decay_max_lb_cost
    }

    class sched_domain_kabi_reserve {
        +unsigned int nr_balance_failed
        +u64 max_newidle_lb_cost
        +unsigned long last_decay_max_lb_cost
    }

    SchedulerConfig --> sched_domain_non_kabi : CONFIG_DEEPIN_KABI_RESERVE = false
    SchedulerConfig --> sched_domain_kabi_reserve : CONFIG_DEEPIN_KABI_RESERVE = true
Loading

Flow diagram for newidle balancing behavior with CONFIG_DEEPIN_KABI_RESERVE

flowchart TD
    A["CPU becomes newly idle"] --> B{CONFIG_DEEPIN_KABI_RESERVE}

    B -- false --> C["update_newidle_stats increments newidle_call and newidle_success"]
    C --> D{sched_feat NI_RANDOM}
    D -- true --> E["Apply randomized weighting for newidle balancing"]
    D -- false --> F["Use default weight for newidle balancing"]
    E --> G["Call load_balance with CPU_NEWLY_IDLE"]
    F --> G["Call load_balance with CPU_NEWLY_IDLE"]

    B -- true --> H["Skip newidle_call/newidle_success/newidle_ratio updates"]
    H --> I["NI_RANDOM feature disabled at compile time"]
    I --> J["Call load_balance with CPU_NEWLY_IDLE using default behavior"]
Loading

File-Level Changes

Change Details Files
Hide newidle balancing statistics fields from sched_domain when Deepin KABI reservation is enabled to avoid KABI-visible struct changes.
  • Include Deepin KABI header in scheduler topology declarations to access CONFIG_DEEPIN_KABI_RESERVE.
  • Wrap newidle_call, newidle_success, and newidle_ratio fields in struct sched_domain with a CONFIG_DEEPIN_KABI_RESERVE guard so they are omitted when KABI reservation is active.
include/linux/sched/topology.h
Disable runtime updating of newidle statistics under KABI reservation while keeping behavior unchanged otherwise.
  • Guard the body of update_newidle_stats with CONFIG_DEEPIN_KABI_RESERVE so calls become no-ops when KABI reservation is active.
  • Ensure the function remains present so callers don’t need ifdefs, but internal accounting is skipped under KABI reservation.
kernel/sched/fair.c
Disable NI_RANDOM-based proportional newidle balancing when KABI reservation is enabled.
  • Wrap the NI_RANDOM feature definition in a CONFIG_DEEPIN_KABI_RESERVE guard so the feature is not available when KABI reservation is active.
  • Guard the NI_RANDOM randomization logic in sched_balance_newidle with CONFIG_DEEPIN_KABI_RESERVE so the weight remains constant under KABI reservation.
kernel/sched/features.h
kernel/sched/fair.c
Avoid initializing newidle statistics in sched_domain initialization when KABI reservation is enabled.
  • Guard initialization of newidle_call, newidle_success, and newidle_ratio in sd_init with CONFIG_DEEPIN_KABI_RESERVE so those fields are only set when they exist.
  • Preserve all other sched_domain initialization paths unchanged.
kernel/sched/topology.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

@opsiff opsiff force-pushed the linux-6.6.y-2026-01-27-kabi branch from 66b6ae2 to 50929f9 Compare January 27, 2026 08:19
deepin inclusion
category: kabi

some kabi whitelist symbol changed, such as set_cpus_allowed_ptr..etc.
the symbol chain is:
int wake_up_process(struct task_struct *tsk);->struct task_struct
->struct sched_dl_entity dl,*dl_server;
->struct rq *rq;
->struct sched_domain __rcu	*sd;
->
+unsigned int newidle_call;
+unsigned int newidle_success;
+unsigned int newidle_ratio;

Before find the way to solve it, disable it for CONFIG_DEEPIN_KABI_RESERVE.

Log:

change set_cpus_allowed_ptr
change wake_up_process
change set_user_nice

Fixes: 97d5537 ("sched/fair: Proportional newidle balance")
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@opsiff opsiff force-pushed the linux-6.6.y-2026-01-27-kabi branch from 50929f9 to 2f37b5e Compare January 27, 2026 08:20
Copy link

@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

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

This PR disables proportional newidle balancing to preserve kernel ABI stability for Deepin by guarding struct members and features with CONFIG_DEEPIN_KABI_RESERVE. The changes prevent ABI breakage in exported symbols like wake_up_process and set_cpus_allowed_ptr by conditionally removing three new fields (newidle_call, newidle_success, newidle_ratio) from struct sched_domain that were added by commit 97d5537.

Changes:

  • Conditionally removes three newidle statistics fields from struct sched_domain
  • Guards the NI_RANDOM scheduler feature flag to disable proportional balancing
  • Protects all code paths that use the removed fields and feature

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
include/linux/sched/topology.h Adds deepin_kabi.h include and guards newidle statistics fields in struct sched_domain with CONFIG_DEEPIN_KABI_RESERVE
kernel/sched/topology.c Conditionally excludes initialization of newidle statistics fields in sd_init()
kernel/sched/features.h Guards the NI_RANDOM feature flag definition
kernel/sched/fair.c Guards update_newidle_stats() implementation and NI_RANDOM-based proportional balancing logic

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

@Avenger-285714
Copy link
Member

This way of fixing is kind of gross...

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.

3 participants