[PATCH v3 20/20] sched/debug: Add debug knobs for steal monitor

From: Shrikanth Hegde

Date: Thu May 14 2026 - 11:34:11 EST


Add three debug knobs in steal_monitor:

sampling_period - sampling frequency in milliseconds.
low_threshold - lower steal threshold value (specify percentage * 100)
high_threshold - higher steal threshold value (specify percentage * 100)

Refer to Documentation/scheduler/sched-debug.rst for detailed info.

Signed-off-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
---
Documentation/scheduler/sched-debug.rst | 32 +++++++++++++++++++++++++
kernel/sched/debug.c | 3 +++
2 files changed, 35 insertions(+)

diff --git a/Documentation/scheduler/sched-debug.rst b/Documentation/scheduler/sched-debug.rst
index b5a92a39eccd..a1fddfca2a52 100644
--- a/Documentation/scheduler/sched-debug.rst
+++ b/Documentation/scheduler/sched-debug.rst
@@ -52,3 +52,35 @@ rate for each task.

``scan_size_mb`` is how many megabytes worth of pages are scanned for
a given scan.
+
+==================================
+Tunables for generic steal monitor
+==================================
+Feature for preferred CPUs logic. Available under CONFIG_PREFERRED_CPU
+Files are at /sys/kernel/debug/sched/steal_monitor/
+
+enable - used for enable/disable the steal_monitor feature.
+Disable needs more than a static branch disable to maintain design
+construct of preferred is same as online when feature is disabled.
+Once enabled, it starts sampling steal time at intervals specified in
+sampling_period and takes action based on high/low thresholds.
+
+sampling_period - sampling frequency in milliseconds.
+How often sampling for steal values happen. This controls how fast scheduler
+acts on detecting the changes to steal time values.
+Default value is 1000 milliseconds.
+
+low_threshold - lower threshold value in percentage * 100
+This determines what values should be considered as nil/no steal values.
+When scheduler see steal times below this value, it will try to increase
+the preferred CPUs by 1 core. Having value as zero causes too much oscillations.
+Default value is 200, i.e 2% steal is considered as low threshold.
+
+high_threshold - higher threshold value in percentage * 100
+This determines what values should be considered as high steal values.
+When scheduler see steal times higher than this value, it will reduce
+the preferred CPUs by 1 core.
+Default value is 500, i.e 5% steal is considered as high threshold.
+
+Note: When the steal values in between high and low threshold no action is taken
+by scheduler. This is to avoid oscillations.
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index f00c08581253..57ba35f7cf95 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -629,6 +629,9 @@ static void sched_steal_monitor_debugfs_init(void)
return;

debugfs_create_file("enable", 0644, sm, &sched_sm_wr_enable, &sched_sm_en_fops);
+ debugfs_create_u32("low_threshold", 0644, sm, &steal_mon.low_threshold);
+ debugfs_create_u32("high_threshold", 0644, sm, &steal_mon.high_threshold);
+ debugfs_create_u32("sampling_period", 0644, sm, &steal_mon.sampling_period_ms);
}
#endif

--
2.47.3