Skip to contentSkip to conversation

sched: Feature to decide if steal should update CPU capacity

PATCH In review Srikar Dronamraju 4 participants 6 messages Oct 28, 2025 – Oct 29, 2025

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 2/2 powerpc/smp: Disable ACCT_STEAL for shared LPARs

In reply to Srikar Dronamraju

In a shared LPAR with SMT enabled, it has been observed that when a CPU experiences steal time, it can trigger task migrations between sibling CPUs. The idle CPU pulls a runnable task from its sibling that is impacted by steal, making the previously busy CPU go idle. This reversal can repeat continuously, resulting in ping-pong behavior between SMT siblings.

To avoid migrations solely triggered by steal time, disable the ACCT_STEAL scheduling feature when running in shared processor mode.

lparstat
System Configuration
type=Shared mode=Uncapped smt=8 lcpu=72 mem=2139693696 kB cpus=64 ent=24.00

Noise case: (Ebizzy on 2 LPARs with similar configuration as above)

nr-ebizzy-threads  baseline  std-deviation  +patch    std-deviation
36                 1         (0.0345589)    1.02358   (0.0346247)
72                 1         (0.0387066)    1.11729   (0.0215052)
96                 1         (0.013317)     1.07751   (0.014656)
128                1         (0.028087)     1.0585    (0.0173575)
144                1         (0.0103478)    1.11785   (0.0472121)
192                1         (0.0164666)    1.0212    (0.0226717)
256                1         (0.0241208)    0.969056  (0.0169747)
288                1         (0.0121516)    0.971862  (0.0190453)

scaled perf stats for 72 thread case.

event         baseline  +patch
cycles        1         1.16475
instructions  1         1.13198
cs            1         0.914774
migrations    1         0.116058
faults        1         0.94104
cache-misses  1         1.75184

Observations:
- We see a drop in context-switches and migrations resulting in an improvement in the records per second.

No-noise case: (Ebizzy on 1 LPARs with other LPAR being idle)

nr-ebizzy-threads  baseline  std-deviation  +patch    std-deviation
36                 1         (0.0451482)    0.985758  (0.0204456)
72                 1         (0.0308503)    1.0288    (0.065893)
96                 1         (0.0500514)    1.07178   (0.0376889)
128                1         (0.0602872)    0.986705  (0.0467856)
144                1         (0.0843502)    1.04157   (0.0626338)
192                1         (0.0255402)    1.03327   (0.0975257)
256                1         (0.00653372)   1.04572   (0.00576901)
288                1         (0.00318369)   1.04578   (0.0115398)
---
 arch/powerpc/kernel/smp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/powerpc/kernel/smp.c +5 -2
index 5ac7084eebc0..d80053f0a05e 100644
@@ -1694,8 +1694,11 @@ static void __init build_sched_topology(void)
 {
 	int i = 0;
 
-	if (is_shared_processor() && has_big_cores)
-		static_branch_enable(&splpar_asym_pack);
+	if (is_shared_processor()) {
+		if (has_big_cores)
+			static_branch_enable(&splpar_asym_pack);
+		steal_updates_cpu_capacity(false);
+	}
 
 #ifdef CONFIG_SCHED_SMT
 	if (has_big_cores) {
Signature · 1 line
2.47.3
#0 lore raw

PATCH 1/2 sched: Feature to decide if steal should update CPU capacity

At present, scheduler scales CPU capacity for fair tasks based on time spent on irq and steal time. If a CPU sees irq or steal time, its capacity for fair tasks decreases causing tasks to migrate to other CPU that are not affected by irq and steal time. All of this is gated by NONTASK_CAPACITY.

In virtualized setups, a CPU that reports steal time (time taken by the hypervisor) can cause tasks to migrate unnecessarily to sibling CPUs that appear to be less busy, only for the situation to reverse shortly.

To mitigate this ping-pong behaviour, this change introduces a new scheduler feature flag: ACCT_STEAL which will control whether steal time contributes to non-task capacity adjustments (used for fair scheduling).

---
 include/linux/sched.h   | 1 +
 kernel/sched/core.c     | 7 +++++--
 kernel/sched/debug.c    | 8 ++++++++
 kernel/sched/features.h | 1 +
 4 files changed, 15 insertions(+), 2 deletions(-)
include/linux/sched.h +1 -0
index aa9c5be7a632..451931cce5bf 100644
@@ -2272,5 +2272,6 @@ static __always_inline void alloc_tag_restore(struct alloc_tag *tag, struct allo
 #define alloc_tag_save(_tag)			NULL
 #define alloc_tag_restore(_tag, _old)		do {} while (0)
 #endif
+extern void steal_updates_cpu_capacity(bool enable);
 
 #endif
kernel/sched/core.c +5 -2
index 81c6df746df1..3a7c4e307371 100644
@@ -792,8 +792,11 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
 	rq->clock_task += delta;
 
 #ifdef CONFIG_HAVE_SCHED_AVG_IRQ
-	if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
-		update_irq_load_avg(rq, irq_delta + steal);
+	if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY)) {
+		if (steal && sched_feat(ACCT_STEAL))
+			irq_delta += steal;
+		update_irq_load_avg(rq, irq_delta);
+	}
 #endif
 	update_rq_clock_pelt(rq, delta);
 }
kernel/sched/debug.c +8 -0
index 557246880a7e..a0393dd43bb2 100644
@@ -1307,3 +1307,11 @@ void resched_latency_warn(int cpu, u64 latency)
 	       cpu, latency, cpu_rq(cpu)->ticks_without_resched);
 	dump_stack();
 }
+
+void steal_updates_cpu_capacity(bool enable)
+{
+	if (enable)
+		sched_feat_set("ACCT_STEAL");
+	else
+		sched_feat_set("NO_ACCT_STEAL");
+}
kernel/sched/features.h +1 -0
index 3c12d9f93331..82d7806ea515 100644
@@ -121,3 +121,4 @@ SCHED_FEAT(WA_BIAS, true)
 SCHED_FEAT(UTIL_EST, true)
 
 SCHED_FEAT(LATENCY_WARN, false)
+SCHED_FEAT(ACCT_STEAL, true)
Signature · 1 line
2.47.3
maintainer
#2 lore raw
Quoted 6 lines · Srikar Dronamraju

At present, scheduler scales CPU capacity for fair tasks based on time spent on irq and steal time. If a CPU sees irq or steal time, its capacity for fair tasks decreases causing tasks to migrate to other CPU that are not affected by irq and steal time. All of this is gated by NONTASK_CAPACITY.

Quoted 7 lines

In virtualized setups, a CPU that reports steal time (time taken by the hypervisor) can cause tasks to migrate unnecessarily to sibling CPUs that appear to be less busy, only for the situation to reverse shortly.

To mitigate this ping-pong behaviour, this change introduces a new scheduler feature flag: ACCT_STEAL which will control whether steal time contributes to non-task capacity adjustments (used for fair scheduling).

Please don't use sched_feat like this. If this is something that wants to be set by architectures move it to a normal static_branch (like eg. sched_energy_present, sched_asymc_cpucapacity, sched_cluster_active, sched_smt_present, sched_numa_balancing etc.).

#3 lore raw
Quoted 11 lines · Peter Zijlstra
Quoted 10 lines · Srikar Dronamraju

At present, scheduler scales CPU capacity for fair tasks based on time spent on irq and steal time. If a CPU sees irq or steal time, its capacity for fair tasks decreases causing tasks to migrate to other CPU that are not affected by irq and steal time. All of this is gated by NONTASK_CAPACITY.

In virtualized setups, a CPU that reports steal time (time taken by the hypervisor) can cause tasks to migrate unnecessarily to sibling CPUs that appear to be less busy, only for the situation to reverse shortly.

Quoted 8 lines
Quoted 3 lines

To mitigate this ping-pong behaviour, this change introduces a new scheduler feature flag: ACCT_STEAL which will control whether steal time contributes to non-task capacity adjustments (used for fair scheduling).

Please don't use sched_feat like this. If this is something that wants to be set by architectures move it to a normal static_branch (like eg. sched_energy_present, sched_asymc_cpucapacity, sched_cluster_active, sched_smt_present, sched_numa_balancing etc.).

Ok, Peter, will move it to a static_branch approach and post a v2.

Signature · 2 lines
Thanks and Regards
Srikar Dronamraju
#4 lore raw
In reply to Srikar Dronamraju
Quoted 38 lines · Srikar Dronamraju

At present, scheduler scales CPU capacity for fair tasks based on time spent on irq and steal time. If a CPU sees irq or steal time, its capacity for fair tasks decreases causing tasks to migrate to other CPU that are not affected by irq and steal time. All of this is gated by NONTASK_CAPACITY.

In virtualized setups, a CPU that reports steal time (time taken by the hypervisor) can cause tasks to migrate unnecessarily to sibling CPUs that appear to be less busy, only for the situation to reverse shortly.

To mitigate this ping-pong behaviour, this change introduces a new scheduler feature flag: ACCT_STEAL which will control whether steal time contributes to non-task capacity adjustments (used for fair scheduling).

---
  include/linux/sched.h   | 1 +
  kernel/sched/core.c     | 7 +++++--
  kernel/sched/debug.c    | 8 ++++++++
  kernel/sched/features.h | 1 +
  4 files changed, 15 insertions(+), 2 deletions(-)
include/linux/sched.h +1 -0
index aa9c5be7a632..451931cce5bf 100644
@@ -2272,5 +2272,6 @@ static __always_inline void alloc_tag_restore(struct alloc_tag *tag, struct allo
  #define alloc_tag_save(_tag)			NULL
  #define alloc_tag_restore(_tag, _old)		do {} while (0)
  #endif
+extern void steal_updates_cpu_capacity(bool enable);
 
  #endif
kernel/sched/core.c +0 -0
index 81c6df746df1..3a7c4e307371 100644

kernel/sched/core.c static void update_rq_clock_task(struct rq *rq, s64 delta) · line 794

Quoted 3 lines
kernel/sched/core.c +0 -0
@@ -792,8 +792,11 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
  	rq->clock_task += delta;
 
  #ifdef CONFIG_HAVE_SCHED_AVG_IRQ

Curious to know if there are users/distro which have CONFIG_HAVE_SCHED_AVG_IRQ=n

Quoted 35 lines
kernel/sched/core.c +5 -2
-	if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY))
-		update_irq_load_avg(rq, irq_delta + steal);
+	if ((irq_delta + steal) && sched_feat(NONTASK_CAPACITY)) {
+		if (steal && sched_feat(ACCT_STEAL))
+			irq_delta += steal;
+		update_irq_load_avg(rq, irq_delta);
+	}
  #endif
  	update_rq_clock_pelt(rq, delta);
  }
kernel/sched/debug.c +8 -0
index 557246880a7e..a0393dd43bb2 100644
@@ -1307,3 +1307,11 @@ void resched_latency_warn(int cpu, u64 latency)
  	       cpu, latency, cpu_rq(cpu)->ticks_without_resched);
  	dump_stack();
  }
+
+void steal_updates_cpu_capacity(bool enable)
+{
+	if (enable)
+		sched_feat_set("ACCT_STEAL");
+	else
+		sched_feat_set("NO_ACCT_STEAL");
+}
kernel/sched/features.h +1 -0
index 3c12d9f93331..82d7806ea515 100644
@@ -121,3 +121,4 @@ SCHED_FEAT(WA_BIAS, true)
  SCHED_FEAT(UTIL_EST, true)
 
  SCHED_FEAT(LATENCY_WARN, false)
+SCHED_FEAT(ACCT_STEAL, true)
#5 lore raw

Hello Shrikanth,

Quoted 5 lines · Shrikanth Hegde

kernel/sched/core.c static void update_rq_clock_task(struct rq *rq, s64 delta) · line 793

Quoted 3 lines
kernel/sched/core.c +0 -0
@@ -792,8 +792,11 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
       rq->clock_task += delta;
     #ifdef CONFIG_HAVE_SCHED_AVG_IRQ

Curious to know if there are users/distro which have CONFIG_HAVE_SCHED_AVG_IRQ=n

Some arch such as s390 doesn't select HAVE_IRQ_TIME_ACCOUNTING which disables IRQ_TIME_ACCOUNTING and HAVE_SCHED_AVG_IRQ.

Checking the Ubuntu 22.04 6.8.0-86-generic config on my machine shows CONFIG_IRQ_TIME_ACCOUNTING is disabled by default. Same is the case with 6.14.0-34-generic config on Ubuntu 24.04.

Signature · 2 lines
Thanks and Regards,
Prateek