Re: [PATCH v2 6/6] sched: dynamic: Simplify preempt model accessors

From: Jinjie Ruan

Date: Thu Aug 06 2026 - 22:02:42 EST




在 2026/8/4 3:17, Mark Rutland 写道:
> 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.
>
> Suggested-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx
> Signed-off-by: Mark Rutland <mark.rutland@xxxxxxx>
> Cc: Frederic Weisbecker <frederic@xxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: John Stultz <jstultz@xxxxxxxxxx>
> Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
> Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> ---
> include/linux/preempt.h | 20 ++++++++++----------
> kernel/sched/core.c | 4 ----
> 2 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/preempt.h b/include/linux/preempt.h
> index d964f965c8ffc..7e2ec8e29c83f 100644
> --- a/include/linux/preempt.h
> +++ b/include/linux/preempt.h
> @@ -470,21 +470,11 @@ DEFINE_LOCK_GUARD_0(preempt_notrace, preempt_disable_notrace(), preempt_enable_n
>
> #ifdef CONFIG_PREEMPT_DYNAMIC
>
[...]

> +
> static inline bool preempt_model_rt(void)
> {
> return IS_ENABLED(CONFIG_PREEMPT_RT);
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 7b815d8ce67d3..4026f2399edf3 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -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?

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7788,12 +7788,6 @@ EXPORT_SYMBOL(__cond_resched_rwlock_write);
# endif

/*
- * NONE:
- * (unselectable)
- *
- * VOLUNTARY:
- * (unselectable)
- *
* FULL:
* dynamic_preempt_lazy <- false
*

Otherwise, LGTM
Reviewed-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>

> };
> @@ -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);
>