linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] powerpc, arm64: move preempt dynamic key into kernel/sched
@ 2025-06-10  7:53 Shrikanth Hegde
  2025-06-10  7:53 ` [PATCH 1/1] sched: preempt: Move dynamic keys " Shrikanth Hegde
  0 siblings, 1 reply; 7+ messages in thread
From: Shrikanth Hegde @ 2025-06-10  7:53 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, maddy
  Cc: sshegde, tglx, bigeasy, vschneid, dietmar.eggemann, rostedt,
	linux-kernel, catalin.marinas, will, linux-arm-kernel,
	mark.rutland

Current usage of preempt dynamic key is not specific to architecture and
can be moved into sched/core instead. Most of the code around it looks
similar. (same code for powerpc, arm64). 

Since preemption is more associated with scheduler rather than
entry/exit, it is probably better that they should be moved. 

This is tested on powerVM PREEMPT_DYNAMIC=y/n. 

Only Compile tested on arm64. It would be great if someone can test both 
PREEMPT_DYNAMIC=y/n configs there.

Shrikanth Hegde (1):
  sched: preempt: Move dynamic keys into kernel/sched

 arch/arm64/include/asm/preempt.h   |  1 -
 arch/arm64/kernel/entry-common.c   |  8 --------
 arch/powerpc/include/asm/preempt.h | 16 ----------------
 arch/powerpc/kernel/interrupt.c    |  4 ----
 include/linux/entry-common.h       |  1 -
 include/linux/sched.h              |  8 ++++++++
 kernel/entry/common.c              |  1 -
 kernel/sched/core.c                |  4 ++++
 8 files changed, 12 insertions(+), 31 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/preempt.h

-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] sched: preempt: Move dynamic keys into kernel/sched
  2025-06-10  7:53 [PATCH 0/1] powerpc, arm64: move preempt dynamic key into kernel/sched Shrikanth Hegde
@ 2025-06-10  7:53 ` Shrikanth Hegde
  2025-06-13  9:49   ` Shrikanth Hegde
                     ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Shrikanth Hegde @ 2025-06-10  7:53 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, maddy
  Cc: sshegde, tglx, bigeasy, vschneid, dietmar.eggemann, rostedt,
	linux-kernel, catalin.marinas, will, linux-arm-kernel,
	mark.rutland

Dynamic preemption can be static key or static call based.
Static key is used to check kernel preemption depending on
the current preemption model. i.e enable for lazy, full. 

Code is spread currently across entry/common.c, arm64 and latest being
powerpc. There is little arch specific to it. For example, arm64,
powerpc does the same thing. It is better to move it into kernel/sched 
since preemption is more closely associated with scheduler.  

Plus, Any new arch that wants dynamic preemption enabled need to have 
only HAVE_PREEMPT_DYNAMIC_KEY. 

This is more of code movement. No functional change. 

Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
---
 arch/arm64/include/asm/preempt.h   |  1 -
 arch/arm64/kernel/entry-common.c   |  8 --------
 arch/powerpc/include/asm/preempt.h | 16 ----------------
 arch/powerpc/kernel/interrupt.c    |  4 ----
 include/linux/entry-common.h       |  1 -
 include/linux/sched.h              |  8 ++++++++
 kernel/entry/common.c              |  1 -
 kernel/sched/core.c                |  4 ++++
 8 files changed, 12 insertions(+), 31 deletions(-)
 delete mode 100644 arch/powerpc/include/asm/preempt.h

diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h
index 0159b625cc7f..a9348e65d75e 100644
--- a/arch/arm64/include/asm/preempt.h
+++ b/arch/arm64/include/asm/preempt.h
@@ -87,7 +87,6 @@ void preempt_schedule_notrace(void);
 
 #ifdef CONFIG_PREEMPT_DYNAMIC
 
-DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
 void dynamic_preempt_schedule(void);
 #define __preempt_schedule()		dynamic_preempt_schedule()
 void dynamic_preempt_schedule_notrace(void);
diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
index b260ddc4d3e9..b1c854fb4884 100644
--- a/arch/arm64/kernel/entry-common.c
+++ b/arch/arm64/kernel/entry-common.c
@@ -259,14 +259,6 @@ static void noinstr arm64_exit_el1_dbg(struct pt_regs *regs)
 		lockdep_hardirqs_on(CALLER_ADDR0);
 }
 
-#ifdef CONFIG_PREEMPT_DYNAMIC
-DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
-#define need_irq_preemption() \
-	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
-#else
-#define need_irq_preemption()	(IS_ENABLED(CONFIG_PREEMPTION))
-#endif
-
 static void __sched arm64_preempt_schedule_irq(void)
 {
 	if (!need_irq_preemption())
diff --git a/arch/powerpc/include/asm/preempt.h b/arch/powerpc/include/asm/preempt.h
deleted file mode 100644
index 000e2b9681f3..000000000000
--- a/arch/powerpc/include/asm/preempt.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __ASM_POWERPC_PREEMPT_H
-#define __ASM_POWERPC_PREEMPT_H
-
-#include <asm-generic/preempt.h>
-
-#if defined(CONFIG_PREEMPT_DYNAMIC)
-#include <linux/jump_label.h>
-DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
-#define need_irq_preemption() \
-	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
-#else
-#define need_irq_preemption()   (IS_ENABLED(CONFIG_PREEMPTION))
-#endif
-
-#endif /* __ASM_POWERPC_PREEMPT_H */
diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
index e0c681d0b076..4d62d785ad26 100644
--- a/arch/powerpc/kernel/interrupt.c
+++ b/arch/powerpc/kernel/interrupt.c
@@ -25,10 +25,6 @@
 unsigned long global_dbcr0[NR_CPUS];
 #endif
 
-#if defined(CONFIG_PREEMPT_DYNAMIC)
-DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
-#endif
-
 #ifdef CONFIG_PPC_BOOK3S_64
 DEFINE_STATIC_KEY_FALSE(interrupt_exit_not_reentrant);
 static inline bool exit_must_hard_disable(void)
diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index f94f3fdf15fc..8624faa1f8b9 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -549,7 +549,6 @@ void raw_irqentry_exit_cond_resched(void);
 DECLARE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched);
 #define irqentry_exit_cond_resched()	static_call(irqentry_exit_cond_resched)()
 #elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
-DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
 void dynamic_irqentry_exit_cond_resched(void);
 #define irqentry_exit_cond_resched()	dynamic_irqentry_exit_cond_resched()
 #endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 45e5953b8f32..ebd230382027 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2115,6 +2115,14 @@ static inline int _cond_resched(void)
 
 #endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */
 
+#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
+DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
+#define need_irq_preemption() \
+	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
+#else
+#define need_irq_preemption()   (IS_ENABLED(CONFIG_PREEMPTION))
+#endif
+
 #define cond_resched() ({			\
 	__might_resched(__FILE__, __LINE__, 0);	\
 	_cond_resched();			\
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index a8dd1f27417c..b8ffd7127338 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -268,7 +268,6 @@ void raw_irqentry_exit_cond_resched(void)
 #if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
 DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched);
 #elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
-DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
 void dynamic_irqentry_exit_cond_resched(void)
 {
 	if (!static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 62b3416f5e43..6af2bab187cb 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7083,6 +7083,10 @@ EXPORT_SYMBOL(dynamic_preempt_schedule_notrace);
 
 #endif /* CONFIG_PREEMPTION */
 
+#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
+DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
+#endif
+
 /*
  * This is the entry point to schedule() from kernel preemption
  * off of IRQ context.
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] sched: preempt: Move dynamic keys into kernel/sched
  2025-06-10  7:53 ` [PATCH 1/1] sched: preempt: Move dynamic keys " Shrikanth Hegde
