Re: [PATCH v3 14/20] sched/debug: Provide debugfs to enable/disable steal monitor

From: Shrikanth Hegde

Date: Tue Jun 09 2026 - 01:05:57 EST




On 6/8/26 11:58 PM, Ilya Leoshkevich wrote:


On 5/14/26 17:21, Shrikanth Hegde wrote:
Add a debugfs "enable" file to enable steal time monitor.

Computing steal time and acting on it periodically are to be opted by
the user. This helps to avoid any overhead when the feature
is disabled.

It is disabled by default.

Signed-off-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
---
  kernel/sched/core.c  |  1 +
  kernel/sched/debug.c | 29 +++++++++++++++++++++++++++++
  kernel/sched/sched.h |  2 ++
  3 files changed, 32 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0d1995c65ce6..1533a44d1a6b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c

[...]

@@ -592,6 +592,33 @@ static void debugfs_ext_server_init(void)
  #endif /* CONFIG_SCHED_CLASS_EXT */
  #ifdef CONFIG_PREFERRED_CPU
+__read_mostly bool sched_sm_wr_enable;
+
+static ssize_t sched_sm_en_write(struct file *filp, const char __user *ubuf,
+                 size_t cnt, loff_t *ppos)
+{
+    bool orig = sched_sm_wr_enable;
+    ssize_t result;
+
+    result = debugfs_write_file_bool(filp, ubuf, cnt, ppos);
+
+    if (sched_sm_wr_enable && !orig) {
+        static_branch_enable(&__sched_sm_enable);

Would it make sense to clear the steal monitor state when enabling it?
Otherwise we may immediately trigger a bogus "dec" if user did a disable
during contention and re-enabled when everything is quiet.


Yes, it may lead to one wrong direction decision but for the case when disable
was during contention and re-enabled again during contention.

I think setting previous_decision = 0 during disable to should fix it. So previous
direction of inc/dec won't carry over the enable.