sched: dynamic: Simplify PREEMPT_DYNAMIC
Subsystems (10)
Mark Rutland
reviewerv2 cover sched: dynamic: Simplify PREEMPT_DYNAMIC
All architectures which currently suppoort PREEMPT_DYNAMIC select ARCH_HAS_PREEMPT_LAZY. On architectures which select ARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since v7.0 due to commit:
7dadeaa6e851 ("sched: Further restrict the preemption modes")
Hence in practice PREEMPT_DYNAMIC no longer supports the NONE or VOLUNTARY preemption models.
This series makes the de-facto situation official by making PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY, and removing redundant code.
Since v1, I've had to rebase atop v7.2-rc4 to avoid a conflict with commit:
a2c02aa0c6ca ("powerpc: Remove dead non-preemption code")
Given this is now late in the cycle, and given the tip:sched/core branch is based on v7.2-rc1, I suspect tip folk might not want to queue this now. Please let me know what you'd prefer; I'm happy to rebase and resend after v7.3-rc1.
Since v1:
* Rebase to v7.2-rc4
* Apply Revied-by tags.
* Fix typos in commit messages.
* Add patch to cleanup accessors (per Shrikanth's comment)
Mark.
Mark Rutland (6):
sched: dynamic: Make PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY
sched: dynamic: Simplify {cond,might}_resched()
sched: dynamic: Simplify preempt_schedule{,_notrace}()
sched: dynamic: Simplify irqentry_exit_cond_resched()
sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
sched: dynamic: Simplify preempt model accessors
arch/Kconfig | 38 ------- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/preempt.h | 10 -- arch/loongarch/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/s390/include/asm/preempt.h | 11 -- arch/x86/Kconfig | 1 - arch/x86/include/asm/preempt.h | 28 ----- include/asm-generic/preempt.h | 10 -- include/linux/irq-entry-common.h | 17 +-- include/linux/kernel.h | 20 ---- include/linux/preempt.h | 20 ++-- include/linux/sched.h | 31 +----- kernel/Kconfig.preempt | 9 +- kernel/entry/common.c | 17 +-- kernel/sched/core.c | 180 +------------------------------ 18 files changed, 23 insertions(+), 374 deletions(-)
Signature · 1 line
2.30.2
Mark Rutland
reviewerPATCH v2 1/6 sched: dynamic: Make PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY
On architectures which select ARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since commit:
7dadeaa6e851 ("sched: Further restrict the preemption modes")
... which was merged in v7.0.
All architectures which currently support PREEMPT_DYNAMIC select ARCH_HAS_PREEMPT_LAZY:
[mark@lakrids:~/src/linux]% git describe HEAD v7.2-rc1-1-g871a4586ea2e1
[mark@lakrids:~/src/linux]% git grep 'select HAVE_PREEMPT_DYNAMIC_' -- arch
arch/arm64/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY
arch/loongarch/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY
arch/powerpc/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY arch/riscv/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY arch/s390/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY arch/x86/Kconfig: select HAVE_PREEMPT_DYNAMIC_CALL [mark@lakrids:~/src/linux]% git grep 'select ARCH_HAS_PREEMPT_LAZY' -- arch arch/arm64/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/loongarch/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/powerpc/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/riscv/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/s390/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/x86/Kconfig: select ARCH_HAS_PREEMPT_LAZY
... and hence in practice PREEMPT_DYNAMIC no longer supports the NONE or VOLUNTARY preemption models.
Make this official: have PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY, and remove the trivially unreachable code. Further simplifications will be made in subsequent patches.
--- kernel/Kconfig.preempt | 1 + kernel/sched/core.c | 63 ++---------------------------------------- 2 files changed, 4 insertions(+), 60 deletions(-)
kernel/Kconfig.preempt +1 -0
@@ -129,6 +129,7 @@ config PREEMPTION config PREEMPT_DYNAMIC bool "Preemption behaviour defined on boot" depends on HAVE_PREEMPT_DYNAMIC + depends on ARCH_HAS_PREEMPT_LAZY select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY select PREEMPT_BUILD default y if HAVE_PREEMPT_DYNAMIC_CALL
kernel/sched/core.c +3 -60
95 lines not on this page · raw message
Signature · 1 line
2.30.2
[tip: sched/core] sched: dynamic: Make PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY
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: d3d16750693b540299cd105968174556012aba09 Gitweb: https://git.kernel.org/tip/d3d16750693b540299cd105968174556012aba09 Author: Mark Rutland <[email protected]> AuthorDate: Mon, 03 Aug 2026 20:17:26 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Wed, 02 Sep 2026 09:37:22 +02:00
sched: dynamic: Make PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY
On architectures which select ARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since commit:
7dadeaa6e851 ("sched: Further restrict the preemption modes")
... which was merged in v7.0.
All architectures which currently support PREEMPT_DYNAMIC select ARCH_HAS_PREEMPT_LAZY:
[mark@lakrids:~/src/linux]% git describe HEAD v7.2-rc1-1-g871a4586ea2e1
[mark@lakrids:~/src/linux]% git grep 'select HAVE_PREEMPT_DYNAMIC_' -- arch
arch/arm64/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY
arch/loongarch/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY
arch/powerpc/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY arch/riscv/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY arch/s390/Kconfig: select HAVE_PREEMPT_DYNAMIC_KEY arch/x86/Kconfig: select HAVE_PREEMPT_DYNAMIC_CALL [mark@lakrids:~/src/linux]% git grep 'select ARCH_HAS_PREEMPT_LAZY' -- arch arch/arm64/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/loongarch/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/powerpc/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/riscv/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/s390/Kconfig: select ARCH_HAS_PREEMPT_LAZY arch/x86/Kconfig: select ARCH_HAS_PREEMPT_LAZY
... and hence in practice PREEMPT_DYNAMIC no longer supports the NONE or VOLUNTARY preemption models.
Make this official: have PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY, and remove the trivially unreachable code. Further simplifications will be made in subsequent patches.
--- kernel/Kconfig.preempt | 1 +- kernel/sched/core.c | 63 +---------------------------------------- 2 files changed, 4 insertions(+), 60 deletions(-)
kernel/Kconfig.preempt +1 -0
@@ -133,6 +133,7 @@ config PREEMPTION config PREEMPT_DYNAMIC bool "Preemption behaviour defined on boot" depends on HAVE_PREEMPT_DYNAMIC + depends on ARCH_HAS_PREEMPT_LAZY select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY select PREEMPT_BUILD default y if HAVE_PREEMPT_DYNAMIC_CALL
kernel/sched/core.c +3 -60
95 lines not on this page · raw message
Mark Rutland
reviewerPATCH v2 2/6 sched: dynamic: Simplify {cond,might}_resched()
In reply to Mark RutlandPREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. In either model, both cond_resched() and might_resched() are always disabled and do nothing.
Remove the unnecessary code for these when PREEMPT_DYNAMIC is selected.
--- include/linux/kernel.h | 20 ------------------- include/linux/sched.h | 31 +++-------------------------- kernel/sched/core.c | 44 +----------------------------------------- 3 files changed, 4 insertions(+), 91 deletions(-)
include/linux/kernel.h +0 -20
@@ -43,30 +43,10 @@ struct completion;struct user ;#ifdef CONFIG_PREEMPT_VOLUNTARY_BUILD -extern int __cond_resched (void );# define might_resched () __cond_resched() - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) - -extern int __cond_resched (void ); - -DECLARE_STATIC_CALL (might_resched, __cond_resched); - -static __always_inline void might_resched(void) -{ -static_call_mod (might_resched)(); -} - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -extern int dynamic_might_resched (void ); -# define might_resched () dynamic_might_resched() -#else -# define might_resched () do { } while (0) -#endif /* CONFIG_PREEMPT_* */ #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
include/linux/sched.h +3 -28
@@ -2119,44 +2119,19 @@ static inline void set_need_resched_current(void)* value indicates whether a reschedule was done in fact. * cond_resched_lock() will drop the spinlock before scheduling, */ -#if !defined(CONFIG_PREEMPTION ) || defined(CONFIG_PREEMPT_DYNAMIC ) +#if !defined(CONFIG_PREEMPTION )extern int __cond_resched (void ); -#if defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) - -DECLARE_STATIC_CALL (cond_resched, __cond_resched); - -static __always_inline int _cond_resched(void) -{ -return static_call_mod (cond_resched)(); -} - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -extern int dynamic_cond_resched (void ); - -static __always_inline int _cond_resched(void) -{ -return dynamic_cond_resched (); -} - -#else /* !CONFIG_PREEMPTION */ -static inline int _cond_resched (void ) {return __cond_resched (); } - -#endif /* PREEMPT_DYNAMIC && CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */ - -#else /* CONFIG_PREEMPTION && !CONFIG_PREEMPT_DYNAMIC */ - +#else static inline int _cond_resched (void ) {return 0 ; } - -#endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */ +#endif #define cond_resched () ({ \ __might_resched(__FILE__, __LINE__, 0); \
kernel/sched/core.c +1 -43
86 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH v2 2/6] sched: dynamic: Simplify {cond,might}_resched()
Quoted 198 lines · Mark Rutland
PREEMPT_DYNAMICis now limited to the FULL and LAZY preemption models. In either model, bothcond_resched()andmight_resched()are always disabled and do nothing.Remove the unnecessary code for these when
PREEMPT_DYNAMICis selected.Signed-off-by Mark Rutland <[email protected]>Reviewed-by Shrikanth Hegde <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc John Stultz <[email protected]>Cc Juri Lelli <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Shrikanth Hegde <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Valentin Schneider <[email protected]>Cc Vincent Guittot <[email protected]>--- include/linux/kernel.h | 20 ------------------- include/linux/sched.h | 31 +++-------------------------- kernel/sched/core.c | 44 +----------------------------------------- 3 files changed, 4 insertions(+), 91 deletions(-)include/linux/kernel.h +0
-20@@ -43,30 +43,10 @@ struct completion;struct user ;#ifdef CONFIG_PREEMPT_VOLUNTARY_BUILD -extern int __cond_resched (void );# define might_resched () __cond_resched() - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) - -extern int __cond_resched (void ); - -DECLARE_STATIC_CALL (might_resched, __cond_resched); - -static __always_inline void might_resched(void) -{ -static_call_mod (might_resched)(); -} - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -extern int dynamic_might_resched (void ); -# define might_resched () dynamic_might_resched() -#else -# define might_resched () do { } while (0) -#endif /* CONFIG_PREEMPT_* */ #ifdef CONFIG_DEBUG_ATOMIC_SLEEP include/linux/sched.h +3
-28@@ -2119,44 +2119,19 @@ static inline void set_need_resched_current(void)* value indicates whether a reschedule was done in fact. * cond_resched_lock() will drop the spinlock before scheduling, */ -#if !defined(CONFIG_PREEMPTION ) || defined(CONFIG_PREEMPT_DYNAMIC ) +#if !defined(CONFIG_PREEMPTION )extern int __cond_resched (void ); -#if defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) - -DECLARE_STATIC_CALL (cond_resched, __cond_resched); - -static __always_inline int _cond_resched(void) -{ -return static_call_mod (cond_resched)(); -} - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -extern int dynamic_cond_resched (void ); - -static __always_inline int _cond_resched(void) -{ -return dynamic_cond_resched (); -} - -#else /* !CONFIG_PREEMPTION */ -static inline int _cond_resched (void ) {return __cond_resched (); } - -#endif /* PREEMPT_DYNAMIC && CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */ - -#else /* CONFIG_PREEMPTION && !CONFIG_PREEMPT_DYNAMIC */ - +#else static inline int _cond_resched (void ) {return 0 ; } - -#endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */ +#endif #define cond_resched () ({ \ __might_resched(__FILE__, __LINE__, 0); \kernel/sched/core.c +1
-41@@ -7733,7 +7733,7 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task) }#endif /* CONFIG_RT_MUTEXES */ -#if !defined(CONFIG_PREEMPTION ) || defined(CONFIG_PREEMPT_DYNAMIC ) +#if !defined(CONFIG_PREEMPTION ) int __sched __cond_resched(void) {if (should_resched (0 ) && !irqs_disabled ()) {@@ -7761,38 +7761,6 @@ int __sched __cond_resched(void)EXPORT_SYMBOL (__cond_resched);#endif -#ifdef CONFIG_PREEMPT_DYNAMIC -# ifdef CONFIG_HAVE_PREEMPT_DYNAMIC_CALL -# define cond_resched_dynamic_enabled __cond_resched -# define cond_resched_dynamic_disabled ((void *)&__static_call_return0) -DEFINE_STATIC_CALL_RET0 (cond_resched, __cond_resched); -EXPORT_STATIC_CALL_TRAMP (cond_resched); - -# define might_resched_dynamic_enabled __cond_resched -# define might_resched_dynamic_disabled ((void *)&__static_call_return0) -DEFINE_STATIC_CALL_RET0 (might_resched, __cond_resched); -EXPORT_STATIC_CALL_TRAMP (might_resched); -# elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) -static DEFINE_STATIC_KEY_FALSE (sk_dynamic_cond_resched); -int __sched dynamic_cond_resched(void) -{ -if (!static_branch_unlikely (&sk_dynamic_cond_resched)) -return 0 ; -return __cond_resched (); -} -EXPORT_SYMBOL (dynamic_cond_resched); - -static DEFINE_STATIC_KEY_FALSE (sk_dynamic_might_resched); -int __sched dynamic_might_resched(void) -{ -if (!static_branch_unlikely (&sk_dynamic_might_resched)) -return 0 ; -return __cond_resched (); -} -EXPORT_SYMBOL (dynamic_might_resched); -# endif -#endif /* CONFIG_PREEMPT_DYNAMIC */ -/* * __cond_resched_lock() - if a reschedule is pending, drop the given lock, * call schedule, and on return reacquire the lock. @@ -7862,8 +7830,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);# endif /* -* SC:cond_resched -* SC:might_resched * SC:preempt_schedule * SC:preempt_schedule_notrace * SC:irqentry_exit_cond_resched @@ -7876,16 +7842,12 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);* (unselectable) * * FULL: -* cond_resched <- RET0 -* might_resched <- RET0 * preempt_schedule <- preempt_schedule * preempt_schedule_notrace <- preempt_schedule_notrace * irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- false * * LAZY: -* cond_resched <- RET0 -* might_resched <- RET0 * preempt_schedule <- preempt_schedule * preempt_schedule_notrace <- preempt_schedule_notrace * irqentry_exit_cond_resched <- irqentry_exit_cond_resched @@ -7932,8 +7894,6 @@ static void __sched_dynamic_update(int mode) {switch (mode) {case preempt_dynamic_full: -preempt_dynamic_disable (cond_resched); -preempt_dynamic_disable (might_resched);preempt_dynamic_enable (preempt_schedule);preempt_dynamic_enable (preempt_schedule_notrace);preempt_dynamic_enable (irqentry_exit_cond_resched);
kernel/sched/core.c static void __sched_dynamic_update(int mode) · line 7947
Quoted 5 lines
kernel/sched/core.c +0
-2@@ -7943,8 +7903,6 @@ static void __sched_dynamic_update(int mode)break ;case preempt_dynamic_lazy: -preempt_dynamic_disable (cond_resched); -preempt_dynamic_disable (might_resched);
Quoted 3 lines
kernel/sched/core.c +0
-0preempt_dynamic_enable (preempt_schedule);preempt_dynamic_enable (preempt_schedule_notrace);preempt_dynamic_enable (irqentry_exit_cond_resched);
[tip: sched/core] sched: dynamic: Simplify {cond,might}_resched()
In reply to Mark RutlandThe 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: 88e0b3bb9930605ad7e5d3ddac7d9875325bebf0 Gitweb: https://git.kernel.org/tip/88e0b3bb9930605ad7e5d3ddac7d9875325bebf0 Author: Mark Rutland <[email protected]> AuthorDate: Mon, 03 Aug 2026 20:17:27 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Wed, 02 Sep 2026 09:37:22 +02:00
sched: dynamic: Simplify {cond,might}_resched()
PREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. In either model, both cond_resched() and might_resched() are always disabled and do nothing.
Remove the unnecessary code for these when PREEMPT_DYNAMIC is selected.
--- include/linux/kernel.h | 20 +------------------- include/linux/sched.h | 31 ++--------------------------- kernel/sched/core.c | 44 +----------------------------------------- 3 files changed, 4 insertions(+), 91 deletions(-)
include/linux/kernel.h +0 -20
@@ -43,30 +43,10 @@ struct completion;struct user ;#ifdef CONFIG_PREEMPT_VOLUNTARY_BUILD -extern int __cond_resched (void );# define might_resched () __cond_resched() - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) - -extern int __cond_resched (void ); - -DECLARE_STATIC_CALL (might_resched, __cond_resched); - -static __always_inline void might_resched(void) -{ -static_call_mod (might_resched)(); -} - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -extern int dynamic_might_resched (void ); -# define might_resched () dynamic_might_resched() -#else -# define might_resched () do { } while (0) -#endif /* CONFIG_PREEMPT_* */ #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
include/linux/sched.h +3 -28
@@ -2134,44 +2134,19 @@ static inline void set_need_resched_current(void)* value indicates whether a reschedule was done in fact. * cond_resched_lock() will drop the spinlock before scheduling, */ -#if !defined(CONFIG_PREEMPTION ) || defined(CONFIG_PREEMPT_DYNAMIC ) +#if !defined(CONFIG_PREEMPTION )extern int __cond_resched (void ); -#if defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) - -DECLARE_STATIC_CALL (cond_resched, __cond_resched); - -static __always_inline int _cond_resched(void) -{ -return static_call_mod (cond_resched)(); -} - -#elif defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -extern int dynamic_cond_resched (void ); - -static __always_inline int _cond_resched(void) -{ -return dynamic_cond_resched (); -} - -#else /* !CONFIG_PREEMPTION */ -static inline int _cond_resched (void ) {return __cond_resched (); } - -#endif /* PREEMPT_DYNAMIC && CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */ - -#else /* CONFIG_PREEMPTION && !CONFIG_PREEMPT_DYNAMIC */ - +#else static inline int _cond_resched (void ) {return 0 ; } - -#endif /* !CONFIG_PREEMPTION || CONFIG_PREEMPT_DYNAMIC */ +#endif #define cond_resched () ({ \ __might_resched(__FILE__, __LINE__, 0); \
kernel/sched/core.c +1 -43
86 lines not on this page · raw message
Mark Rutland
reviewerPATCH v2 3/6 sched: dynamic: Simplify preempt_schedule{,_notrace}()
In reply to Mark RutlandPREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. In either model, both preempt_schedule() and preempt_schedule_notrace() are always called and never disabled.
Remove the unnecessary code for these when PREEMPT_DYNAMIC is selected.
--- arch/arm64/include/asm/preempt.h | 10 ------ arch/s390/include/asm/preempt.h | 11 ------- arch/x86/include/asm/preempt.h | 28 ----------------- include/asm-generic/preempt.h | 10 ------ kernel/sched/core.c | 52 -------------------------------- 5 files changed, 111 deletions(-)
arch/arm64/include/asm/preempt.h +0 -10
@@ -84,19 +84,9 @@ static inline bool should_resched(int preempt_offset)void preempt_schedule (void );void preempt_schedule_notrace (void ); -#ifdef CONFIG_PREEMPT_DYNAMIC - -void dynamic_preempt_schedule (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace() -#endif /* CONFIG_PREEMPT_DYNAMIC */ #endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */
arch/s390/include/asm/preempt.h +0 -11
@@ -148,20 +148,9 @@ static __always_inline bool should_resched(int preempt_offset)void preempt_schedule (void );void preempt_schedule_notrace (void ); -#ifdef CONFIG_PREEMPT_DYNAMIC - -void dynamic_preempt_schedule (void ); -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace() -#endif /* CONFIG_PREEMPT_DYNAMIC */ -#endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */
arch/x86/include/asm/preempt.h +0 -28
@@ -109,43 +109,15 @@ static __always_inline bool should_resched(int preempt_offset) extern asmlinkage void preempt_schedule(void); extern asmlinkage void preempt_schedule_thunk(void); -#define preempt_schedule_dynamic_enabled preempt_schedule_thunk -#define preempt_schedule_dynamic_disabled NULL - extern asmlinkage void preempt_schedule_notrace(void); extern asmlinkage void preempt_schedule_notrace_thunk(void); -#define preempt_schedule_notrace_dynamic_enabled preempt_schedule_notrace_thunk -#define preempt_schedule_notrace_dynamic_disabled NULL - -#ifdef CONFIG_PREEMPT_DYNAMIC - -DECLARE_STATIC_CALL (preempt_schedule, preempt_schedule_dynamic_enabled); - -#define __preempt_schedule () \ -do { \ - __STATIC_CALL_MOD_ADDRESSABLE(preempt_schedule); \ - asm volatile ("call " STATIC_CALL_TRAMP_STR(preempt_schedule) : ASM_CALL_CONSTRAINT); \ -} while (0) - -DECLARE_STATIC_CALL (preempt_schedule_notrace, preempt_schedule_notrace_dynamic_enabled); - -#define __preempt_schedule_notrace () \ -do { \ - __STATIC_CALL_MOD_ADDRESSABLE(preempt_schedule_notrace); \ - asm volatile ("call " STATIC_CALL_TRAMP_STR(preempt_schedule_notrace) : ASM_CALL_CONSTRAINT); \ -} while (0) - -#else /* PREEMPT_DYNAMIC */ -#define __preempt_schedule () \ asm volatile ("call preempt_schedule_thunk" : ASM_CALL_CONSTRAINT);#define __preempt_schedule_notrace () \ asm volatile ("call preempt_schedule_notrace_thunk" : ASM_CALL_CONSTRAINT); -#endif /* PREEMPT_DYNAMIC */ -#endif /* PREEMPTION */ #endif /* __ASM_PREEMPT_H */
include/asm-generic/preempt.h +0 -10
@@ -82,19 +82,9 @@ static __always_inline bool should_resched(int preempt_offset) extern asmlinkage void preempt_schedule(void); extern asmlinkage void preempt_schedule_notrace(void); -#if defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -void dynamic_preempt_schedule (void ); -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_HAVE_PREEMPT_DYNAMIC_KEY*/ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace() -#endif /* CONFIG_PREEMPT_DYNAMIC && CONFIG_HAVE_PREEMPT_DYNAMIC_KEY*/ #endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */
kernel/sched/core.c +0 -52
92 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH v2 3/6] sched: dynamic: Simplify preempt_schedule{,_notrace}()
Quoted 34 lines · Mark Rutland
PREEMPT_DYNAMICis now limited to the FULL and LAZY preemption models. In either model, bothpreempt_schedule()andpreempt_schedule_notrace()are always called and never disabled.Remove the unnecessary code for these when
PREEMPT_DYNAMICis selected.Signed-off-by Mark Rutland <[email protected]>Reviewed-by Shrikanth Hegde <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc John Stultz <[email protected]>Cc Juri Lelli <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Shrikanth Hegde <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Valentin Schneider <[email protected]>Cc Vincent Guittot <[email protected]>--- arch/arm64/include/asm/preempt.h | 10 ------ arch/s390/include/asm/preempt.h | 11 ------- arch/x86/include/asm/preempt.h | 28 ----------------- include/asm-generic/preempt.h | 10 ------ kernel/sched/core.c | 52 -------------------------------- 5 files changed, 111 deletions(-)arch/arm64/include/asm/preempt.h +0
-1@@ -84,19 +84,9 @@ static inline bool should_resched(int preempt_offset)void preempt_schedule (void );void preempt_schedule_notrace (void ); -#ifdef CONFIG_PREEMPT_DYNAMIC
arch/arm64/include/asm/preempt.h static inline bool should_resched(int preempt_offset) · line 88
Quoted 10 lines
arch/arm64/include/asm/preempt.h +0
-8- -void dynamic_preempt_schedule (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace()
In both full and lazy modes for PREEMPT_DYNAMIC , "preempt_schedule" and "preempt_schedule_notrace" are enabled. Therefore, dynamic switching is not required. we can directly invoke preempt_schedule[_notrace]().
LGTM
Quoted 204 lines
arch/arm64/include/asm/preempt.h +0
-1-#endif /* CONFIG_PREEMPT_DYNAMIC */ #endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */ arch/s390/include/asm/preempt.h +0
-11@@ -148,20 +148,9 @@ static __always_inline bool should_resched(int preempt_offset)void preempt_schedule (void );void preempt_schedule_notrace (void ); -#ifdef CONFIG_PREEMPT_DYNAMIC - -void dynamic_preempt_schedule (void ); -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace() -#endif /* CONFIG_PREEMPT_DYNAMIC */ -#endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */ arch/x86/include/asm/preempt.h +0
-28@@ -109,43 +109,15 @@ static __always_inline bool should_resched(int preempt_offset) extern asmlinkage void preempt_schedule(void); extern asmlinkage void preempt_schedule_thunk(void); -#define preempt_schedule_dynamic_enabled preempt_schedule_thunk -#define preempt_schedule_dynamic_disabled NULL - extern asmlinkage void preempt_schedule_notrace(void); extern asmlinkage void preempt_schedule_notrace_thunk(void); -#define preempt_schedule_notrace_dynamic_enabled preempt_schedule_notrace_thunk -#define preempt_schedule_notrace_dynamic_disabled NULL - -#ifdef CONFIG_PREEMPT_DYNAMIC - -DECLARE_STATIC_CALL (preempt_schedule, preempt_schedule_dynamic_enabled); - -#define __preempt_schedule () \ -do { \ - __STATIC_CALL_MOD_ADDRESSABLE(preempt_schedule); \ - asm volatile ("call " STATIC_CALL_TRAMP_STR(preempt_schedule) : ASM_CALL_CONSTRAINT); \ -} while (0) - -DECLARE_STATIC_CALL (preempt_schedule_notrace, preempt_schedule_notrace_dynamic_enabled); - -#define __preempt_schedule_notrace () \ -do { \ - __STATIC_CALL_MOD_ADDRESSABLE(preempt_schedule_notrace); \ - asm volatile ("call " STATIC_CALL_TRAMP_STR(preempt_schedule_notrace) : ASM_CALL_CONSTRAINT); \ -} while (0) - -#else /* PREEMPT_DYNAMIC */ -#define __preempt_schedule () \ asm volatile ("call preempt_schedule_thunk" : ASM_CALL_CONSTRAINT);#define __preempt_schedule_notrace () \ asm volatile ("call preempt_schedule_notrace_thunk" : ASM_CALL_CONSTRAINT); -#endif /* PREEMPT_DYNAMIC */ -#endif /* PREEMPTION */ #endif /* __ASM_PREEMPT_H */ include/asm-generic/preempt.h +0
-10@@ -82,19 +82,9 @@ static __always_inline bool should_resched(int preempt_offset) extern asmlinkage void preempt_schedule(void); extern asmlinkage void preempt_schedule_notrace(void); -#if defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -void dynamic_preempt_schedule (void ); -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_HAVE_PREEMPT_DYNAMIC_KEY*/ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace() -#endif /* CONFIG_PREEMPT_DYNAMIC && CONFIG_HAVE_PREEMPT_DYNAMIC_KEY*/ #endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */ kernel/sched/core.c +0
-52@@ -7439,27 +7439,6 @@ asmlinkage __visible void __sched notrace preempt_schedule(void)NOKPROBE_SYMBOL (preempt_schedule);EXPORT_SYMBOL (preempt_schedule); -#ifdef CONFIG_PREEMPT_DYNAMIC -# ifdef CONFIG_HAVE_PREEMPT_DYNAMIC_CALL -# ifndef preempt_schedule_dynamic_enabled -# define preempt_schedule_dynamic_enabled preempt_schedule -# define preempt_schedule_dynamic_disabled NULL -# endif -DEFINE_STATIC_CALL (preempt_schedule, preempt_schedule_dynamic_enabled); -EXPORT_STATIC_CALL_TRAMP (preempt_schedule); -# elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) -static DEFINE_STATIC_KEY_TRUE (sk_dynamic_preempt_schedule); -void __sched notrace dynamic_preempt_schedule(void) -{ -if (!static_branch_unlikely (&sk_dynamic_preempt_schedule)) -return ; -preempt_schedule (); -} -NOKPROBE_SYMBOL (dynamic_preempt_schedule); -EXPORT_SYMBOL (dynamic_preempt_schedule); -# endif -#endif /* CONFIG_PREEMPT_DYNAMIC */ -/** * preempt_schedule_notrace - preempt_schedule called by tracing * @@ -7512,27 +7491,6 @@ asmlinkage __visible void __sched notrace preempt_schedule_notrace(void) }EXPORT_SYMBOL_GPL (preempt_schedule_notrace); -#ifdef CONFIG_PREEMPT_DYNAMIC -# if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) -# ifndef preempt_schedule_notrace_dynamic_enabled -# define preempt_schedule_notrace_dynamic_enabled preempt_schedule_notrace -# define preempt_schedule_notrace_dynamic_disabled NULL -# endif -DEFINE_STATIC_CALL (preempt_schedule_notrace, preempt_schedule_notrace_dynamic_enabled); -EXPORT_STATIC_CALL_TRAMP (preempt_schedule_notrace); -# elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) -static DEFINE_STATIC_KEY_TRUE (sk_dynamic_preempt_schedule_notrace); -void __sched notrace dynamic_preempt_schedule_notrace(void) -{ -if (!static_branch_unlikely (&sk_dynamic_preempt_schedule_notrace)) -return ; -preempt_schedule_notrace (); -} -NOKPROBE_SYMBOL (dynamic_preempt_schedule_notrace); -EXPORT_SYMBOL (dynamic_preempt_schedule_notrace); -# endif -#endif -#endif /* CONFIG_PREEMPTION */ /* @@ -7830,8 +7788,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);# endif /* -* SC:preempt_schedule -* SC:preempt_schedule_notrace * SC:irqentry_exit_cond_resched * * @@ -7842,14 +7798,10 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);* (unselectable) * * FULL: -* preempt_schedule <- preempt_schedule -* preempt_schedule_notrace <- preempt_schedule_notrace * irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- false * * LAZY: -* preempt_schedule <- preempt_schedule -* preempt_schedule_notrace <- preempt_schedule_notrace * irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- true */ @@ -7894,8 +7846,6 @@ static void __sched_dynamic_update(int mode) {switch (mode) {case preempt_dynamic_full: -preempt_dynamic_enable (preempt_schedule); -preempt_dynamic_enable (preempt_schedule_notrace);preempt_dynamic_enable (irqentry_exit_cond_resched);preempt_dynamic_key_disable (preempt_lazy);if (mode != preempt_dynamic_mode)@@ -7903,8 +7853,6 @@ static void __sched_dynamic_update(int mode)break ;case preempt_dynamic_lazy: -preempt_dynamic_enable (preempt_schedule); -preempt_dynamic_enable (preempt_schedule_notrace);preempt_dynamic_enable (irqentry_exit_cond_resched);preempt_dynamic_key_enable (preempt_lazy);if (mode != preempt_dynamic_mode)
[tip: sched/core] sched: dynamic: Simplify preempt_schedule{,_notrace}()
In reply to Mark RutlandThe 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: b9d267b9d632feec9ddd1ce12078b7113f429a51 Gitweb: https://git.kernel.org/tip/b9d267b9d632feec9ddd1ce12078b7113f429a51 Author: Mark Rutland <[email protected]> AuthorDate: Mon, 03 Aug 2026 20:17:28 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Wed, 02 Sep 2026 09:37:22 +02:00
sched: dynamic: Simplify preempt_schedule{,_notrace}()
PREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. In either model, both preempt_schedule() and preempt_schedule_notrace() are always called and never disabled.
Remove the unnecessary code for these when PREEMPT_DYNAMIC is selected.
--- arch/arm64/include/asm/preempt.h | 10 +------ arch/s390/include/asm/preempt.h | 11 +------- arch/x86/include/asm/preempt.h | 28 +----------------- include/asm-generic/preempt.h | 10 +------ kernel/sched/core.c | 52 +------------------------------- 5 files changed, 111 deletions(-)
arch/arm64/include/asm/preempt.h +0 -10
@@ -104,19 +104,9 @@ static inline bool should_resched(int preempt_offset)void preempt_schedule (void );void preempt_schedule_notrace (void ); -#ifdef CONFIG_PREEMPT_DYNAMIC - -void dynamic_preempt_schedule (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace() -#endif /* CONFIG_PREEMPT_DYNAMIC */ #endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */
arch/s390/include/asm/preempt.h +0 -11
@@ -155,20 +155,9 @@ static __always_inline int __preempt_count_sub_return(int val)void preempt_schedule (void );void preempt_schedule_notrace (void ); -#ifdef CONFIG_PREEMPT_DYNAMIC - -void dynamic_preempt_schedule (void ); -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace() -#endif /* CONFIG_PREEMPT_DYNAMIC */ -#endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */
arch/x86/include/asm/preempt.h +0 -28
@@ -137,43 +137,15 @@ static __always_inline bool should_resched(int preempt_offset) extern asmlinkage void preempt_schedule(void); extern asmlinkage void preempt_schedule_thunk(void); -#define preempt_schedule_dynamic_enabled preempt_schedule_thunk -#define preempt_schedule_dynamic_disabled NULL - extern asmlinkage void preempt_schedule_notrace(void); extern asmlinkage void preempt_schedule_notrace_thunk(void); -#define preempt_schedule_notrace_dynamic_enabled preempt_schedule_notrace_thunk -#define preempt_schedule_notrace_dynamic_disabled NULL - -#ifdef CONFIG_PREEMPT_DYNAMIC - -DECLARE_STATIC_CALL (preempt_schedule, preempt_schedule_dynamic_enabled); - -#define __preempt_schedule () \ -do { \ - __STATIC_CALL_MOD_ADDRESSABLE(preempt_schedule); \ - asm volatile ("call " STATIC_CALL_TRAMP_STR(preempt_schedule) : ASM_CALL_CONSTRAINT); \ -} while (0) - -DECLARE_STATIC_CALL (preempt_schedule_notrace, preempt_schedule_notrace_dynamic_enabled); - -#define __preempt_schedule_notrace () \ -do { \ - __STATIC_CALL_MOD_ADDRESSABLE(preempt_schedule_notrace); \ - asm volatile ("call " STATIC_CALL_TRAMP_STR(preempt_schedule_notrace) : ASM_CALL_CONSTRAINT); \ -} while (0) - -#else /* PREEMPT_DYNAMIC */ -#define __preempt_schedule () \ asm volatile ("call preempt_schedule_thunk" : ASM_CALL_CONSTRAINT);#define __preempt_schedule_notrace () \ asm volatile ("call preempt_schedule_notrace_thunk" : ASM_CALL_CONSTRAINT); -#endif /* PREEMPT_DYNAMIC */ -#endif /* PREEMPTION */ #undef __pc_op
include/asm-generic/preempt.h +0 -10
@@ -96,19 +96,9 @@ static __always_inline bool should_resched(int preempt_offset) extern asmlinkage void preempt_schedule(void); extern asmlinkage void preempt_schedule_notrace(void); -#if defined(CONFIG_PREEMPT_DYNAMIC ) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) - -void dynamic_preempt_schedule (void ); -void dynamic_preempt_schedule_notrace (void ); -#define __preempt_schedule () dynamic_preempt_schedule() -#define __preempt_schedule_notrace () dynamic_preempt_schedule_notrace() - -#else /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_HAVE_PREEMPT_DYNAMIC_KEY*/ -#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace() -#endif /* CONFIG_PREEMPT_DYNAMIC && CONFIG_HAVE_PREEMPT_DYNAMIC_KEY*/ #endif /* CONFIG_PREEMPTION */ #endif /* __ASM_PREEMPT_H */
kernel/sched/core.c +0 -52
92 lines not on this page · raw message
Mark Rutland
reviewerPATCH v2 4/6 sched: dynamic: Simplify irqentry_exit_cond_resched()
In reply to Mark RutlandPREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. In either model, irqentry_exit_cond_resched() is always called and never disabled.
Remove the unnecessary code for this when PREEMPT_DYNAMIC is selected.
--- include/linux/irq-entry-common.h | 17 +---------------- kernel/entry/common.c | 17 ++--------------- kernel/sched/core.c | 7 ------- 3 files changed, 3 insertions(+), 38 deletions(-)
include/linux/irq-entry-common.h +1 -16
@@ -346,22 +346,7 @@ typedef struct irqentry_state {* * Conditional reschedule with additional sanity checks. */ -void raw_irqentry_exit_cond_resched (void ); - -#ifdef CONFIG_PREEMPT_DYNAMIC -#if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) -#define irqentry_exit_cond_resched_dynamic_enabled raw_irqentry_exit_cond_resched -#define irqentry_exit_cond_resched_dynamic_disabled NULL -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 -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define irqentry_exit_cond_resched () raw_irqentry_exit_cond_resched() -#endif /* CONFIG_PREEMPT_DYNAMIC */ +void irqentry_exit_cond_resched (void );/** * irqentry_enter_from_kernel_mode - Establish state before invoking the irq handler
kernel/entry/common.c +2 -15
@@ -123,7 +123,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)/** * arch_irqentry_exit_need_resched - Architecture specific need resched function * -* Invoked from raw_irqentry_exit_cond_resched() to check if resched is needed. +* Invoked from irqentry_exit_cond_resched() to check if resched is needed. * Defaults return true. * * The main purpose is to permit arch to avoid preemption of a task from an IRQ.
@@ -134,7 +134,7 @@ static inline bool arch_irqentry_exit_need_resched(void);static inline bool arch_irqentry_exit_need_resched (void ) {return true; }#endif -void raw_irqentry_exit_cond_resched (void ) +void irqentry_exit_cond_resched (void ) {if (!preempt_count ()) {/* Sanity check RCU and thread stack */
@@ -145,19 +145,6 @@ void raw_irqentry_exit_cond_resched(void)preempt_schedule_irq (); } } -#ifdef CONFIG_PREEMPT_DYNAMIC -#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)) -return ; -raw_irqentry_exit_cond_resched (); -} -#endif -#endif noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) {
kernel/sched/core.c +0 -7
@@ -7788,9 +7788,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);# endif /* -* SC:irqentry_exit_cond_resched -* -* * NONE: * (unselectable) *
@@ -7798,11 +7795,9 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);* (unselectable) * * FULL: -* irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- false * * LAZY: -* irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- true */
@@ -7846,14 +7841,12 @@ static void __sched_dynamic_update(int mode) {switch (mode) {case preempt_dynamic_full: -preempt_dynamic_enable (irqentry_exit_cond_resched);preempt_dynamic_key_disable (preempt_lazy);if (mode != preempt_dynamic_mode)pr_info ("Dynamic Preempt: full\n" );break ;case preempt_dynamic_lazy: -preempt_dynamic_enable (irqentry_exit_cond_resched);preempt_dynamic_key_enable (preempt_lazy);if (mode != preempt_dynamic_mode)pr_info ("Dynamic Preempt: lazy\n" );
Signature · 1 line
2.30.2
Re: [PATCH v2 4/6] sched: dynamic: Simplify irqentry_exit_cond_resched()
Quoted 3 lines · Mark Rutland
PREEMPT_DYNAMICis now limited to the FULL and LAZY preemption models. In either model,irqentry_exit_cond_resched()is always called and never disabled.
Hi Mark,
Is it necessary to mention that all architectures supporting generic irq entry support PREEMPT_DYNAMIC?
Quoted 71 lines
Remove the unnecessary code for this when
PREEMPT_DYNAMICis selected.Signed-off-by Mark Rutland <[email protected]>Reviewed-by Shrikanth Hegde <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc John Stultz <[email protected]>Cc Juri Lelli <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Shrikanth Hegde <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Valentin Schneider <[email protected]>Cc Vincent Guittot <[email protected]>--- include/linux/irq-entry-common.h | 17 +---------------- kernel/entry/common.c | 17 ++--------------- kernel/sched/core.c | 7 ------- 3 files changed, 3 insertions(+), 38 deletions(-)include/linux/irq-entry-common.h +1
-16@@ -346,22 +346,7 @@ typedef struct irqentry_state {* * Conditional reschedule with additional sanity checks. */ -void raw_irqentry_exit_cond_resched (void ); - -#ifdef CONFIG_PREEMPT_DYNAMIC -#if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) -#define irqentry_exit_cond_resched_dynamic_enabled raw_irqentry_exit_cond_resched -#define irqentry_exit_cond_resched_dynamic_disabled NULL -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 -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define irqentry_exit_cond_resched () raw_irqentry_exit_cond_resched() -#endif /* CONFIG_PREEMPT_DYNAMIC */ +void irqentry_exit_cond_resched (void );/** * irqentry_enter_from_kernel_mode - Establish state before invoking the irq handler kernel/entry/common.c +2
-2@@ -123,7 +123,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)/** * arch_irqentry_exit_need_resched - Architecture specific need resched function * -* Invoked from raw_irqentry_exit_cond_resched() to check if resched is needed. +* Invoked from irqentry_exit_cond_resched() to check if resched is needed. * Defaults return true. * * The main purpose is to permit arch to avoid preemption of a task from an IRQ. @@ -134,7 +134,7 @@ static inline bool arch_irqentry_exit_need_resched(void);static inline bool arch_irqentry_exit_need_resched (void ) {return true; }#endif -void raw_irqentry_exit_cond_resched (void ) +void irqentry_exit_cond_resched (void ) {if (!preempt_count ()) {/* Sanity check RCU and thread stack */
kernel/entry/common.c void raw_irqentry_exit_cond_resched(void) · line 147
Quoted 3 lines
kernel/entry/common.c +0
-0@@ -145,19 +145,6 @@ void raw_irqentry_exit_cond_resched(void)preempt_schedule_irq (); } }
Otherwise, LGTM
Quoted 57 lines
kernel/entry/common.c +0
-13-#ifdef CONFIG_PREEMPT_DYNAMIC -#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)) -return ; -raw_irqentry_exit_cond_resched (); -} -#endif -#endif noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) {kernel/sched/core.c +0
-7@@ -7788,9 +7788,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);# endif /* -* SC:irqentry_exit_cond_resched -* -* * NONE: * (unselectable) * @@ -7798,11 +7795,9 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);* (unselectable) * * FULL: -* irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- false * * LAZY: -* irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- true */ @@ -7846,14 +7841,12 @@ static void __sched_dynamic_update(int mode) {switch (mode) {case preempt_dynamic_full: -preempt_dynamic_enable (irqentry_exit_cond_resched);preempt_dynamic_key_disable (preempt_lazy);if (mode != preempt_dynamic_mode)pr_info ("Dynamic Preempt: full\n" );break ;case preempt_dynamic_lazy: -preempt_dynamic_enable (irqentry_exit_cond_resched);preempt_dynamic_key_enable (preempt_lazy);if (mode != preempt_dynamic_mode)pr_info ("Dynamic Preempt: lazy\n" );
[tip: sched/core] sched: dynamic: Simplify irqentry_exit_cond_resched()
In reply to Mark RutlandThe 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: aa4178f63847f86e3b27b9e53ee8ccbd6ed6bf8c Gitweb: https://git.kernel.org/tip/aa4178f63847f86e3b27b9e53ee8ccbd6ed6bf8c Author: Mark Rutland <[email protected]> AuthorDate: Mon, 03 Aug 2026 20:17:29 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Wed, 02 Sep 2026 09:37:23 +02:00
sched: dynamic: Simplify irqentry_exit_cond_resched()
PREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. In either model, irqentry_exit_cond_resched() is always called and never disabled.
Remove the unnecessary code for this when PREEMPT_DYNAMIC is selected.
--- include/linux/irq-entry-common.h | 17 +---------------- kernel/entry/common.c | 17 ++--------------- kernel/sched/core.c | 7 ------- 3 files changed, 3 insertions(+), 38 deletions(-)
include/linux/irq-entry-common.h +1 -16
@@ -346,22 +346,7 @@ typedef struct irqentry_state {* * Conditional reschedule with additional sanity checks. */ -void raw_irqentry_exit_cond_resched (void ); - -#ifdef CONFIG_PREEMPT_DYNAMIC -#if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) -#define irqentry_exit_cond_resched_dynamic_enabled raw_irqentry_exit_cond_resched -#define irqentry_exit_cond_resched_dynamic_disabled NULL -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 -#else /* CONFIG_PREEMPT_DYNAMIC */ -#define irqentry_exit_cond_resched () raw_irqentry_exit_cond_resched() -#endif /* CONFIG_PREEMPT_DYNAMIC */ +void irqentry_exit_cond_resched (void );/** * irqentry_enter_from_kernel_mode - Establish state before invoking the irq handler
kernel/entry/common.c +2 -15
@@ -123,7 +123,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)/** * arch_irqentry_exit_need_resched - Architecture specific need resched function * -* Invoked from raw_irqentry_exit_cond_resched() to check if resched is needed. +* Invoked from irqentry_exit_cond_resched() to check if resched is needed. * Defaults return true. * * The main purpose is to permit arch to avoid preemption of a task from an IRQ.
@@ -134,7 +134,7 @@ static inline bool arch_irqentry_exit_need_resched(void);static inline bool arch_irqentry_exit_need_resched (void ) {return true; }#endif -void raw_irqentry_exit_cond_resched (void ) +void irqentry_exit_cond_resched (void ) {if (!preempt_count ()) {/* Sanity check RCU and thread stack */
@@ -145,19 +145,6 @@ void raw_irqentry_exit_cond_resched(void)preempt_schedule_irq (); } } -#ifdef CONFIG_PREEMPT_DYNAMIC -#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)) -return ; -raw_irqentry_exit_cond_resched (); -} -#endif -#endif noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state) {
kernel/sched/core.c +0 -7
@@ -7849,9 +7849,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);# endif /* -* SC:irqentry_exit_cond_resched -* -* * NONE: * (unselectable) *
@@ -7859,11 +7856,9 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);* (unselectable) * * FULL: -* irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- false * * LAZY: -* irqentry_exit_cond_resched <- irqentry_exit_cond_resched * dynamic_preempt_lazy <- true */
@@ -7907,14 +7902,12 @@ static void __sched_dynamic_update(int mode) {switch (mode) {case preempt_dynamic_full: -preempt_dynamic_enable (irqentry_exit_cond_resched);preempt_dynamic_key_disable (preempt_lazy);if (mode != preempt_dynamic_mode)pr_info ("Dynamic Preempt: full\n" );break ;case preempt_dynamic_lazy: -preempt_dynamic_enable (irqentry_exit_cond_resched);preempt_dynamic_key_enable (preempt_lazy);if (mode != preempt_dynamic_mode)pr_info ("Dynamic Preempt: lazy\n" );
Mark Rutland
reviewerPATCH v2 5/6 sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
In reply to Mark RutlandPREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. Switching model only changes the behaviour of dynamic_preempt_lazy(), which uses a static key. There are no other static calls or static keys, and so there's no need for HAVE_PREEMPT_DYNAMIC_CALL or HAVE_PREEMPT_DYNAMIC_KEY.
The static key used by dynamic_preempt_lazy() is entirely local to kernel/sched/core.c, and any architecture which selects ARCH_HAS_PREEMPT_LAZY implements the necessary support. Remove PREEMPT_DYNAMIC's dependencies on HAVE_PREEMPT_DYNAMIC_CALL and HAVE_PREEMPT_DYNAMIC_KEY entirely, leaving the dependency on ARCH_HAS_PREEMPT_LAZY.
For architectures which previously selected HAVE_PREEMPT_DYNAMIC_KEY, PREEMPT_DYNAMIC will now be selected by default, matching x86. As the runtime impact is limited to dynamic_preempt_lazy(), this shouldn't be as concerning as previously (e.g. where calls to {cond,might}_resched() stubs could introduce a measurable penalty).
As all of this can work without jump labels, JUMP_LABEL is not selected explicitly. It is obviously preferable to have JUMP_LABEL enabled, but this is not functionally necessary.
--- arch/Kconfig | 38 -------------------------------------- arch/arm64/Kconfig | 1 - arch/loongarch/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/x86/Kconfig | 1 - kernel/Kconfig.preempt | 8 ++------ kernel/sched/core.c | 10 ---------- 9 files changed, 2 insertions(+), 60 deletions(-)
arch/Kconfig +0 -38
@@ -1696,44 +1696,6 @@ config HAVE_STATIC_CALL_INLINE depends on HAVE_STATIC_CALL select OBJTOOL -config HAVE_PREEMPT_DYNAMIC - bool - -config HAVE_PREEMPT_DYNAMIC_CALL - bool - depends on HAVE_STATIC_CALL - select HAVE_PREEMPT_DYNAMIC - help - An architecture should select this if it can handle the preemption - model being selected at boot time using static calls. - - Where an architecture selects HAVE_STATIC_CALL_INLINE, any call to a - preemption function will be patched directly. - - Where an architecture does not select HAVE_STATIC_CALL_INLINE, any - call to a preemption function will go through a trampoline, and the - trampoline will be patched. - - It is strongly advised to support inline static call to avoid any - overhead. - -config HAVE_PREEMPT_DYNAMIC_KEY - bool - depends on HAVE_ARCH_JUMP_LABEL - select HAVE_PREEMPT_DYNAMIC - help - An architecture should select this if it can handle the preemption - model being selected at boot time using static keys. - - Each preemption function will be given an early return based on a - static key. This should have slightly lower overhead than non-inline - static calls, as this effectively inlines each trampoline into the - start of its callee. This may avoid redundant work, and may - integrate better with CFI schemes. - - This will have greater overhead than using inline static calls as - the call to the preemption function cannot be entirely elided. - config ARCH_WANT_LD_ORPHAN_WARN bool help
arch/arm64/Kconfig +0 -1
@@ -216,7 +216,6 @@ config ARM64 select HAVE_PERF_EVENTS_NMI if ARM64_PSEUDO_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_POSIX_CPU_TIMERS_TASK_WORK
arch/loongarch/Kconfig +0 -1
@@ -170,7 +170,6 @@ config LOONGARCH select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC select HAVE_RETHOOK
arch/powerpc/Kconfig +0 -1
@@ -280,7 +280,6 @@ config PPC select HAVE_PERF_EVENTS_NMI if PPC64 select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_RETHOOK if KPROBES select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE
arch/riscv/Kconfig +0 -1
@@ -193,7 +193,6 @@ config RISCV select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RETHOOK select HAVE_RSEQ
arch/s390/Kconfig +0 -1
@@ -239,7 +239,6 @@ config S390 select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_RETHOOK
arch/x86/Kconfig +0 -1
@@ -294,7 +294,6 @@ config X86 select HAVE_STACK_VALIDATION if HAVE_OBJTOOL select HAVE_STATIC_CALL select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL - select HAVE_PREEMPT_DYNAMIC_CALL select HAVE_RSEQ select HAVE_RUST if X86_64 select HAVE_SYSCALL_TRACEPOINTS
kernel/Kconfig.preempt +2 -6
@@ -128,11 +128,9 @@ config PREEMPTION config PREEMPT_DYNAMIC bool "Preemption behaviour defined on boot" - depends on HAVE_PREEMPT_DYNAMIC depends on ARCH_HAS_PREEMPT_LAZY - select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY select PREEMPT_BUILD - default y if HAVE_PREEMPT_DYNAMIC_CALL + default y help This option allows to define the preemption model on the kernel command line parameter and thus override the default preemption
@@ -142,9 +140,7 @@ config PREEMPT_DYNAMIC provide a pre-built kernel binary to reduce the number of kernel flavors they offer while still offering different usecases. - The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled - but if runtime patching is not available for the specific architecture - then the potential overhead should be considered. + The runtime overhead is negligible. Interesting if you want the same pre-built kernel should be used for both Server and Desktop workloads.
kernel/sched/core.c +0 -10
@@ -7825,16 +7825,6 @@ int sched_dynamic_mode(const char *str)# define preempt_dynamic_key_enable (f) static_key_enable(&sk_dynamic_##f.key)# define preempt_dynamic_key_disable (f) static_key_disable(&sk_dynamic_##f.key) -# if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) -# define preempt_dynamic_enable (f) static_call_update(f, f##_dynamic_enabled) -# define preempt_dynamic_disable (f) static_call_update(f, f##_dynamic_disabled) -# elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) -# define preempt_dynamic_enable (f) preempt_dynamic_key_enable(f) -# define preempt_dynamic_disable (f) preempt_dynamic_key_disable(f) -# else -# error "Unsupported PREEMPT_DYNAMIC mechanism" -# endif -static DEFINE_MUTEX (sched_dynamic_mutex);static void __sched_dynamic_update (int mode)
Signature · 1 line
2.30.2
Re: [PATCH v2 5/6] sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
Quoted 81 lines · Mark Rutland
PREEMPT_DYNAMICis now limited to the FULL and LAZY preemption models. Switching model only changes the behaviour ofdynamic_preempt_lazy(), which uses a static key. There are no other static calls or static keys, and so there's no need forHAVE_PREEMPT_DYNAMIC_CALLorHAVE_PREEMPT_DYNAMIC_KEY.The static key used by
dynamic_preempt_lazy()is entirely local tokernel/sched/core.c, and any architecture which selectsARCH_HAS_PREEMPT_LAZYimplements the necessary support. Remove PREEMPT_DYNAMIC's dependencies onHAVE_PREEMPT_DYNAMIC_CALLandHAVE_PREEMPT_DYNAMIC_KEYentirely, leaving the dependency onARCH_HAS_PREEMPT_LAZY.For architectures which previously selected
HAVE_PREEMPT_DYNAMIC_KEY,PREEMPT_DYNAMICwill now be selected by default, matching x86. As the runtime impact is limited todynamic_preempt_lazy(), this shouldn't be as concerning as previously (e.g. where calls to {cond,might}_resched() stubs could introduce a measurable penalty).As all of this can work without jump labels,
JUMP_LABELis not selected explicitly. It is obviously preferable to haveJUMP_LABELenabled, but this is not functionally necessary.Signed-off-by Mark Rutland <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc John Stultz <[email protected]>Cc Juri Lelli <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Shrikanth Hegde <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Valentin Schneider <[email protected]>Cc Vincent Guittot <[email protected]>--- arch/Kconfig | 38 -------------------------------------- arch/arm64/Kconfig | 1 - arch/loongarch/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/x86/Kconfig | 1 - kernel/Kconfig.preempt | 8 ++------ kernel/sched/core.c | 10 ---------- 9 files changed, 2 insertions(+), 60 deletions(-)arch/Kconfig +0
-28@@ -1696,44 +1696,6 @@ config HAVE_STATIC_CALL_INLINE depends on HAVE_STATIC_CALL select OBJTOOL -config HAVE_PREEMPT_DYNAMIC - bool - -config HAVE_PREEMPT_DYNAMIC_CALL - bool - depends on HAVE_STATIC_CALL - select HAVE_PREEMPT_DYNAMIC - help - An architecture should select this if it can handle the preemption - model being selected at boot time using static calls. - - Where an architecture selects HAVE_STATIC_CALL_INLINE, any call to a - preemption function will be patched directly. - - Where an architecture does not select HAVE_STATIC_CALL_INLINE, any - call to a preemption function will go through a trampoline, and the - trampoline will be patched. - - It is strongly advised to support inline static call to avoid any - overhead. - -config HAVE_PREEMPT_DYNAMIC_KEY - bool - depends on HAVE_ARCH_JUMP_LABEL - select HAVE_PREEMPT_DYNAMIC - help - An architecture should select this if it can handle the preemption - model being selected at boot time using static keys.
arch/Kconfig config HAVE_STATIC_CALL_INLINE · line 1736
Quoted 10 lines
arch/Kconfig +0
-10- - Each preemption function will be given an early return based on a - static key. This should have slightly lower overhead than non-inline - static calls, as this effectively inlines each trampoline into the - start of its callee. This may avoid redundant work, and may - integrate better with CFI schemes. - - This will have greater overhead than using inline static calls as - the call to the preemption function cannot be entirely elided. -
That's in line with my expectations.
Quoted 20 lines
arch/Kconfig +0
-0config ARCH_WANT_LD_ORPHAN_WARN bool helparch/arm64/Kconfig +0
-1@@ -216,7 +216,6 @@ config ARM64 select HAVE_PERF_EVENTS_NMI if ARM64_PSEUDO_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_POSIX_CPU_TIMERS_TASK_WORKarch/loongarch/Kconfig +0
-0
arch/loongarch/Kconfig config LOONGARCH · line 173
Quoted 4 lines
arch/loongarch/Kconfig +0
-1@@ -170,7 +170,6 @@ config LOONGARCH select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY
select JUMP_LABEL?
arch/powerpc/Kconfig config PPC · line 283
Quoted 12 lines
arch/loongarch/Kconfig +0
-0select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC select HAVE_RETHOOKarch/powerpc/Kconfig +0
-1@@ -280,7 +280,6 @@ config PPC select HAVE_PERF_EVENTS_NMI if PPC64 select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP - select HAVE_PREEMPT_DYNAMIC_KEY
select JUMP_LABEL?
arch/riscv/Kconfig config RISCV · line 196
Quoted 12 lines
arch/powerpc/Kconfig +0
-0select HAVE_RETHOOK if KPROBES select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACEarch/riscv/Kconfig +0
-1@@ -193,7 +193,6 @@ config RISCV select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY
select JUMP_LABEL?
arch/s390/Kconfig config S390 · line 242
Quoted 12 lines
arch/riscv/Kconfig +0
-0select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RETHOOK select HAVE_RSEQarch/s390/Kconfig +0
-1@@ -239,7 +239,6 @@ config S390 select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY
select JUMP_LABEL?
Quoted 20 lines
arch/s390/Kconfig +0
-0select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_RETHOOKarch/x86/Kconfig +0
-1@@ -294,7 +294,6 @@ config X86 select HAVE_STACK_VALIDATION if HAVE_OBJTOOL select HAVE_STATIC_CALL select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL - select HAVE_PREEMPT_DYNAMIC_CALL select HAVE_RSEQ select HAVE_RUST if X86_64 select HAVE_SYSCALL_TRACEPOINTSkernel/Kconfig.preempt +0
-0
kernel/Kconfig.preempt config PREEMPTION · line 133
Quoted 6 lines
kernel/Kconfig.preempt +0
-2@@ -128,11 +128,9 @@ config PREEMPTION config PREEMPT_DYNAMIC bool "Preemption behaviour defined on boot" - depends on HAVE_PREEMPT_DYNAMIC depends on ARCH_HAS_PREEMPT_LAZY - select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY
After this, only the arm64 architecture explicitly selects JUMP_LABEL. When we remove the dependency on HAVE_PREEMPT_DYNAMIC_KEY, should we also select JUMP_LABEL for those architectures.
git grep "select JUMP_LABEL"
arch/arm64/Kconfig: select JUMP_LABEL block/Kconfig: select JUMP_LABEL if HAVE_ARCH_JUMP_LABEL fs/xfs/Kconfig: select JUMP_LABEL if HAVE_ARCH_JUMP_LABEL fs/xfs/Kconfig: select JUMP_LABEL if HAVE_ARCH_JUMP_LABEL
otherwise
Quoted 38 lines
kernel/Kconfig.preempt +2
-4select PREEMPT_BUILD - default y if HAVE_PREEMPT_DYNAMIC_CALL + default y help This option allows to define the preemption model on the kernel command line parameter and thus override the default preemption@@ -142,9 +140,7 @@ config PREEMPT_DYNAMIC provide a pre-built kernel binary to reduce the number of kernel flavors they offer while still offering different usecases. - The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled - but if runtime patching is not available for the specific architecture - then the potential overhead should be considered. + The runtime overhead is negligible. Interesting if you want the same pre-built kernel should be used for both Server and Desktop workloads.kernel/sched/core.c +0
-10@@ -7825,16 +7825,6 @@ int sched_dynamic_mode(const char *str)# define preempt_dynamic_key_enable (f) static_key_enable(&sk_dynamic_##f.key)# define preempt_dynamic_key_disable (f) static_key_disable(&sk_dynamic_##f.key) -# if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) -# define preempt_dynamic_enable (f) static_call_update(f, f##_dynamic_enabled) -# define preempt_dynamic_disable (f) static_call_update(f, f##_dynamic_disabled) -# elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) -# define preempt_dynamic_enable (f) preempt_dynamic_key_enable(f) -# define preempt_dynamic_disable (f) preempt_dynamic_key_disable(f) -# else -# error "Unsupported PREEMPT_DYNAMIC mechanism" -# endif -static DEFINE_MUTEX (sched_dynamic_mutex);static void __sched_dynamic_update (int mode)
Mark Rutland
reviewerRe: [PATCH v2 5/6] sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
Quoted 25 lines · Jinjie Ruan
Quoted 22 lines · Mark Rutland
PREEMPT_DYNAMICis now limited to the FULL and LAZY preemption models. Switching model only changes the behaviour ofdynamic_preempt_lazy(), which uses a static key. There are no other static calls or static keys, and so there's no need forHAVE_PREEMPT_DYNAMIC_CALLorHAVE_PREEMPT_DYNAMIC_KEY.The static key used by
dynamic_preempt_lazy()is entirely local tokernel/sched/core.c, and any architecture which selectsARCH_HAS_PREEMPT_LAZYimplements the necessary support. Remove PREEMPT_DYNAMIC's dependencies onHAVE_PREEMPT_DYNAMIC_CALLandHAVE_PREEMPT_DYNAMIC_KEYentirely, leaving the dependency onARCH_HAS_PREEMPT_LAZY.For architectures which previously selected
HAVE_PREEMPT_DYNAMIC_KEY,PREEMPT_DYNAMICwill now be selected by default, matching x86. As the runtime impact is limited todynamic_preempt_lazy(), this shouldn't be as concerning as previously (e.g. where calls to {cond,might}_resched() stubs could introduce a measurable penalty).As all of this can work without jump labels,
JUMP_LABELis not selected explicitly. It is obviously preferable to haveJUMP_LABELenabled, but this is not functionally necessary.
[...]
Quoted 16 lines
kernel/Kconfig.preempt config PREEMPTION · line 133
Quoted 11 lines
kernel/Kconfig.preempt +0
-2@@ -128,11 +128,9 @@ config PREEMPTION config PREEMPT_DYNAMIC bool "Preemption behaviour defined on boot" - depends on HAVE_PREEMPT_DYNAMIC depends on ARCH_HAS_PREEMPT_LAZY - select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEYAfter this, only the arm64 architecture explicitly selects
JUMP_LABEL. When we remove the dependency onHAVE_PREEMPT_DYNAMIC_KEY, should we also selectJUMP_LABELfor those architectures.
Quoted 5 lines
git grep "select
JUMP_LABEL"arch/arm64/Kconfig: select JUMP_LABEL block/Kconfig: select JUMP_LABEL if HAVE_ARCH_JUMP_LABEL fs/xfs/Kconfig: select JUMP_LABEL if HAVE_ARCH_JUMP_LABEL fs/xfs/Kconfig: select JUMP_LABEL if HAVE_ARCH_JUMP_LABEL
I had deliberately avoided selecting JUMP_LABEL. As the commit message says, it's not functionally necessary. It also wasn't previously selected for !HAVE_PREEMPT_DYNAMIC_KEY (e.g. on x86). The relevant defconfig files have CONFIG_JUMP_LABEL=y regardless, so it ends up being on by default in practice.
Not selecting JUMP_LABEL allows it to be turned off for testing, so I would prefer to leave it as-is.
Quoted 2 lines
otherwise
Reviewed-by Jinjie Ruan <[email protected]>
Thanks!
Mark.
[tip: sched/core] sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
In reply to Mark RutlandThe 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: 5b9a28eeed37513778ca6b636253aa8dcf39d55f Gitweb: https://git.kernel.org/tip/5b9a28eeed37513778ca6b636253aa8dcf39d55f Author: Mark Rutland <[email protected]> AuthorDate: Mon, 03 Aug 2026 20:17:30 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Wed, 02 Sep 2026 09:37:23 +02:00
sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
PREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. Switching model only changes the behaviour of dynamic_preempt_lazy(), which uses a static key. There are no other static calls or static keys, and so there's no need for HAVE_PREEMPT_DYNAMIC_CALL or HAVE_PREEMPT_DYNAMIC_KEY.
The static key used by dynamic_preempt_lazy() is entirely local to kernel/sched/core.c, and any architecture which selects ARCH_HAS_PREEMPT_LAZY implements the necessary support. Remove PREEMPT_DYNAMIC's dependencies on HAVE_PREEMPT_DYNAMIC_CALL and HAVE_PREEMPT_DYNAMIC_KEY entirely, leaving the dependency on ARCH_HAS_PREEMPT_LAZY.
For architectures which previously selected HAVE_PREEMPT_DYNAMIC_KEY, PREEMPT_DYNAMIC will now be selected by default, matching x86. As the runtime impact is limited to dynamic_preempt_lazy(), this shouldn't be as concerning as previously (e.g. where calls to {cond,might}_resched() stubs could introduce a measurable penalty).
As all of this can work without jump labels, JUMP_LABEL is not selected explicitly. It is obviously preferable to have JUMP_LABEL enabled, but this is not functionally necessary.
--- arch/Kconfig | 38 -------------------------------------- arch/arm64/Kconfig | 1 - arch/loongarch/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/x86/Kconfig | 1 - kernel/Kconfig.preempt | 8 ++------ kernel/sched/core.c | 10 ---------- 9 files changed, 2 insertions(+), 60 deletions(-)
arch/Kconfig +0 -38
@@ -1712,44 +1712,6 @@ config HAVE_STATIC_CALL_INLINE depends on HAVE_STATIC_CALL select OBJTOOL -config HAVE_PREEMPT_DYNAMIC - bool - -config HAVE_PREEMPT_DYNAMIC_CALL - bool - depends on HAVE_STATIC_CALL - select HAVE_PREEMPT_DYNAMIC - help - An architecture should select this if it can handle the preemption - model being selected at boot time using static calls. - - Where an architecture selects HAVE_STATIC_CALL_INLINE, any call to a - preemption function will be patched directly. - - Where an architecture does not select HAVE_STATIC_CALL_INLINE, any - call to a preemption function will go through a trampoline, and the - trampoline will be patched. - - It is strongly advised to support inline static call to avoid any - overhead. - -config HAVE_PREEMPT_DYNAMIC_KEY - bool - depends on HAVE_ARCH_JUMP_LABEL - select HAVE_PREEMPT_DYNAMIC - help - An architecture should select this if it can handle the preemption - model being selected at boot time using static keys. - - Each preemption function will be given an early return based on a - static key. This should have slightly lower overhead than non-inline - static calls, as this effectively inlines each trampoline into the - start of its callee. This may avoid redundant work, and may - integrate better with CFI schemes. - - This will have greater overhead than using inline static calls as - the call to the preemption function cannot be entirely elided. - config ARCH_WANT_LD_ORPHAN_WARN bool help
arch/arm64/Kconfig +0 -1
@@ -217,7 +217,6 @@ config ARM64 select HAVE_PERF_EVENTS_NMI if ARM64_PSEUDO_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_POSIX_CPU_TIMERS_TASK_WORK
arch/loongarch/Kconfig +0 -1
@@ -170,7 +170,6 @@ config LOONGARCH select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC select HAVE_RETHOOK
arch/powerpc/Kconfig +0 -1
@@ -279,7 +279,6 @@ config PPC select HAVE_PERF_EVENTS_NMI if PPC64 select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_POSIX_CPU_TIMERS_TASK_WORK select HAVE_RETHOOK if KPROBES select HAVE_REGS_AND_STACK_ACCESS_API
arch/riscv/Kconfig +0 -1
@@ -195,7 +195,6 @@ config RISCV select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RETHOOK select HAVE_RSEQ
arch/s390/Kconfig +0 -1
@@ -246,7 +246,6 @@ config S390 select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK - select HAVE_PREEMPT_DYNAMIC_KEY select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_RETHOOK
arch/x86/Kconfig +0 -1
@@ -297,7 +297,6 @@ config X86 select HAVE_STACK_VALIDATION if HAVE_OBJTOOL select HAVE_STATIC_CALL select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL - select HAVE_PREEMPT_DYNAMIC_CALL select HAVE_RSEQ select HAVE_RUST if X86_64 select HAVE_SYSCALL_TRACEPOINTS
kernel/Kconfig.preempt +2 -6
@@ -132,11 +132,9 @@ config PREEMPTION config PREEMPT_DYNAMIC bool "Preemption behaviour defined on boot" - depends on HAVE_PREEMPT_DYNAMIC depends on ARCH_HAS_PREEMPT_LAZY - select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY select PREEMPT_BUILD - default y if HAVE_PREEMPT_DYNAMIC_CALL + default y help This option allows to define the preemption model on the kernel command line parameter and thus override the default preemption
@@ -146,9 +144,7 @@ config PREEMPT_DYNAMIC provide a pre-built kernel binary to reduce the number of kernel flavors they offer while still offering different usecases. - The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled - but if runtime patching is not available for the specific architecture - then the potential overhead should be considered. + The runtime overhead is negligible. Interesting if you want the same pre-built kernel should be used for both Server and Desktop workloads.
kernel/sched/core.c +0 -10
@@ -7886,16 +7886,6 @@ int sched_dynamic_mode(const char *str)# define preempt_dynamic_key_enable (f) static_key_enable(&sk_dynamic_##f.key)# define preempt_dynamic_key_disable (f) static_key_disable(&sk_dynamic_##f.key) -# if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL ) -# define preempt_dynamic_enable (f) static_call_update(f, f##_dynamic_enabled) -# define preempt_dynamic_disable (f) static_call_update(f, f##_dynamic_disabled) -# elif defined(CONFIG_HAVE_PREEMPT_DYNAMIC_KEY ) -# define preempt_dynamic_enable (f) preempt_dynamic_key_enable(f) -# define preempt_dynamic_disable (f) preempt_dynamic_key_disable(f) -# else -# error "Unsupported PREEMPT_DYNAMIC mechanism" -# endif -static DEFINE_MUTEX (sched_dynamic_mutex);static void __sched_dynamic_update (int mode)
Mark Rutland
reviewerPATCH v2 6/6 sched: dynamic: Simplify preempt model accessors
In reply to Mark RutlandPREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. When CONFIG_PREEMPT_DYNAMIC=y, the NONE and VOLUNTARY models cannot be used, and neither CONFIG_PREEMPT_NONE nor CONFIG_PREEMPT_VOLUNTARY can be selected.
Simplify the preempt model accessors accordingly: remove the out-of-line implementations of preempt_model_none() and preempt_model_voluntary(), and remove the preempt_dynamic_{none,voluntary} values.
There are no current users of preempt_model_voluntary(), but I've kept it around for consistency, with every scheduler model having its own preempt_model_*() accessor.
--- include/linux/preempt.h | 20 ++++++++++---------- kernel/sched/core.c | 4 ---- 2 files changed, 10 insertions(+), 14 deletions(-)
include/linux/preempt.h +10 -10
@@ -470,21 +470,11 @@ DEFINE_LOCK_GUARD_0(preempt_notrace, preempt_disable_notrace(), preempt_enable_n#ifdef CONFIG_PREEMPT_DYNAMIC -extern bool preempt_model_none (void ); -extern bool preempt_model_voluntary (void );extern bool preempt_model_full (void );extern bool preempt_model_lazy (void );#else -static inline bool preempt_model_none (void ) -{ -return IS_ENABLED (CONFIG_PREEMPT_NONE ); -} -static inline bool preempt_model_voluntary (void ) -{ -return IS_ENABLED (CONFIG_PREEMPT_VOLUNTARY ); -}static inline bool preempt_model_full (void ) {return IS_ENABLED (CONFIG_PREEMPT );
@@ -497,6 +487,16 @@ static inline bool preempt_model_lazy(void)#endif +static inline bool preempt_model_none (void ) +{ +return IS_ENABLED (CONFIG_PREEMPT_NONE ); +} + +static inline bool preempt_model_voluntary (void ) +{ +return IS_ENABLED (CONFIG_PREEMPT_VOLUNTARY ); +} +static inline bool preempt_model_rt (void ) {return IS_ENABLED (CONFIG_PREEMPT_RT );
kernel/sched/core.c +0 -4
@@ -7803,8 +7803,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);enum { preempt_dynamic_undefined =-1 , - preempt_dynamic_none, - preempt_dynamic_voluntary, preempt_dynamic_full, preempt_dynamic_lazy, };
@@ -7889,8 +7887,6 @@ static void __init preempt_dynamic_init(void) } \ EXPORT_SYMBOL_GPL(preempt_model_##mode) -PREEMPT_MODEL_ACCESSOR (none); -PREEMPT_MODEL_ACCESSOR (voluntary);PREEMPT_MODEL_ACCESSOR (full);PREEMPT_MODEL_ACCESSOR (lazy);
Signature · 1 line
2.30.2
Re: [PATCH v2 6/6] sched: dynamic: Simplify preempt model accessors
Quoted 37 lines · Mark Rutland
PREEMPT_DYNAMICis now limited to the FULL and LAZY preemption models. WhenCONFIG_PREEMPT_DYNAMIC=y, the NONE and VOLUNTARY models cannot be used, and neitherCONFIG_PREEMPT_NONEnorCONFIG_PREEMPT_VOLUNTARYcan be selected.Simplify the preempt model accessors accordingly: remove the out-of-line implementations of
preempt_model_none()andpreempt_model_voluntary(), and remove the preempt_dynamic_{none,voluntary} values.There are no current users of
preempt_model_voluntary(), but I've kept it around for consistency, with every scheduler model having its own preempt_model_*() accessor.Suggested-by Shrikanth Hegde <[email protected]Signed-off-by Mark Rutland <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Ingo Molnar <[email protected]>Cc John Stultz <[email protected]>Cc Juri Lelli <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Shrikanth Hegde <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Valentin Schneider <[email protected]>Cc Vincent Guittot <[email protected]>--- include/linux/preempt.h | 20 ++++++++++---------- kernel/sched/core.c | 4 ---- 2 files changed, 10 insertions(+), 14 deletions(-)include/linux/preempt.h +0
-0@@ -470,21 +470,11 @@ DEFINE_LOCK_GUARD_0(preempt_notrace, preempt_disable_notrace(), preempt_enable_n#ifdef CONFIG_PREEMPT_DYNAMIC
[...]
Quoted 9 lines
include/linux/preempt.h +1
-0+static inline bool preempt_model_rt (void ) {return IS_ENABLED (CONFIG_PREEMPT_RT );kernel/sched/core.c +0
-0
kernel/sched/core.c EXPORT_SYMBOL(__cond_resched_rwlock_write); · line 7807
Quoted 7 lines
kernel/sched/core.c +0
-2@@ -7803,8 +7803,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);enum { preempt_dynamic_undefined =-1 , - preempt_dynamic_none, - preempt_dynamic_voluntary, preempt_dynamic_full, preempt_dynamic_lazy,
Hi Mark,
Should the annotations for NONE and VOLUNTARY be removed simultaneously?
kernel/sched/core.c +0 -6
@@ -7788,12 +7788,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);# endif /* -* NONE: -* (unselectable) -* -* VOLUNTARY: -* (unselectable) -* * FULL: * dynamic_preempt_lazy <- false *
Otherwise, LGTM
Quoted 10 lines
kernel/sched/core.c +0
-2};@@ -7889,8 +7887,6 @@ static void __init preempt_dynamic_init(void) } \ EXPORT_SYMBOL_GPL(preempt_model_##mode) -PREEMPT_MODEL_ACCESSOR (none); -PREEMPT_MODEL_ACCESSOR (voluntary);PREEMPT_MODEL_ACCESSOR (full);PREEMPT_MODEL_ACCESSOR (lazy);
Mark Rutland
reviewerRe: [PATCH v2 6/6] sched: dynamic: Simplify preempt model accessors
Quoted 17 lines · Jinjie Ruan
Review
Quoted 6 lines · Mark Rutland
enum {
(quoted diff) +0
-2preempt_dynamic_undefined = -1, - preempt_dynamic_none, - preempt_dynamic_voluntary, preempt_dynamic_full, preempt_dynamic_lazy,Hi Mark,
Should the annotations for NONE and VOLUNTARY be removed simultaneously?
kernel/sched/core.c +0
-0@@ -7788,12 +7788,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);# endif
kernel/sched/core.c EXPORT_SYMBOL(__cond_resched_rwlock_write); · line 7793
Quoted 10 lines
kernel/sched/core.c +0
-6/* -* NONE: -* (unselectable) -* -* VOLUNTARY: -* (unselectable) -* * FULL: * dynamic_preempt_lazy <- false *
I had left those lines to indicate that those modes were deliberately not selectable with preempt_dynamic. Evidently keeping them was confusing, so I'll delete them.
Quoted 2 lines
Otherwise, LGTM
Reviewed-by Jinjie Ruan <[email protected]>
Thanks!
Mark.
Quoted 11 lines
Quoted 10 lines
};
(quoted diff) +0
-2@@ -7889,8 +7887,6 @@ static void __init preempt_dynamic_init(void) } \ EXPORT_SYMBOL_GPL(preempt_model_##mode) -PREEMPT_MODEL_ACCESSOR(none); -PREEMPT_MODEL_ACCESSOR(voluntary); PREEMPT_MODEL_ACCESSOR(full); PREEMPT_MODEL_ACCESSOR(lazy);
[tip: sched/core] sched: dynamic: Simplify preempt model accessors
In reply to Mark RutlandThe 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: 9650ce11f2e377310332d87a902dc4df3f59b905 Gitweb: https://git.kernel.org/tip/9650ce11f2e377310332d87a902dc4df3f59b905 Author: Mark Rutland <[email protected]> AuthorDate: Mon, 03 Aug 2026 20:17:31 +01:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Wed, 02 Sep 2026 09:37:24 +02:00
sched: dynamic: Simplify preempt model accessors
PREEMPT_DYNAMIC is now limited to the FULL and LAZY preemption models. When CONFIG_PREEMPT_DYNAMIC=y, the NONE and VOLUNTARY models cannot be used, and neither CONFIG_PREEMPT_NONE nor CONFIG_PREEMPT_VOLUNTARY can be selected.
Simplify the preempt model accessors accordingly: remove the out-of-line implementations of preempt_model_none() and preempt_model_voluntary(), and remove the preempt_dynamic_{none,voluntary} values.
There are no current users of preempt_model_voluntary(), but I've kept it around for consistency, with every scheduler model having its own preempt_model_*() accessor.
--- include/linux/preempt.h | 20 ++++++++++---------- kernel/sched/core.c | 4 ---- 2 files changed, 10 insertions(+), 14 deletions(-)
include/linux/preempt.h +10 -10
@@ -502,21 +502,11 @@ DEFINE_LOCK_GUARD_0(preempt_notrace, preempt_disable_notrace(), preempt_enable_n#ifdef CONFIG_PREEMPT_DYNAMIC -extern bool preempt_model_none (void ); -extern bool preempt_model_voluntary (void );extern bool preempt_model_full (void );extern bool preempt_model_lazy (void );#else -static inline bool preempt_model_none (void ) -{ -return IS_ENABLED (CONFIG_PREEMPT_NONE ); -} -static inline bool preempt_model_voluntary (void ) -{ -return IS_ENABLED (CONFIG_PREEMPT_VOLUNTARY ); -}static inline bool preempt_model_full (void ) {return IS_ENABLED (CONFIG_PREEMPT );
@@ -529,6 +519,16 @@ static inline bool preempt_model_lazy(void)#endif +static inline bool preempt_model_none (void ) +{ +return IS_ENABLED (CONFIG_PREEMPT_NONE ); +} + +static inline bool preempt_model_voluntary (void ) +{ +return IS_ENABLED (CONFIG_PREEMPT_VOLUNTARY ); +} +static inline bool preempt_model_rt (void ) {return IS_ENABLED (CONFIG_PREEMPT_RT );
kernel/sched/core.c +0 -4
@@ -7864,8 +7864,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);enum { preempt_dynamic_undefined =-1 , - preempt_dynamic_none, - preempt_dynamic_voluntary, preempt_dynamic_full, preempt_dynamic_lazy, };
@@ -7950,8 +7948,6 @@ static void __init preempt_dynamic_init(void) } \ EXPORT_SYMBOL_GPL(preempt_model_##mode) -PREEMPT_MODEL_ACCESSOR (none); -PREEMPT_MODEL_ACCESSOR (voluntary);PREEMPT_MODEL_ACCESSOR (full);PREEMPT_MODEL_ACCESSOR (lazy);
Quoted 24 lines · Mark Rutland
All architectures which currently suppoort
PREEMPT_DYNAMICselectARCH_HAS_PREEMPT_LAZY. On architectures which selectARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since v7.0 due to commit:
7dadeaa6e851("sched: Further restrict the preemption modes")Hence in practice
PREEMPT_DYNAMICno longer supports the NONE or VOLUNTARY preemption models.This series makes the de-facto situation official by making
PREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY, and removing redundant code.Since v1, I've had to rebase atop v7.2-rc4 to avoid a conflict with commit:
a2c02aa0c6ca("powerpc: Remove dead non-preemption code")Given this is now late in the cycle, and given the tip:sched/core branch is based on v7.2-rc1, I suspect tip folk might not want to queue this now. Please let me know what you'd prefer; I'm happy to rebase and resend after v7.3-rc1.
Quoted 8 lines
Since v1:
* Rebase to v7.2-rc4
* Apply Revied-by tags.
* Fix typos in commit messages.
* Add patch to cleanup accessors (per Shrikanth's comment)Mark.
Hi, I once again did a build test and the results
are looking the same;
$ ls -la baseline/vmlinux patched/vmlinux -rwxrwxr-x 1 meted meted 409534568 Aug 5 11:38 baseline/vmlinux -rwxrwxr-x 1 meted meted 408212872 Aug 5 10:50 patched/vmlinux
$ ls -la baseline/bzImage patched/bzImage -rwxrwxr-x 1 meted meted 12922880 Aug 5 11:38 baseline/bzImage -rwxrwxr-x 1 meted meted 12890112 Aug 5 10:51 patched/bzImage
Both bzImage and vmlinux are shrunk after the patch for s390.
bzImage ~32K smaller
vmlinux ~1.2M smaller
FWIW, here is my tested-by;
Quoted 24 lines · Mark Rutland
All architectures which currently suppoort
PREEMPT_DYNAMICselectARCH_HAS_PREEMPT_LAZY. On architectures which selectARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since v7.0 due to commit:
7dadeaa6e851("sched: Further restrict the preemption modes")Hence in practice
PREEMPT_DYNAMICno longer supports the NONE or VOLUNTARY preemption models.This series makes the de-facto situation official by making
PREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY, and removing redundant code.Since v1, I've had to rebase atop v7.2-rc4 to avoid a conflict with commit:
a2c02aa0c6ca("powerpc: Remove dead non-preemption code")Given this is now late in the cycle, and given the tip:sched/core branch is based on v7.2-rc1, I suspect tip folk might not want to queue this now. Please let me know what you'd prefer; I'm happy to rebase and resend after v7.3-rc1.
Quoted 8 lines
Since v1:
* Rebase to v7.2-rc4
* Apply Revied-by tags.
* Fix typos in commit messages.
* Add patch to cleanup accessors (per Shrikanth's comment)Mark.
I have tested with and without PREEMPT_DYNAMIC for lazy/full. I haven't observed anything odd.
For the series,
Quoted 28 lines
Mark Rutland (6):
sched: dynamic: MakePREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY
sched: dynamic: Simplify {cond,might}_resched()
sched: dynamic: Simplify preempt_schedule{,_notrace}()
sched: dynamic: Simplifyirqentry_exit_cond_resched()
sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
sched: dynamic: Simplify preempt model accessorsarch/Kconfig | 38 ------- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/preempt.h | 10 -- arch/loongarch/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/s390/include/asm/preempt.h | 11 -- arch/x86/Kconfig | 1 - arch/x86/include/asm/preempt.h | 28 ----- include/asm-generic/preempt.h | 10 -- include/linux/irq-entry-common.h | 17 +-- include/linux/kernel.h | 20 ---- include/linux/preempt.h | 20 ++-- include/linux/sched.h | 31 +----- kernel/Kconfig.preempt | 9 +- kernel/entry/common.c | 17 +-- kernel/sched/core.c | 180 +------------------------------ 18 files changed, 23 insertions(+), 374 deletions(-)
Quoted 30 lines · Mark Rutland
All architectures which currently suppoort
PREEMPT_DYNAMICselectARCH_HAS_PREEMPT_LAZY. On architectures which selectARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since v7.0 due to commit:
7dadeaa6e851("sched: Further restrict the preemption modes")Hence in practice
PREEMPT_DYNAMICno longer supports the NONE or VOLUNTARY preemption models.This series makes the de-facto situation official by making
PREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY, and removing redundant code.Since v1, I've had to rebase atop v7.2-rc4 to avoid a conflict with commit:
a2c02aa0c6ca("powerpc: Remove dead non-preemption code")Given this is now late in the cycle, and given the tip:sched/core branch is based on v7.2-rc1, I suspect tip folk might not want to queue this now. Please let me know what you'd prefer; I'm happy to rebase and resend after v7.3-rc1.
Since v1:
* Rebase to v7.2-rc4
* Apply Revied-by tags.
* Fix typos in commit messages.
* Add patch to cleanup accessors (per Shrikanth's comment)
Quoted 5 lines
Mark.
Mark Rutland (6):
sched: dynamic: MakePREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY
sched: dynamic: Simplify {cond,might}_resched()
Hi Mark,
We also need to update the Doc.
Documentation/admin-guide/kernel-parameters.txt +0 -0
@@ -5410,8 +5410,6 @@ Kernel parameters preempt= [KNL] Select preemption mode if you have
CONFIG_PREEMPT_DYNAMIC
- none - Limited to cond_resched() calls
- voluntary - Limited to cond_resched() andmight_sleep() calls
full - Any section that isn't explicitly preempt
disabled
can be preempted anytime. Tasks will
also yield
contended spinlocks (if the critical
section isn't
Best regards,
Jinjie
Quoted 25 lines
sched: dynamic: Simplify preempt_schedule{,_notrace}()
sched: dynamic: Simplifyirqentry_exit_cond_resched()
sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
sched: dynamic: Simplify preempt model accessorsarch/Kconfig | 38 ------- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/preempt.h | 10 -- arch/loongarch/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/s390/include/asm/preempt.h | 11 -- arch/x86/Kconfig | 1 - arch/x86/include/asm/preempt.h | 28 ----- include/asm-generic/preempt.h | 10 -- include/linux/irq-entry-common.h | 17 +-- include/linux/kernel.h | 20 ---- include/linux/preempt.h | 20 ++-- include/linux/sched.h | 31 +----- kernel/Kconfig.preempt | 9 +- kernel/entry/common.c | 17 +-- kernel/sched/core.c | 180 +------------------------------ 18 files changed, 23 insertions(+), 374 deletions(-)
Quoted 53 lines · Jinjie Ruan
Quoted 30 lines · Mark Rutland
All architectures which currently suppoort
PREEMPT_DYNAMICselectARCH_HAS_PREEMPT_LAZY. On architectures which selectARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since v7.0 due to commit:
7dadeaa6e851("sched: Further restrict the preemption modes")Hence in practice
PREEMPT_DYNAMICno longer supports the NONE or VOLUNTARY preemption models.This series makes the de-facto situation official by making
PREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY, and removing redundant code.Since v1, I've had to rebase atop v7.2-rc4 to avoid a conflict with commit:
a2c02aa0c6ca("powerpc: Remove dead non-preemption code")Given this is now late in the cycle, and given the tip:sched/core branch is based on v7.2-rc1, I suspect tip folk might not want to queue this now. Please let me know what you'd prefer; I'm happy to rebase and resend after v7.3-rc1.
Since v1:
* Rebase to v7.2-rc4
* Apply Revied-by tags.
* Fix typos in commit messages.
* Add patch to cleanup accessors (per Shrikanth's comment)Quoted 5 lines
Mark.
Mark Rutland (6):
sched: dynamic: MakePREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY
sched: dynamic: Simplify {cond,might}_resched()Hi Mark,
We also need to update the Doc.
Documentation/admin-guide/kernel-parameters.txt +0
-0@@ -5410,8 +5410,6 @@ Kernel parameters preempt= [KNL] Select preemption mode if you have
CONFIG_PREEMPT_DYNAMICDocumentation/admin-guide/kernel-parameters.txt +0
-2- none - Limited to cond_resched() calls - voluntary - Limited to cond_resched() and
Quoted 6 lines
might_sleep()calls
full - Any section that isn't explicitly preempt
disabled
can be preempted anytime. Tasks will
also yield
contended spinlocks (if the critical
Hi Mark,
What do you think?
Quoted 31 lines
section isn't
Best regards,
JinjieQuoted 25 lines
sched: dynamic: Simplify preempt_schedule{,_notrace}()
sched: dynamic: Simplifyirqentry_exit_cond_resched()
sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
sched: dynamic: Simplify preempt model accessorsarch/Kconfig | 38 ------- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/preempt.h | 10 -- arch/loongarch/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/s390/include/asm/preempt.h | 11 -- arch/x86/Kconfig | 1 - arch/x86/include/asm/preempt.h | 28 ----- include/asm-generic/preempt.h | 10 -- include/linux/irq-entry-common.h | 17 +-- include/linux/kernel.h | 20 ---- include/linux/preempt.h | 20 ++-- include/linux/sched.h | 31 +----- kernel/Kconfig.preempt | 9 +- kernel/entry/common.c | 17 +-- kernel/sched/core.c | 180 +------------------------------ 18 files changed, 23 insertions(+), 374 deletions(-)
Quoted 24 lines · Mark Rutland
All architectures which currently suppoort
PREEMPT_DYNAMICselectARCH_HAS_PREEMPT_LAZY. On architectures which selectARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since v7.0 due to commit:
7dadeaa6e851("sched: Further restrict the preemption modes")Hence in practice
PREEMPT_DYNAMICno longer supports the NONE or VOLUNTARY preemption models.This series makes the de-facto situation official by making
PREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY, and removing redundant code.Since v1, I've had to rebase atop v7.2-rc4 to avoid a conflict with commit:
a2c02aa0c6ca("powerpc: Remove dead non-preemption code")Given this is now late in the cycle, and given the tip:sched/core branch is based on v7.2-rc1, I suspect tip folk might not want to queue this now. Please let me know what you'd prefer; I'm happy to rebase and resend after v7.3-rc1.
Quoted 5 lines
Since v1:
* Rebase to v7.2-rc4
* Apply Revied-by tags.
* Fix typos in commit messages.
* Add patch to cleanup accessors (per Shrikanth's comment)
Hi Mark,
I did a test on v7.2-rc6 for arm64.
# ls -la Image_base Image_patch -rw-r--r-- 1 root root 63158784 Aug 7 10:37 Image_base -rw-r--r-- 1 root root 63093248 Aug 7 10:31 Image_patch # ls -la vmlinux_base vmlinux_patch -rwxr-xr-x 1 root root 206396648 Aug 7 10:37 vmlinux_base -rwxr-xr-x 1 root root 206266232 Aug 7 10:31 vmlinux_patch
So the overall vmlinux file size reduced by ~127 KB and the Image size reduced by ~64 KB.
Boot tested successfully with preempt=lazy and preempt=full on Qemu and Kunpeng HIP09 server.
Boot with preempt=none and preempt=voluntary on Qemu.
Dynamic Preempt: unsupported mode: none
Dynamic Preempt: unsupported mode: voluntary
But runtime switching via /sys/kernel/debug/sched/preempt works not right as below.
# echo full > preempt # cat preempt full lazy # echo lazy > preempt # cat preempt full lazy
We should also update the "preempt_modes" array, after the below fix, it shows ok;
# echo lazy > preempt [ 37.407616] Dynamic Preempt: lazy # cat preempt full (lazy) # echo full > preempt [ 52.067001] Dynamic Preempt: full # cat preempt (full) lazy
kernel/sched/core.c +1 -1
@@ -7899,7 +7899,7 @@ static inline void preempt_dynamic_init(void) { }#endif /* CONFIG_PREEMPT_DYNAMIC */ const char *preempt_modes[] = { -"none" ,"voluntary" ,"full" ,"lazy" ,NULL , +"full" ,"lazy" ,NULL , };
Otherwise
Quoted 31 lines
Mark.
Mark Rutland (6):
sched: dynamic: MakePREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY
sched: dynamic: Simplify {cond,might}_resched()
sched: dynamic: Simplify preempt_schedule{,_notrace}()
sched: dynamic: Simplifyirqentry_exit_cond_resched()
sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY}
sched: dynamic: Simplify preempt model accessorsarch/Kconfig | 38 ------- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/preempt.h | 10 -- arch/loongarch/Kconfig | 1 - arch/powerpc/Kconfig | 1 - arch/riscv/Kconfig | 1 - arch/s390/Kconfig | 1 - arch/s390/include/asm/preempt.h | 11 -- arch/x86/Kconfig | 1 - arch/x86/include/asm/preempt.h | 28 ----- include/asm-generic/preempt.h | 10 -- include/linux/irq-entry-common.h | 17 +-- include/linux/kernel.h | 20 ---- include/linux/preempt.h | 20 ++-- include/linux/sched.h | 31 +----- kernel/Kconfig.preempt | 9 +- kernel/entry/common.c | 17 +-- kernel/sched/core.c | 180 +------------------------------ 18 files changed, 23 insertions(+), 374 deletions(-)
Mark Rutland
reviewerQuoted 80 lines · Jinjie Ruan
Quoted 24 lines · Mark Rutland
All architectures which currently suppoort
PREEMPT_DYNAMICselectARCH_HAS_PREEMPT_LAZY. On architectures which selectARCH_HAS_PREEMPT_LAZY, it has not been possible to select the NONE and VOLUNTARY preemption models since v7.0 due to commit:
7dadeaa6e851("sched: Further restrict the preemption modes")Hence in practice
PREEMPT_DYNAMICno longer supports the NONE or VOLUNTARY preemption models.This series makes the de-facto situation official by making
PREEMPT_DYNAMICdepend onARCH_HAS_PREEMPT_LAZY, and removing redundant code.Since v1, I've had to rebase atop v7.2-rc4 to avoid a conflict with commit:
a2c02aa0c6ca("powerpc: Remove dead non-preemption code")Given this is now late in the cycle, and given the tip:sched/core branch is based on v7.2-rc1, I suspect tip folk might not want to queue this now. Please let me know what you'd prefer; I'm happy to rebase and resend after v7.3-rc1.
Quoted 5 lines
Since v1:
* Rebase to v7.2-rc4
* Apply Revied-by tags.
* Fix typos in commit messages.
* Add patch to cleanup accessors (per Shrikanth's comment)Hi Mark,
I did a test on v7.2-rc6 for arm64.
# ls -la Image_base Image_patch(quoted diff) +0
-2-rw-r--r-- 1 root root 63158784 Aug 7 10:37 Image_base -rw-r--r-- 1 root root 63093248 Aug 7 10:31 Image_patch# ls -la vmlinux_base vmlinux_patch(quoted diff) +0
-2-rwxr-xr-x 1 root root 206396648 Aug 7 10:37 vmlinux_base -rwxr-xr-x 1 root root 206266232 Aug 7 10:31 vmlinux_patchSo the overall vmlinux file size reduced by ~127 KB and the Image size reduced by ~64 KB.
Boot tested successfully with preempt=lazy and preempt=full on Qemu and Kunpeng HIP09 server.
Boot with preempt=none and preempt=voluntary on Qemu.
Dynamic Preempt: unsupported mode: none
Dynamic Preempt: unsupported mode: voluntaryBut runtime switching via
/sys/kernel/debug/sched/preemptworks not right as below.# echo full > preempt # cat preempt full lazy # echo lazy > preempt # cat preempt full lazyWe should also update the "
preempt_modes" array, after the below fix, it shows ok;# echo lazy > preempt [ 37.407616] Dynamic Preempt: lazy # cat preempt full (lazy) # echo full > preempt [ 52.067001] Dynamic Preempt: full # cat preempt (full) lazy
kernel/sched/core.c static inline void preempt_dynamic_init(void) { } · line 7903
Quoted 6 lines
kernel/sched/core.c +1
-1@@ -7899,7 +7899,7 @@ static inline void preempt_dynamic_init(void) { }#endif /* CONFIG_PREEMPT_DYNAMIC */ const char *preempt_modes[] = { -"none" ,"voluntary" ,"full" ,"lazy" ,NULL , +"full" ,"lazy" ,NULL , };
Ugh, yes.
We'll also need to fix up sched_dynamic_show(), since it has logic to conditionally skip "none" and "voluntary".
This is all a bit messy, given the enum value isn't used to define the string array. I'll see if I can figure a way to make that consistent by construction, but that probably needs a bit more rework...
Quoted 2 lines
Otherwise
Tested-by Jinjie Ruan <[email protected]>
Thanks!
Mark.