@ 2025-06-13  9:49   ` Shrikanth Hegde
  2025-06-16 16:37   ` Mark Rutland
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Shrikanth Hegde @ 2025-06-13  9:49 UTC (permalink / raw)
  To: maddy, catalin.marinas
  Cc: tglx, bigeasy, vschneid, dietmar.eggemann, rostedt, linux-kernel,
	will, linux-arm-kernel, mark.rutland, Christophe Leroy, mingo,
	peterz, juri.lelli, vincent.guittot

+Cristope Leroy.

On 6/10/25 13:23, Shrikanth Hegde wrote:
> Dynamic preemption can be static key or static call based.
> Static key is used to check kernel preemption depending on
> the current preemption model. i.e enable for lazy, full.
> 
> Code is spread currently across entry/common.c, arm64 and latest being
> powerpc. There is little arch specific to it. For example, arm64,
> powerpc does the same thing. It is better to move it into kernel/sched
> since preemption is more closely associated with scheduler.
> 
> Plus, Any new arch that wants dynamic preemption enabled need to have
> only HAVE_PREEMPT_DYNAMIC_KEY.
> 
> This is more of code movement. No functional change.
> 
> Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
>   arch/arm64/include/asm/preempt.h   |  1 -
>   arch/arm64/kernel/entry-common.c   |  8 --------
>   arch/powerpc/include/asm/preempt.h | 16 ----------------
>   arch/powerpc/kernel/interrupt.c    |  4 ----
>   include/linux/entry-common.h       |  1 -
>   include/linux/sched.h              |  8 ++++++++
>   kernel/entry/common.c              |  1 -
>   kernel/sched/core.c                |  4 ++++
>   8 files changed, 12 insertions(+), 31 deletions(-)
>   delete mode 100644 arch/powerpc/include/asm/preempt.h

Hi. Catalin, Maddy,

Does respective arch changes seem ok?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] sched: preempt: Move dynamic keys into kernel/sched
  2025-06-10  7:53 ` [PATCH 1/1] sched: preempt: Move dynamic keys " Shrikanth Hegde
  2025-06-13  9:49   ` Shrikanth Hegde
@ 2025-06-16 16:37   ` Mark Rutland
  2025-07-13  4:50     ` Shrikanth Hegde
  2025-07-11 14:56   ` Will Deacon
  2025-07-14  2:39   ` Madhavan Srinivasan
  3 siblings, 1 reply; 7+ messages in thread
From: Mark Rutland @ 2025-06-16 16:37 UTC (permalink / raw)
  To: Shrikanth Hegde, catalin.marinas, will
  Cc: mingo, peterz, juri.lelli, vincent.guittot, maddy, tglx, bigeasy,
	vschneid, dietmar.eggemann, rostedt, linux-kernel,
	linux-arm-kernel

On Tue, Jun 10, 2025 at 01:23:44PM +0530, Shrikanth Hegde wrote:
> Dynamic preemption can be static key or static call based.
> Static key is used to check kernel preemption depending on
> the current preemption model. i.e enable for lazy, full. 
> 
> Code is spread currently across entry/common.c, arm64 and latest being
> powerpc. There is little arch specific to it. For example, arm64,
> powerpc does the same thing. It is better to move it into kernel/sched 
> since preemption is more closely associated with scheduler.  
> 
> Plus, Any new arch that wants dynamic preemption enabled need to have 
> only HAVE_PREEMPT_DYNAMIC_KEY. 
> 
> This is more of code movement. No functional change. 
> 
> Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>

I've tested this on arm64 atop v6.16-rc2, building and booting defconfig
and defconfig + PREEMPT_DYNAMIC=y.

It builds cleanly, boots fine, and I think this is obviously correct
given it's just moving things around, so FWIW:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Catalin, Will, are you happy with this?

I assume this would go via the tip tree?

Mark.

