mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Venkat <venkat88@linux.ibm.com>
To: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: mingo@redhat.com, Peter Zijlstra <peterz@infradead.org>,
	tglx@linutronix.de, maddy@linux.ibm.com, will@kernel.org,
	mark.rutland@arm.com, bigeasy@linutronix.de,
	LKML <linux-kernel@vger.kernel.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 1/1] sched: preempt: Move dynamic keys into kernel/sched
Date: Mon, 4 Aug 2025 12:36:17 +0530	[thread overview]
Message-ID: <6A55B96B-C9B6-46CE-A17F-1E580DFF8300@linux.ibm.com> (raw)
In-Reply-To: <20250716094745.2232041-2-sshegde@linux.ibm.com>



> On 16 Jul 2025, at 3:17 PM, Shrikanth Hegde <sshegde@linux.ibm.com> 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 currently spread across entry/common.c, arm64 and latest being
> powerpc. There is little arch specific to it. arm64, powerpc have the
> same code. 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. 
> 
> Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
> Acked-by: Will Deacon <will@kernel.org>
> Acked-by: Madhavan Srinivasan <maddy@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/irq-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 7c1970b341b8..f4985ae4d8a9 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/irq-entry-common.h b/include/linux/irq-entry-common.h
> index 8af374331900..5bb752f0a69c 100644
> --- a/include/linux/irq-entry-common.h
> +++ b/include/linux/irq-entry-common.h
> @@ -343,7 +343,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 54a91261e99b..df9a87de0f83 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -2076,6 +2076,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 b82032777310..0ffe3d5a6c44 100644
> --- a/kernel/entry/common.c
> +++ b/kernel/entry/common.c
> @@ -157,7 +157,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 c73c9ca6ca01..8425008c99f1 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6999,6 +6999,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
> 



<Resending to the right thread>


Tested this patch, by applying on top of mainline kernel. 

Dynamically changed the preemption modes, and its working as expected. Hence,

Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>

Regards,
Venkat.


  reply	other threads:[~2025-08-04  7:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-16  9:47 [PATCH v2 0/1] powerpc, arm64: move preempt dynamic key " Shrikanth Hegde
2025-07-16  9:47 ` [PATCH v2 1/1] sched: preempt: Move dynamic keys " Shrikanth Hegde
2025-08-04  7:06   ` Venkat [this message]
2025-08-12 18:21   ` Shrikanth Hegde
2025-07-23  7:44 Venkat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6A55B96B-C9B6-46CE-A17F-1E580DFF8300@linux.ibm.com \
    --to=venkat88@linux.ibm.com \
    --cc=bigeasy@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sshegde@linux.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®