From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Mark Rutland <mark.rutland@arm.com>, linux-kernel@vger.kernel.org
Cc: frederic@kernel.org, jstultz@google.com, juri.lelli@redhat.com,
mingo@redhat.com, peterz@infradead.org, tglx@linutronix.de,
vincent.guittot@linaro.org, vschneid@redhat.com
Subject: Re: [PATCH 1/5] sched: dynamic: Make PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY
Date: Mon, 6 Jul 2026 10:06:29 +0530 [thread overview]
Message-ID: <860baba7-e65d-463b-85cc-feb9c4f930c7@linux.ibm.com> (raw)
In-Reply-To: <20260703133358.698078-2-mark.rutland@arm.com>
On 7/3/26 7:03 PM, Mark Rutland wrote:
> 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 suppoort PREEMPT_DYNAMIC select
s/suppoort/support
> 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.
>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Cc: Frederic Weisbecker <frederic@kernel.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: John Stultz <jstultz@google.com>
> Cc: Juri Lelli <juri.lelli@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Valentin Schneider <vschneid@redhat.com>
> Cc: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> kernel/Kconfig.preempt | 1 +
> kernel/sched/core.c | 63 ++----------------------------------------
> 2 files changed, 4 insertions(+), 60 deletions(-)
>
> diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
> index 88c594c6d7fcd..fb49424003b2b 100644
> --- a/kernel/Kconfig.preempt
> +++ b/kernel/Kconfig.preempt
> @@ -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
Can we update the help section bit?
"""
The runtime overhead is negligible.
Interesting if you want the same pre-built kernel should be used for
both Server and Desktop workloads.
"""
I think server meant preempt=none and desktop meant preempt=full/lazy there. No?
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 96226707c2f61..2db78826a484b 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -7870,20 +7870,10 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);
> *
> *
> * NONE:
> - * cond_resched <- __cond_resched
> - * might_resched <- RET0
> - * preempt_schedule <- NOP
> - * preempt_schedule_notrace <- NOP
> - * irqentry_exit_cond_resched <- NOP
> - * dynamic_preempt_lazy <- false
> + * (unselectable)
> *
> * VOLUNTARY:
> - * cond_resched <- __cond_resched
> - * might_resched <- __cond_resched
> - * preempt_schedule <- NOP
> - * preempt_schedule_notrace <- NOP
> - * irqentry_exit_cond_resched <- NOP
> - * dynamic_preempt_lazy <- false
> + * (unselectable)
> *
> * FULL:
> * cond_resched <- RET0
> @@ -7914,21 +7904,11 @@ int preempt_dynamic_mode = preempt_dynamic_undefined;
>
> int sched_dynamic_mode(const char *str)
> {
> -# if !(defined(CONFIG_PREEMPT_RT) || defined(CONFIG_ARCH_HAS_PREEMPT_LAZY))
> - if (!strcmp(str, "none"))
> - return preempt_dynamic_none;
> -
> - if (!strcmp(str, "voluntary"))
> - return preempt_dynamic_voluntary;
> -# endif
> -
> if (!strcmp(str, "full"))
> return preempt_dynamic_full;
>
> -# ifdef CONFIG_ARCH_HAS_PREEMPT_LAZY
> if (!strcmp(str, "lazy"))
> return preempt_dynamic_lazy;
> -# endif
>
> return -EINVAL;
> }
> @@ -7950,40 +7930,7 @@ static DEFINE_MUTEX(sched_dynamic_mutex);
>
> static void __sched_dynamic_update(int mode)
> {
> - /*
> - * Avoid {NONE,VOLUNTARY} -> FULL transitions from ever ending up in
> - * the ZERO state, which is invalid.
> - */
> - preempt_dynamic_enable(cond_resched);
> - preempt_dynamic_enable(might_resched);
> - preempt_dynamic_enable(preempt_schedule);
> - preempt_dynamic_enable(preempt_schedule_notrace);
> - preempt_dynamic_enable(irqentry_exit_cond_resched);
> - preempt_dynamic_key_disable(preempt_lazy);
> -
> switch (mode) {
> - case preempt_dynamic_none:
> - preempt_dynamic_enable(cond_resched);
> - preempt_dynamic_disable(might_resched);
> - preempt_dynamic_disable(preempt_schedule);
> - preempt_dynamic_disable(preempt_schedule_notrace);
> - preempt_dynamic_disable(irqentry_exit_cond_resched);
> - preempt_dynamic_key_disable(preempt_lazy);
> - if (mode != preempt_dynamic_mode)
> - pr_info("Dynamic Preempt: none\n");
> - break;
> -
> - case preempt_dynamic_voluntary:
> - preempt_dynamic_enable(cond_resched);
> - preempt_dynamic_enable(might_resched);
> - preempt_dynamic_disable(preempt_schedule);
> - preempt_dynamic_disable(preempt_schedule_notrace);
> - preempt_dynamic_disable(irqentry_exit_cond_resched);
> - preempt_dynamic_key_disable(preempt_lazy);
> - if (mode != preempt_dynamic_mode)
> - pr_info("Dynamic Preempt: voluntary\n");
> - break;
> -
> case preempt_dynamic_full:
> preempt_dynamic_disable(cond_resched);
> preempt_dynamic_disable(might_resched);
> @@ -8033,11 +7980,7 @@ __setup("preempt=", setup_preempt_mode);
> static void __init preempt_dynamic_init(void)
> {
> if (preempt_dynamic_mode == preempt_dynamic_undefined) {
> - if (IS_ENABLED(CONFIG_PREEMPT_NONE)) {
> - sched_dynamic_update(preempt_dynamic_none);
> - } else if (IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY)) {
> - sched_dynamic_update(preempt_dynamic_voluntary);
> - } else if (IS_ENABLED(CONFIG_PREEMPT_LAZY)) {
> + if (IS_ENABLED(CONFIG_PREEMPT_LAZY)) {
> sched_dynamic_update(preempt_dynamic_lazy);
> } else {
> /* Default static call setting, nothing to do */
other than that, it looks good to me.
Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>
next prev parent reply other threads:[~2026-07-06 4:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 13:33 [PATCH 0/5] sched: dynamic: Simplify PREEMPT_DYNAMIC Mark Rutland
2026-07-03 13:33 ` [PATCH 1/5] sched: dynamic: Make PREEMPT_DYNAMIC depend on ARCH_HAS_PREEMPT_LAZY Mark Rutland
2026-07-06 4:36 ` Shrikanth Hegde [this message]
2026-07-03 13:33 ` [PATCH 2/5] sched: dynamic: Simplify {cond,might}_resched() Mark Rutland
2026-07-06 4:59 ` Shrikanth Hegde
2026-07-03 13:33 ` [PATCH 3/5] sched: dynamic: Simplify preempt_schedule{,_notrace}() Mark Rutland
2026-07-06 5:19 ` Shrikanth Hegde
2026-07-03 13:33 ` [PATCH 4/5] sched: dynamic: Simplify irqentry_exit_cond_resched() Mark Rutland
2026-07-06 4:42 ` Shrikanth Hegde
2026-07-03 13:33 ` [PATCH 5/5] sched: dynamic: Remove HAVE_PREEMPT_DYNAMIC_{CALL,KEY} Mark Rutland
2026-07-06 4:30 ` [PATCH 0/5] sched: dynamic: Simplify PREEMPT_DYNAMIC Shrikanth Hegde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=860baba7-e65d-463b-85cc-feb9c4f930c7@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=frederic@kernel.org \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox