Skip to contentSkip to conversation

sched: Convert paravirt_steal to new static key APIs

PATCH RESEND Applied Hongyan Xia 4 participants 5 messages Aug 19 – Nov 1

Subsystems (12)
x86 KVM PowerPC RISC-V +8 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 sched: Convert paravirt_steal to new static key APIs

From: Hongyan Xia <[email protected]>

paravirt_steal_rq_enabled and paravirt_steal_enabled use raw static_key APIs which are now deprecated. Use the new API instead.

No functional change.

---
Changed in RESEND:
- Separate the original series into individual patches. They aren't easy to review as a series.

 arch/arm64/kernel/paravirt.c           | 4 ++--
 arch/loongarch/kernel/paravirt.c       | 4 ++--
 arch/powerpc/platforms/pseries/setup.c | 4 ++--
 arch/riscv/kernel/paravirt.c           | 4 ++--
 arch/x86/kernel/cpu/vmware.c           | 4 ++--
 arch/x86/kernel/kvm.c                  | 4 ++--
 drivers/xen/time.c                     | 4 ++--
 include/linux/sched/cputime.h          | 6 +++---
 kernel/sched/core.c                    | 4 ++--
 kernel/sched/cputime.c                 | 4 ++--
 10 files changed, 21 insertions(+), 21 deletions(-)
arch/arm64/kernel/paravirt.c +2 -2
index 572efb96b23f..30bf61d031eb 100644
@@ -157,9 +157,9 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, para_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 
 	pr_info("using stolen time PV\n");
 
arch/loongarch/kernel/paravirt.c +2 -2
index 10821cce554c..e8965a3f8082 100644
@@ -308,10 +308,10 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, paravt_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 #endif
 
 	if (static_key_enabled(&virt_preempt_key))
arch/powerpc/platforms/pseries/setup.c +2 -2
index 1223dc961242..8dcbc4bb7025 100644
@@ -852,9 +852,9 @@ static void __init pSeries_setup_arch(void)
 			static_branch_enable(&shared_processor);
 			pv_spinlocks_init();
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-			static_key_slow_inc(&paravirt_steal_enabled);
+			static_branch_inc(&paravirt_steal_enabled);
 			if (steal_acc)
-				static_key_slow_inc(&paravirt_steal_rq_enabled);
+				static_branch_inc(&paravirt_steal_rq_enabled);
 #endif
 		}
 
arch/riscv/kernel/paravirt.c +2 -2
index 5f56be79cd06..9c13a6f1ea2a 100644
@@ -116,9 +116,9 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, pv_time_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 
 	pr_info("Computing paravirt steal-time\n");
 