> ---
>  arch/arm64/include/asm/preempt.h   |  1 -
>  arch/arm64/kernel/entry-common.c   |  8 --------
>  arch/powerpc/include/asm/preempt.h | 16 ----------------
>  arch/powerpc/kernel/interrupt.c    |  4 ----
>  include/linux/entry-common.h       |  1 -
>  include/linux/sched.h              |  8 ++++++++
>  kernel/entry/common.c              |  1 -
>  kernel/sched/core.c                |  4 ++++
>  8 files changed, 12 insertions(+), 31 deletions(-)
>  delete mode 100644 arch/powerpc/include/asm/preempt.h
> 
> diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h
> index 0159b625cc7f..a9348e65d75e 100644
> --- a/arch/arm64/include/asm/preempt.h
> +++ b/arch/arm64/include/asm/preempt.h
> @@ -87,7 +87,6 @@ void preempt_schedule_notrace(void);
>  
>  #ifdef CONFIG_PREEMPT_DYNAMIC
>  
> -DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
>  void dynamic_preempt_schedule(void);
>  #define __preempt_schedule()		dynamic_preempt_schedule()
>  void dynamic_preempt_schedule_notrace(void);
> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
> index b260ddc4d3e9..b1c854fb4884 100644
> --- a/arch/arm64/kernel/entry-common.c
> +++ b/arch/arm64/kernel/entry-common.c
> @@ -259,14 +259,6 @@ static void noinstr arm64_exit_el1_dbg(struct pt_regs *regs)
>  		lockdep_hardirqs_on(CALLER_ADDR0);
>  }
>  
> -#ifdef CONFIG_PREEMPT_DYNAMIC
> -DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> -#define need_irq_preemption() \
> -	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> -#else
> -#define need_irq_preemption()	(IS_ENABLED(CONFIG_PREEMPTION))
> -#endif
> -
>  static void __sched arm64_preempt_schedule_irq(void)
>  {
>  	if (!need_irq_preemption())
> diff --git a/arch/powerpc/include/asm/preempt.h b/arch/powerpc/include/asm/preempt.h
> deleted file mode 100644
> index 000e2b9681f3..000000000000
> --- a/arch/powerpc/include/asm/preempt.h
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> -#ifndef __ASM_POWERPC_PREEMPT_H
> -#define __ASM_POWERPC_PREEMPT_H
> -
> -#include <asm-generic/preempt.h>
> -
> -#if defined(CONFIG_PREEMPT_DYNAMIC)
> -#include <linux/jump_label.h>
> -DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> -#define need_irq_preemption() \
> -	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> -#else
> -#define need_irq_preemption()   (IS_ENABLED(CONFIG_PREEMPTION))
> -#endif
> -
> -#endif /* __ASM_POWERPC_PREEMPT_H */
> diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
> index e0c681d0b076..4d62d785ad26 100644
> --- a/arch/powerpc/kernel/interrupt.c
> +++ b/arch/powerpc/kernel/interrupt.c
> @@ -25,10 +25,6 @@
>  unsigned long global_dbcr0[NR_CPUS];
>  #endif
>  
> -#if defined(CONFIG_PREEMPT_DYNAMIC)
> -DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> -#endif
> -
>  #ifdef CONFIG_PPC_BOOK3S_64
>  DEFINE_STATIC_KEY_FALSE(interrupt_exit_not_reentrant);
>  static inline bool exit_must_hard_disable(void)
> diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
> index f94f3fdf15fc..8624faa1f8b9 100644
> --- a/include/linux/entry-common.h
> +++ b/include/linux/entry-common.h
> @@ -549,7 +549,6 @@ void raw_irqentry_exit_cond_resched(void);
>  DECLARE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched);
>  #define irqentry_exit_cond_resched()	static_call(irqentry_exit_cond_resched)()
>  #elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> -DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
>  void dynamic_irqentry_exit_cond_resched(void);
>  #define irqentry_exit_cond_resched()	dynamic_irqentry_exit_cond_resched()
>  #endif
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 45e5953b8f32..ebd230382027 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -2115,6 +2115,14 @@ static inline int _cond_resched(void)
>  
>  #endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */
>  
> +#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> +DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> +#define need_irq_preemption() \
> +	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> +#else
> +#define need_irq_preemption()   (IS_ENABLED(CONFIG_PREEMPTION))
> +#endif
> +
>  #define cond_resched() ({			\
>  	__might_resched(__FILE__, __LINE__, 0);	\
>  	_cond_resched();			\
> diff --git a/kernel/entry/common.c b/kernel/entry/common.c
> index a8dd1f27417c..b8ffd7127338 100644
> --- a/kernel/entry/common.c
> +++ b/kernel/entry/common.c
> @@ -268,7 +268,6 @@ void raw_irqentry_exit_cond_resched(void)
>  #if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
>  DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched);
>  #elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> -DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
>  void dynamic_irqentry_exit_cond_resched(void)
>  {
>  	if (!static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 62b3416f5e43..6af2bab187cb 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -7083,6 +7083,10 @@ EXPORT_SYMBOL(dynamic_preempt_schedule_notrace);
>  
>  #endif /* CONFIG_PREEMPTION */
>  
> +#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> +DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> +#endif
> +
>  /*
>   * This is the entry point to schedule() from kernel preemption
>   * off of IRQ context.
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] sched: preempt: Move dynamic keys into kernel/sched
  2025-06-10  7:53 ` [PATCH 1/1] sched: preempt: Move dynamic keys " Shrikanth Hegde
  2025-06-13  9:49   ` Shrikanth Hegde
  2025-06-16 16:37   ` Mark Rutland
@ 2025-07-11 14:56   ` Will Deacon
  2025-07-14  2:39   ` Madhavan Srinivasan
  3 siblings, 0 replies; 7+ messages in thread
From: Will Deacon @ 2025-07-11 14:56 UTC (permalink / raw)
  To: Shrikanth Hegde
  Cc: mingo, peterz, juri.lelli, vincent.guittot, maddy, tglx, bigeasy,
	vschneid, dietmar.eggemann, rostedt, linux-kernel,
	catalin.marinas, linux-arm-kernel, mark.rutland

On Tue, Jun 10, 2025 at 01:23:44PM +0530, Shrikanth Hegde wrote:
> Dynamic preemption can be static key or static call based.
> Static key is used to check kernel preemption depending on
> the current preemption model. i.e enable for lazy, full. 
> 
> Code is spread currently across entry/common.c, arm64 and latest being
> powerpc. There is little arch specific to it. For example, arm64,
> powerpc does the same thing. It is better to move it into kernel/sched 
> since preemption is more closely associated with scheduler.  
> 
> Plus, Any new arch that wants dynamic preemption enabled need to have 
> only HAVE_PREEMPT_DYNAMIC_KEY. 
> 
> This is more of code movement. No functional change. 
> 
> Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
>  arch/arm64/include/asm/preempt.h   |  1 -
>  arch/arm64/kernel/entry-common.c   |  8 --------
>  arch/powerpc/include/asm/preempt.h | 16 ----------------
>  arch/powerpc/kernel/interrupt.c    |  4 ----
>  include/linux/entry-common.h       |  1 -
>  include/linux/sched.h              |  8 ++++++++
>  kernel/entry/common.c              |  1 -
>  kernel/sched/core.c                |  4 ++++
>  8 files changed, 12 insertions(+), 31 deletions(-)
>  delete mode 100644 arch/powerpc/include/asm/preempt.h

Acked-by: Will Deacon <will@kernel.org>

Will

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] sched: preempt: Move dynamic keys into kernel/sched
  2025-06-16 16:37   ` Mark Rutland
@ 2025-07-13  4:50     ` Shrikanth Hegde
  0 siblings, 0 replies; 7+ messages in thread
From: Shrikanth Hegde @ 2025-07-13  4:50 UTC (permalink / raw)
  To: Mark Rutland, catalin.marinas, will, maddy
  Cc: mingo, peterz, juri.lelli, vincent.guittot, tglx, bigeasy,
	vschneid, dietmar.eggemann, rostedt, linux-kernel,
	linux-arm-kernel


> On Tue, Jun 10, 2025 at 01:23:44PM +0530, Shrikanth Hegde wrote:
>> Dynamic preemption can be static key or static call based.
>> Static key is used to check kernel preemption depending on
>> the current preemption model. i.e enable for lazy, full.
>>
>> Code is spread currently across entry/common.c, arm64 and latest being
>> powerpc. There is little arch specific to it. For example, arm64,
>> powerpc does the same thing. It is better to move it into kernel/sched
>> since preemption is more closely associated with scheduler.
>>
>> Plus, Any new arch that wants dynamic preemption enabled need to have
>> only HAVE_PREEMPT_DYNAMIC_KEY.
>>
>> This is more of code movement. No functional change.
>>
>> Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> 
> I've tested this on arm64 atop v6.16-rc2, building and booting defconfig
> and defconfig + PREEMPT_DYNAMIC=y.
> 

Hi Mark. Thanks for testing it. Sorry for delayed response.

> It builds cleanly, boots fine, and I think this is obviously correct
> given it's just moving things around, so FWIW:
> 
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> 
> Catalin, Will, are you happy with this?
>

Thank you will for the tags.


> I assume this would go via the tip tree?
> 

Maddy, are you okay with this?

I would request it to go via tip tree.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] sched: preempt: Move dynamic keys into kernel/sched
  2025-06-10  7:53 ` [PATCH 1/1] sched: preempt: Move dynamic keys " Shrikanth Hegde
                     ` (2 preceding siblings ...)
  2025-07-11 14:56   ` Will Deacon
@ 2025-07-14  2:39   ` Madhavan Srinivasan
  3 siblings, 0 replies; 7+ messages in thread
From: Madhavan Srinivasan @ 2025-07-14  2:39 UTC (permalink / raw)
  To: Shrikanth Hegde, mingo, peterz, juri.lelli, vincent.guittot
  Cc: tglx, bigeasy, vschneid, dietmar.eggemann, rostedt, linux-kernel,
	catalin.marinas, will, linux-arm-kernel, mark.rutland



On 6/10/25 1:23 PM, Shrikanth Hegde wrote:
> Dynamic preemption can be static key or static call based.
> Static key is used to check kernel preemption depending on
> the current preemption model. i.e enable for lazy, full. 
> 
> Code is spread currently across entry/common.c, arm64 and latest being
> powerpc. There is little arch specific to it. For example, arm64,
> powerpc does the same thing. It is better to move it into kernel/sched 
> since preemption is more closely associated with scheduler.  
> 
> Plus, Any new arch that wants dynamic preemption enabled need to have 
> only HAVE_PREEMPT_DYNAMIC_KEY. 
> 
> This is more of code movement. No functional change. 
> 

For powerpc changes
Acked-by: Madhavan Srinivasan <maddy@linux.ibm.com>


> Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> ---
>  arch/arm64/include/asm/preempt.h   |  1 -
>  arch/arm64/kernel/entry-common.c   |  8 --------
>  arch/powerpc/include/asm/preempt.h | 16 ----------------
>  arch/powerpc/kernel/interrupt.c    |  4 ----
>  include/linux/entry-common.h       |  1 -
>  include/linux/sched.h              |  8 ++++++++
>  kernel/entry/common.c              |  1 -
>  kernel/sched/core.c                |  4 ++++
>  8 files changed, 12 insertions(+), 31 deletions(-)
>  delete mode 100644 arch/powerpc/include/asm/preempt.h
> 
> diff --git a/arch/arm64/include/asm/preempt.h b/arch/arm64/include/asm/preempt.h
> index 0159b625cc7f..a9348e65d75e 100644
> --- a/arch/arm64/include/asm/preempt.h
> +++ b/arch/arm64/include/asm/preempt.h
> @@ -87,7 +87,6 @@ void preempt_schedule_notrace(void);
>  
>  #ifdef CONFIG_PREEMPT_DYNAMIC
>  
> -DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
>  void dynamic_preempt_schedule(void);
>  #define __preempt_schedule()		dynamic_preempt_schedule()
>  void dynamic_preempt_schedule_notrace(void);
> diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c
> index b260ddc4d3e9..b1c854fb4884 100644
> --- a/arch/arm64/kernel/entry-common.c
> +++ b/arch/arm64/kernel/entry-common.c
> @@ -259,14 +259,6 @@ static void noinstr arm64_exit_el1_dbg(struct pt_regs *regs)
>  		lockdep_hardirqs_on(CALLER_ADDR0);
>  }
>  
> -#ifdef CONFIG_PREEMPT_DYNAMIC
> -DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> -#define need_irq_preemption() \
> -	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> -#else
> -#define need_irq_preemption()	(IS_ENABLED(CONFIG_PREEMPTION))
> -#endif
> -
>  static void __sched arm64_preempt_schedule_irq(void)
>  {
>  	if (!need_irq_preemption())
> diff --git a/arch/powerpc/include/asm/preempt.h b/arch/powerpc/include/asm/preempt.h
> deleted file mode 100644
> index 000e2b9681f3..000000000000
> --- a/arch/powerpc/include/asm/preempt.h
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> -#ifndef __ASM_POWERPC_PREEMPT_H
> -#define __ASM_POWERPC_PREEMPT_H
> -
> -#include <asm-generic/preempt.h>
> -
> -#if defined(CONFIG_PREEMPT_DYNAMIC)
> -#include <linux/jump_label.h>
> -DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> -#define need_irq_preemption() \
> -	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> -#else
> -#define need_irq_preemption()   (IS_ENABLED(CONFIG_PREEMPTION))
> -#endif
> -
> -#endif /* __ASM_POWERPC_PREEMPT_H */
> diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
> index e0c681d0b076..4d62d785ad26 100644
> --- a/arch/powerpc/kernel/interrupt.c
> +++ b/arch/powerpc/kernel/interrupt.c
> @@ -25,10 +25,6 @@
>  unsigned long global_dbcr0[NR_CPUS];
>  #endif
>  
> -#if defined(CONFIG_PREEMPT_DYNAMIC)
> -DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> -#endif
> -
>  #ifdef CONFIG_PPC_BOOK3S_64
>  DEFINE_STATIC_KEY_FALSE(interrupt_exit_not_reentrant);
>  static inline bool exit_must_hard_disable(void)
> diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
> index f94f3fdf15fc..8624faa1f8b9 100644
> --- a/include/linux/entry-common.h
> +++ b/include/linux/entry-common.h
> @@ -549,7 +549,6 @@ void raw_irqentry_exit_cond_resched(void);
>  DECLARE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched);
>  #define irqentry_exit_cond_resched()	static_call(irqentry_exit_cond_resched)()
>  #elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> -DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
>  void dynamic_irqentry_exit_cond_resched(void);
>  #define irqentry_exit_cond_resched()	dynamic_irqentry_exit_cond_resched()
>  #endif
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 45e5953b8f32..ebd230382027 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -2115,6 +2115,14 @@ static inline int _cond_resched(void)
>  
>  #endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */
>  
> +#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> +DECLARE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> +#define need_irq_preemption() \
> +	(static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> +#else
> +#define need_irq_preemption()   (IS_ENABLED(CONFIG_PREEMPTION))
> +#endif
> +
>  #define cond_resched() ({			\
>  	__might_resched(__FILE__, __LINE__, 0);	\
>  	_cond_resched();			\
> diff --git a/kernel/entry/common.c b/kernel/entry/common.c
> index a8dd1f27417c..b8ffd7127338 100644
> --- a/kernel/entry/common.c
> +++ b/kernel/entry/common.c
> @@ -268,7 +268,6 @@ void raw_irqentry_exit_cond_resched(void)
>  #if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
>  DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched);
>  #elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> -DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
>  void dynamic_irqentry_exit_cond_resched(void)
>  {
>  	if (!static_branch_unlikely(&sk_dynamic_irqentry_exit_cond_resched))
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 62b3416f5e43..6af2bab187cb 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -7083,6 +7083,10 @@ EXPORT_SYMBOL(dynamic_preempt_schedule_notrace);
>  
>  #endif /* CONFIG_PREEMPTION */
>  
> +#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY)
> +DEFINE_STATIC_KEY_TRUE(sk_dynamic_irqentry_exit_cond_resched);
> +#endif
> +
>  /*
>   * This is the entry point to schedule() from kernel preemption
>   * off of IRQ context.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-07-14  2:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10  7:53 [PATCH 0/1] powerpc, arm64: move preempt dynamic key into kernel/sched Shrikanth Hegde
2025-06-10  7:53 ` [PATCH 1/1] sched: preempt: Move dynamic keys " Shrikanth Hegde
2025-06-13  9:49   ` Shrikanth Hegde
2025-06-16 16:37   ` Mark Rutland
2025-07-13  4:50     ` Shrikanth Hegde
2025-07-11 14:56   ` Will Deacon
2025-07-14  2:39   ` Madhavan Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).