Skip to content

sched: unify RFLAGS definitions and make steal scan limits configurable - #115

Merged
FengHeting merged 2 commits into
ViudiraTech:developfrom
FengHeting:develop
Oct 22, 2026
Merged

FengHeting merged 2 commits into
ViudiraTech:developfrom
FengHeting:develop

Conversation

@FengHeting

Copy link
Copy Markdown
Contributor

Summary

This series contains two independent cleanups:

  1. x86: unify RFLAGS bit definitions — add include/arch/cpu/eflags.h and replace the raw RFLAGS constants (1ULL << 9, 0x202, 0x200, and the local X86_EFLAGS_AC) across the scheduler, APIC, ELF loader, kthread, signal and syscall code. No functional change.

  2. sched: make steal scan limits configurable — replace the hard-coded hot-candidate budget (8) and scan-node limit (32) in pick_steal_candidate_locked() with CONFIG_SCHED_STEAL_HOT_BUDGET and CONFIG_SCHED_STEAL_SCAN_LIMIT. The defaults preserve the current policy and visit the same nodes.

The second commit also makes CONFIG_SCHED_STEAL_HOT_BUDGET=0 meaningful: cold candidates and newly-idle stealing remain active, and the scan stops at the first hot candidate. It also fixes a pre-existing -Wtype-limits build failure when CONFIG_SCHED_MIGRATION_COOLDOWN=0.

Validation

  • make -j4 with GCC/LTO and -Wall -Wextra -Werror
  • clang-tidy kernel/sched/sched.c
  • clang-format --dry-run --Werror
  • Compile-tested steal settings 0, 1/1, 64/64, and cooldown 0; 64/16 is rejected by the new static assert.

Add include/arch/cpu/eflags.h with the architectural RFLAGS bits and use it
to replace the raw 1ULL << 9 tests in the scheduler and APIC code, the
0x202 initial context flags in the scheduler, ELF loader, kthread and
syscall paths, and the SYSCALL FMASK value.  The signal-return mask now
spells out its user-visible flags, and syscall.c drops its local
X86_EFLAGS_AC definition in favour of the shared one.

No functional change.

Signed-off-by: MicroFish <[email protected]>
Replace the hard-coded eight-hot-candidate and 32-node bounds in
pick_steal_candidate_locked() with CONFIG_SCHED_STEAL_HOT_BUDGET and
CONFIG_SCHED_STEAL_SCAN_LIMIT.  The defaults keep the existing policy and
the scan visits the same nodes: pinned entities do not spend the hot
budget, and a non-newly-idle scan abandons the source once the budget is
exhausted.

Move the hot-budget check inside the loop so a zero budget is meaningful:
cold candidates remain eligible and the scan stops at the first hot one,
instead of skipping the loop entirely (which also disabled newly-idle
stealing).  Add a compile-time check that the hot budget does not exceed
the scan limit, and wire both options through Kconfig, the fallback
config, kconfig.mk and the default configuration.

While validating the zero setting, fix the pre-existing build failure for
CONFIG_SCHED_MIGRATION_COOLDOWN=0: copy the cooldown into a local before
the unsigned comparison so -Wtype-limits does not reject the always-false
case.  A zero cooldown still means no cooldown.

Validation: GCC LTO build, clang-tidy on kernel/sched/sched.c and
clang-format; steal configs 0, 1/1 and 64/64 compile, as does
cooldown=0; 64/16 is rejected by the static assert.

Signed-off-by: MicroFish <[email protected]>
@FengHeting
FengHeting merged commit 9adb007 into ViudiraTech:develop Oct 22, 2026
2 checks passed
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.

1 participant