arch/x86/kernel/cpu/vmware.c +2 -2
index 34b73573b108..f7ab9e7902cf 100644
@@ -328,9 +328,9 @@ static int vmware_cpu_down_prepare(unsigned int cpu)
 static __init int activate_jump_labels(void)
 {
 	if (has_steal_clock) {
-		static_key_slow_inc(&paravirt_steal_enabled);
+		static_branch_inc(&paravirt_steal_enabled);
 		if (steal_acc)
-			static_key_slow_inc(&paravirt_steal_rq_enabled);
+			static_branch_inc(&paravirt_steal_rq_enabled);
 	}
 
 	return 0;
arch/x86/kernel/kvm.c +2 -2
index dcef84da304b..d3dcd64f22c2 100644
@@ -1052,9 +1052,9 @@ const __initconst struct hypervisor_x86 x86_hyper_kvm = {
 static __init int activate_jump_labels(void)
 {
 	if (has_steal_clock) {
-		static_key_slow_inc(&paravirt_steal_enabled);
+		static_branch_inc(&paravirt_steal_enabled);
 		if (steal_acc)
-			static_key_slow_inc(&paravirt_steal_rq_enabled);
+			static_branch_inc(&paravirt_steal_rq_enabled);
 	}
 
 	return 0;
drivers/xen/time.c +2 -2
index a2be0a4d45b0..a02d48a2aa68 100644
@@ -169,7 +169,7 @@ void __init xen_time_setup_guest(void)
 
 	static_call_update(pv_steal_clock, xen_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (xen_runstate_remote)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 }
include/linux/sched/cputime.h +3 -3
index e90efaf6d26e..694126411dfe 100644
@@ -182,9 +182,9 @@ extern unsigned long long
 task_sched_runtime(struct task_struct *task);
 
 #ifdef CONFIG_PARAVIRT
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
+#include <linux/jump_label.h>
+DECLARE_STATIC_KEY_FALSE(paravirt_steal_enabled);
+DECLARE_STATIC_KEY_FALSE(paravirt_steal_rq_enabled);
 
 #ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
 u64 dummy_steal_clock(int cpu);
kernel/sched/core.c +2 -2
index 5c07d53e43b5..84d090581a08 100644
@@ -795,7 +795,7 @@ struct rq *_task_rq_lock(struct task_struct *p, struct rq_flags *rf)
 
 /* Use CONFIG_PARAVIRT as this will avoid more #ifdef in arch code. */
 #ifdef CONFIG_PARAVIRT
-struct static_key paravirt_steal_rq_enabled;
+DEFINE_STATIC_KEY_FALSE(paravirt_steal_rq_enabled);
 #endif
 
 static void update_rq_clock_task(struct rq *rq, s64 delta)
@@ -834,7 +834,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
 	}
 #endif
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-	if (static_key_false((&paravirt_steal_rq_enabled))) {
+	if (static_branch_unlikely(&paravirt_steal_rq_enabled)) {
 		u64 prev_steal;
 
 		steal = prev_steal = paravirt_steal_clock(cpu_of(rq));
kernel/sched/cputime.c +2 -2
index 06bddaa738e5..f16970ca81d0 100644
@@ -255,7 +255,7 @@ void __account_forceidle_time(struct task_struct *p, u64 delta)
  * occasion account more time than the calling functions think elapsed.
  */
 #ifdef CONFIG_PARAVIRT
-struct static_key paravirt_steal_enabled;
+DEFINE_STATIC_KEY_FALSE(paravirt_steal_enabled);
 
 #ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
 static u64 native_steal_clock(int cpu)
@@ -270,7 +270,7 @@ DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
 static __always_inline u64 steal_account_process_time(u64 maxtime)
 {
 #ifdef CONFIG_PARAVIRT
-	if (static_key_false(&paravirt_steal_enabled)) {
+	if (static_branch_unlikely(&paravirt_steal_enabled)) {
 		u64 steal;
 
 		steal = paravirt_steal_clock(smp_processor_id());
Signature · 1 line
2.47.3
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Hongyan.

Quoted 7 lines · Hongyan Xia

From: Hongyan Xia <[email protected]>

paravirt_steal_rq_enabled and paravirt_steal_enabled use raw static_key APIs which are now deprecated. Use the new API instead.

No functional change.

FWIW, looks good to me. One minor nit.

Quoted 135 lines

---
Changed in RESEND:
- Separate the original series into individual patches. They aren't easy to review as a series.

  arch/arm64/kernel/paravirt.c           | 4 ++--
  arch/loongarch/kernel/paravirt.c       | 4 ++--
  arch/powerpc/platforms/pseries/setup.c | 4 ++--
  arch/riscv/kernel/paravirt.c           | 4 ++--
  arch/x86/kernel/cpu/vmware.c           | 4 ++--
  arch/x86/kernel/kvm.c                  | 4 ++--
  drivers/xen/time.c                     | 4 ++--
  include/linux/sched/cputime.h          | 6 +++---
  kernel/sched/core.c                    | 4 ++--
  kernel/sched/cputime.c                 | 4 ++--
  10 files changed, 21 insertions(+), 21 deletions(-)
arch/arm64/kernel/paravirt.c +2 -2
index 572efb96b23f..30bf61d031eb 100644
@@ -157,9 +157,9 @@ int __init pv_time_init(void)
 
  	static_call_update(pv_steal_clock, para_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
  	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 
  	pr_info("using stolen time PV\n");
 
arch/loongarch/kernel/paravirt.c +2 -2
index 10821cce554c..e8965a3f8082 100644
@@ -308,10 +308,10 @@ int __init pv_time_init(void)
 
  	static_call_update(pv_steal_clock, paravt_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
  #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
  	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
  #endif
 
  	if (static_key_enabled(&virt_preempt_key))
arch/powerpc/platforms/pseries/setup.c +2 -2
index 1223dc961242..8dcbc4bb7025 100644
@@ -852,9 +852,9 @@ static void __init pSeries_setup_arch(void)
  			static_branch_enable(&shared_processor);
  			pv_spinlocks_init();
  #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-			static_key_slow_inc(&paravirt_steal_enabled);
+			static_branch_inc(&paravirt_steal_enabled);
  			if (steal_acc)
-				static_key_slow_inc(&paravirt_steal_rq_enabled);
+				static_branch_inc(&paravirt_steal_rq_enabled);
  #endif
  		}
 
arch/riscv/kernel/paravirt.c +2 -2
index 5f56be79cd06..9c13a6f1ea2a 100644
@@ -116,9 +116,9 @@ int __init pv_time_init(void)
 
  	static_call_update(pv_steal_clock, pv_time_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
  	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 
  	pr_info("Computing paravirt steal-time\n");
 
arch/x86/kernel/cpu/vmware.c +2 -2
index 34b73573b108..f7ab9e7902cf 100644
@@ -328,9 +328,9 @@ static int vmware_cpu_down_prepare(unsigned int cpu)
  static __init int activate_jump_labels(void)
  {
  	if (has_steal_clock) {
-		static_key_slow_inc(&paravirt_steal_enabled);
+		static_branch_inc(&paravirt_steal_enabled);
  		if (steal_acc)
-			static_key_slow_inc(&paravirt_steal_rq_enabled);
+			static_branch_inc(&paravirt_steal_rq_enabled);
  	}
 
  	return 0;
arch/x86/kernel/kvm.c +2 -2
index dcef84da304b..d3dcd64f22c2 100644
@@ -1052,9 +1052,9 @@ const __initconst struct hypervisor_x86 x86_hyper_kvm = {
  static __init int activate_jump_labels(void)
  {
  	if (has_steal_clock) {
-		static_key_slow_inc(&paravirt_steal_enabled);
+		static_branch_inc(&paravirt_steal_enabled);
  		if (steal_acc)
-			static_key_slow_inc(&paravirt_steal_rq_enabled);
+			static_branch_inc(&paravirt_steal_rq_enabled);
  	}
 
  	return 0;
drivers/xen/time.c +2 -2
index a2be0a4d45b0..a02d48a2aa68 100644
@@ -169,7 +169,7 @@ void __init xen_time_setup_guest(void)
 
  	static_call_update(pv_steal_clock, xen_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
  	if (xen_runstate_remote)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
  }
include/linux/sched/cputime.h +0 -0
index e90efaf6d26e..694126411dfe 100644

include/linux/sched/cputime.h extern unsigned long long · line 185

Quoted 7 lines
include/linux/sched/cputime.h +1 -3
@@ -182,9 +182,9 @@ extern unsigned long long
  task_sched_runtime(struct task_struct *task);
 
  #ifdef CONFIG_PARAVIRT
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
+#include <linux/jump_label.h>

nit:

This looks bit odd to see includes in the middle. I know it is including only if necessary.
maybe worth an unconditional include in the beginning?

Quoted 49 lines
include/linux/sched/cputime.h +2 -0
+DECLARE_STATIC_KEY_FALSE(paravirt_steal_enabled);
+DECLARE_STATIC_KEY_FALSE(paravirt_steal_rq_enabled);
 
  #ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
  u64 dummy_steal_clock(int cpu);
kernel/sched/core.c +2 -2
index 5c07d53e43b5..84d090581a08 100644
@@ -795,7 +795,7 @@ struct rq *_task_rq_lock(struct task_struct *p, struct rq_flags *rf)
 
  /* Use CONFIG_PARAVIRT as this will avoid more #ifdef in arch code. */
  #ifdef CONFIG_PARAVIRT
-struct static_key paravirt_steal_rq_enabled;
+DEFINE_STATIC_KEY_FALSE(paravirt_steal_rq_enabled);
  #endif
 
  static void update_rq_clock_task(struct rq *rq, s64 delta)
@@ -834,7 +834,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
  	}
  #endif
  #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-	if (static_key_false((&paravirt_steal_rq_enabled))) {
+	if (static_branch_unlikely(&paravirt_steal_rq_enabled)) {
  		u64 prev_steal;
 
  		steal = prev_steal = paravirt_steal_clock(cpu_of(rq));
kernel/sched/cputime.c +2 -2
index 06bddaa738e5..f16970ca81d0 100644
@@ -255,7 +255,7 @@ void __account_forceidle_time(struct task_struct *p, u64 delta)
   * occasion account more time than the calling functions think elapsed.
   */
  #ifdef CONFIG_PARAVIRT
-struct static_key paravirt_steal_enabled;
+DEFINE_STATIC_KEY_FALSE(paravirt_steal_enabled);
 
  #ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
  static u64 native_steal_clock(int cpu)
@@ -270,7 +270,7 @@ DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
  static __always_inline u64 steal_account_process_time(u64 maxtime)
  {
  #ifdef CONFIG_PARAVIRT
-	if (static_key_false(&paravirt_steal_enabled)) {
+	if (static_branch_unlikely(&paravirt_steal_enabled)) {
  		u64 steal;
 
  		steal = paravirt_steal_clock(smp_processor_id());
#2 lore raw
In reply to Hongyan Xia
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     087b40fe5934e4b8aa80b29b3debbd6542756ffd
Gitweb:        https://git.kernel.org/tip/087b40fe5934e4b8aa80b29b3debbd6542756ffd
Author:        Hongyan Xia =0A= <[email protected]>
AuthorDate:    Wed, 19 Aug 2026 08:12:09 
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Wed, 02 Sep 2026 09:37:24 +02:00

sched: Convert paravirt_steal to new static key APIs

paravirt_steal_rq_enabled and paravirt_steal_enabled use raw static_key APIs which are now deprecated. Use the new API instead.

No functional change.

---
 arch/arm64/kernel/paravirt.c           | 4 ++--
 arch/loongarch/kernel/paravirt.c       | 4 ++--
 arch/powerpc/platforms/pseries/setup.c | 4 ++--
 arch/riscv/kernel/paravirt.c           | 4 ++--
 arch/x86/kernel/cpu/vmware.c           | 4 ++--
 arch/x86/kernel/kvm.c                  | 4 ++--
 drivers/xen/time.c                     | 4 ++--
 include/linux/sched/cputime.h          | 6 +++---
 kernel/sched/core.c                    | 4 ++--
 kernel/sched/cputime.c                 | 4 ++--
 10 files changed, 21 insertions(+), 21 deletions(-)
arch/arm64/kernel/paravirt.c +2 -2
index 572efb9..30bf61d 100644
@@ -157,9 +157,9 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, para_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 
 	pr_info("using stolen time PV\n");
 
arch/loongarch/kernel/paravirt.c +2 -2
index 10821cc..e8965a3 100644
@@ -308,10 +308,10 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, paravt_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 #endif
 
 	if (static_key_enabled(&virt_preempt_key))
arch/powerpc/platforms/pseries/setup.c +2 -2
index f29e754..c181df4 100644
@@ -876,9 +876,9 @@ static void __init pSeries_setup_arch(void)
 			static_branch_enable(&shared_processor);
 			pv_spinlocks_init();
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-			static_key_slow_inc(&paravirt_steal_enabled);
+			static_branch_inc(&paravirt_steal_enabled);
 			if (steal_acc)
-				static_key_slow_inc(&paravirt_steal_rq_enabled);
+				static_branch_inc(&paravirt_steal_rq_enabled);
 #endif
 		}
 
arch/riscv/kernel/paravirt.c +2 -2
index 5f56be7..9c13a6f 100644
@@ -116,9 +116,9 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, pv_time_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 
 	pr_info("Computing paravirt steal-time\n");
 
arch/x86/kernel/cpu/vmware.c +2 -2
index 34b7357..f7ab9e7 100644
@@ -328,9 +328,9 @@ static int vmware_cpu_down_prepare(unsigned int cpu)
 static __init int activate_jump_labels(void)
 {
 	if (has_steal_clock) {
-		static_key_slow_inc(&paravirt_steal_enabled);
+		static_branch_inc(&paravirt_steal_enabled);
 		if (steal_acc)
-			static_key_slow_inc(&paravirt_steal_rq_enabled);
+			static_branch_inc(&paravirt_steal_rq_enabled);
 	}
 
 	return 0;
arch/x86/kernel/kvm.c +2 -2
index 6b0a586..2ce01fd 100644
@@ -1054,9 +1054,9 @@ const __initconst struct hypervisor_x86 x86_hyper_kvm = {
 static __init int activate_jump_labels(void)
 {
 	if (has_steal_clock) {
-		static_key_slow_inc(&paravirt_steal_enabled);
+		static_branch_inc(&paravirt_steal_enabled);
 		if (steal_acc)
-			static_key_slow_inc(&paravirt_steal_rq_enabled);
+			static_branch_inc(&paravirt_steal_rq_enabled);
 	}
 
 	return 0;
drivers/xen/time.c +2 -2
index a2be0a4..a02d48a 100644
@@ -169,7 +169,7 @@ void __init xen_time_setup_guest(void)
 
 	static_call_update(pv_steal_clock, xen_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (xen_runstate_remote)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 }
include/linux/sched/cputime.h +3 -3
index e90efaf..6941264 100644
@@ -182,9 +182,9 @@ extern unsigned long long
 task_sched_runtime(struct task_struct *task);
 
 #ifdef CONFIG_PARAVIRT
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
+#include <linux/jump_label.h>
+DECLARE_STATIC_KEY_FALSE(paravirt_steal_enabled);
+DECLARE_STATIC_KEY_FALSE(paravirt_steal_rq_enabled);
 
 #ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
 u64 dummy_steal_clock(int cpu);
kernel/sched/core.c +2 -2
index c9dd6f4..4e97766 100644
@@ -805,7 +805,7 @@ struct rq *_task_rq_lock(struct task_struct *p, struct rq_flags *rf)
 
 /* Use CONFIG_PARAVIRT as this will avoid more #ifdef in arch code. */
 #ifdef CONFIG_PARAVIRT
-struct static_key paravirt_steal_rq_enabled;
+DEFINE_STATIC_KEY_FALSE(paravirt_steal_rq_enabled);
 #endif
 
 static void update_rq_clock_task(struct rq *rq, s64 delta)
@@ -844,7 +844,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
 	}
 #endif
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-	if (static_key_false((&paravirt_steal_rq_enabled))) {
+	if (static_branch_unlikely(&paravirt_steal_rq_enabled)) {
 		u64 prev_steal;
 
 		steal = prev_steal = paravirt_steal_clock(cpu_of(rq));
kernel/sched/cputime.c +2 -2
index 06bddaa..f16970c 100644
@@ -255,7 +255,7 @@ void __account_forceidle_time(struct task_struct *p, u64 delta)
  * occasion account more time than the calling functions think elapsed.
  */
 #ifdef CONFIG_PARAVIRT
-struct static_key paravirt_steal_enabled;
+DEFINE_STATIC_KEY_FALSE(paravirt_steal_enabled);
 
 #ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
 static u64 native_steal_clock(int cpu)
@@ -270,7 +270,7 @@ DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
 static __always_inline u64 steal_account_process_time(u64 maxtime)
 {
 #ifdef CONFIG_PARAVIRT
-	if (static_key_false(&paravirt_steal_enabled)) {
+	if (static_branch_unlikely(&paravirt_steal_enabled)) {
 		u64 steal;
 
 		steal = paravirt_steal_clock(smp_processor_id());
merge bot Applied
#3 lore raw
In reply to Hongyan Xia
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     a5576ebce9201e2abc820348a494e666de8efe64
Gitweb:        https://git.kernel.org/tip/a5576ebce9201e2abc820348a494e666de8efe64
Author:        Hongyan Xia <[email protected]>
AuthorDate:    Wed, 19 Aug 2026 08:12:09 
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Wed, 02 Sep 2026 10:28:24 +02:00

sched: Convert paravirt_steal to new static key APIs

paravirt_steal_rq_enabled and paravirt_steal_enabled use raw static_key APIs which are now deprecated. Use the new API instead.

No functional change.

---
 arch/arm64/kernel/paravirt.c           | 4 ++--
 arch/loongarch/kernel/paravirt.c       | 4 ++--
 arch/powerpc/platforms/pseries/setup.c | 4 ++--
 arch/riscv/kernel/paravirt.c           | 4 ++--
 arch/x86/kernel/cpu/vmware.c           | 4 ++--
 arch/x86/kernel/kvm.c                  | 4 ++--
 drivers/xen/time.c                     | 4 ++--
 include/linux/sched/cputime.h          | 6 +++---
 kernel/sched/core.c                    | 4 ++--
 kernel/sched/cputime.c                 | 4 ++--
 10 files changed, 21 insertions(+), 21 deletions(-)
arch/arm64/kernel/paravirt.c +2 -2
index 572efb9..30bf61d 100644
@@ -157,9 +157,9 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, para_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 
 	pr_info("using stolen time PV\n");
 
arch/loongarch/kernel/paravirt.c +2 -2
index 10821cc..e8965a3 100644
@@ -308,10 +308,10 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, paravt_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 #endif
 
 	if (static_key_enabled(&virt_preempt_key))
arch/powerpc/platforms/pseries/setup.c +2 -2
index f29e754..c181df4 100644
@@ -876,9 +876,9 @@ static void __init pSeries_setup_arch(void)
 			static_branch_enable(&shared_processor);
 			pv_spinlocks_init();
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-			static_key_slow_inc(&paravirt_steal_enabled);
+			static_branch_inc(&paravirt_steal_enabled);
 			if (steal_acc)
-				static_key_slow_inc(&paravirt_steal_rq_enabled);
+				static_branch_inc(&paravirt_steal_rq_enabled);
 #endif
 		}
 
arch/riscv/kernel/paravirt.c +2 -2
index 5f56be7..9c13a6f 100644
@@ -116,9 +116,9 @@ int __init pv_time_init(void)
 
 	static_call_update(pv_steal_clock, pv_time_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (steal_acc)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 
 	pr_info("Computing paravirt steal-time\n");
 
arch/x86/kernel/cpu/vmware.c +2 -2
index 34b7357..f7ab9e7 100644
@@ -328,9 +328,9 @@ static int vmware_cpu_down_prepare(unsigned int cpu)
 static __init int activate_jump_labels(void)
 {
 	if (has_steal_clock) {
-		static_key_slow_inc(&paravirt_steal_enabled);
+		static_branch_inc(&paravirt_steal_enabled);
 		if (steal_acc)
-			static_key_slow_inc(&paravirt_steal_rq_enabled);
+			static_branch_inc(&paravirt_steal_rq_enabled);
 	}
 
 	return 0;
arch/x86/kernel/kvm.c +2 -2
index 6b0a586..2ce01fd 100644
@@ -1054,9 +1054,9 @@ const __initconst struct hypervisor_x86 x86_hyper_kvm = {
 static __init int activate_jump_labels(void)
 {
 	if (has_steal_clock) {
-		static_key_slow_inc(&paravirt_steal_enabled);
+		static_branch_inc(&paravirt_steal_enabled);
 		if (steal_acc)
-			static_key_slow_inc(&paravirt_steal_rq_enabled);
+			static_branch_inc(&paravirt_steal_rq_enabled);
 	}
 
 	return 0;
drivers/xen/time.c +2 -2
index a2be0a4..a02d48a 100644
@@ -169,7 +169,7 @@ void __init xen_time_setup_guest(void)
 
 	static_call_update(pv_steal_clock, xen_steal_clock);
 
-	static_key_slow_inc(&paravirt_steal_enabled);
+	static_branch_inc(&paravirt_steal_enabled);
 	if (xen_runstate_remote)
-		static_key_slow_inc(&paravirt_steal_rq_enabled);
+		static_branch_inc(&paravirt_steal_rq_enabled);
 }
include/linux/sched/cputime.h +3 -3
index e90efaf..6941264 100644
@@ -182,9 +182,9 @@ extern unsigned long long
 task_sched_runtime(struct task_struct *task);
 
 #ifdef CONFIG_PARAVIRT
-struct static_key;
-extern struct static_key paravirt_steal_enabled;
-extern struct static_key paravirt_steal_rq_enabled;
+#include <linux/jump_label.h>
+DECLARE_STATIC_KEY_FALSE(paravirt_steal_enabled);
+DECLARE_STATIC_KEY_FALSE(paravirt_steal_rq_enabled);
 
 #ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
 u64 dummy_steal_clock(int cpu);
kernel/sched/core.c +2 -2
index c9dd6f4..4e97766 100644
@@ -805,7 +805,7 @@ struct rq *_task_rq_lock(struct task_struct *p, struct rq_flags *rf)
 
 /* Use CONFIG_PARAVIRT as this will avoid more #ifdef in arch code. */
 #ifdef CONFIG_PARAVIRT
-struct static_key paravirt_steal_rq_enabled;
+DEFINE_STATIC_KEY_FALSE(paravirt_steal_rq_enabled);
 #endif
 
 static void update_rq_clock_task(struct rq *rq, s64 delta)
@@ -844,7 +844,7 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
 	}
 #endif
 #ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
-	if (static_key_false((&paravirt_steal_rq_enabled))) {
+	if (static_branch_unlikely(&paravirt_steal_rq_enabled)) {
 		u64 prev_steal;
 
 		steal = prev_steal = paravirt_steal_clock(cpu_of(rq));
kernel/sched/cputime.c +2 -2
index 06bddaa..f16970c 100644
@@ -255,7 +255,7 @@ void __account_forceidle_time(struct task_struct *p, u64 delta)
  * occasion account more time than the calling functions think elapsed.
  */
 #ifdef CONFIG_PARAVIRT
-struct static_key paravirt_steal_enabled;
+DEFINE_STATIC_KEY_FALSE(paravirt_steal_enabled);
 
 #ifdef CONFIG_HAVE_PV_STEAL_CLOCK_GEN
 static u64 native_steal_clock(int cpu)
@@ -270,7 +270,7 @@ DEFINE_STATIC_CALL(pv_steal_clock, native_steal_clock);
 static __always_inline u64 steal_account_process_time(u64 maxtime)
 {
 #ifdef CONFIG_PARAVIRT
-	if (static_key_false(&paravirt_steal_enabled)) {
+	if (static_branch_unlikely(&paravirt_steal_enabled)) {
 		u64 steal;
 
 		steal = paravirt_steal_clock(smp_processor_id());
#4 lore raw
In reply to Hongyan Xia
This patch was applied to riscv/linux.git (fixes) by Peter Zijlstra <[email protected]>:

Hello:

This patch was applied to riscv/linux.git (fixes)
by Peter Zijlstra <[email protected]>:

Quoted 8 lines · On Wed, 19 Aug 2026 08:12:09 +0000 you wrote:

From: Hongyan Xia <[email protected]>

paravirt_steal_rq_enabled and paravirt_steal_enabled use raw static_key APIs which are now deprecated. Use the new API instead.

No functional change.

[...]

Here is the summary with links:
- [RESEND] sched: Convert paravirt_steal to new static key APIs

    https://git.kernel.org/riscv/c/a5576ebce920

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html