Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sched: Further restrict the preemption modes

The introduction of PREEMPT_LAZY was for multiple reasons:

- PREEMPT_RT suffered from over-scheduling, hurting performance compared to
!PREEMPT_RT.

- the introduction of (more) features that rely on preemption; like
folio_zero_user() which can do large memset() without preemption checks.

(Xen already had a horrible hack to deal with long running hypercalls)

- the endless and uncontrolled sprinkling of cond_resched() -- mostly cargo
cult or in response to poor to replicate workloads.

By moving to a model that is fundamentally preemptable these things become
managable and avoid needing to introduce more horrible hacks.

Since this is a requirement; limit PREEMPT_NONE to architectures that do not
support preemption at all. Further limit PREEMPT_VOLUNTARY to those
architectures that do not yet have PREEMPT_LAZY support (with the eventual goal
to make this the empty set and completely remove voluntary preemption and
cond_resched() -- notably VOLUNTARY is already limited to !ARCH_NO_PREEMPT.)

This leaves up-to-date architectures (arm64, loongarch, powerpc, riscv, s390,
x86) with only two preemption models: full and lazy.

While Lazy has been the recommended setting for a while, not all distributions
have managed to make the switch yet. Force things along. Keep the patch minimal
in case of hard to address regressions that might pop up.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Valentin Schneider <vschneid@redhat.com>
Link: https://patch.msgid.link/20251219101502.GB1132199@noisy.programming.kicks-ass.net

+5 -2
+3
kernel/Kconfig.preempt
··· 16 16 17 17 choice 18 18 prompt "Preemption Model" 19 + default PREEMPT_LAZY if ARCH_HAS_PREEMPT_LAZY 19 20 default PREEMPT_NONE 20 21 21 22 config PREEMPT_NONE 22 23 bool "No Forced Preemption (Server)" 23 24 depends on !PREEMPT_RT 25 + depends on ARCH_NO_PREEMPT 24 26 select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC 25 27 help 26 28 This is the traditional Linux preemption model, geared towards ··· 37 35 38 36 config PREEMPT_VOLUNTARY 39 37 bool "Voluntary Kernel Preemption (Desktop)" 38 + depends on !ARCH_HAS_PREEMPT_LAZY 40 39 depends on !ARCH_NO_PREEMPT 41 40 depends on !PREEMPT_RT 42 41 select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC
+1 -1
kernel/sched/core.c
··· 7553 7553 7554 7554 int sched_dynamic_mode(const char *str) 7555 7555 { 7556 - # ifndef CONFIG_PREEMPT_RT 7556 + # if !(defined(CONFIG_PREEMPT_RT) || defined(CONFIG_ARCH_HAS_PREEMPT_LAZY)) 7557 7557 if (!strcmp(str, "none")) 7558 7558 return preempt_dynamic_none; 7559 7559
+1 -1
kernel/sched/debug.c
··· 243 243 244 244 static int sched_dynamic_show(struct seq_file *m, void *v) 245 245 { 246 - int i = IS_ENABLED(CONFIG_PREEMPT_RT) * 2; 246 + int i = (IS_ENABLED(CONFIG_PREEMPT_RT) || IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY)) * 2; 247 247 int j; 248 248 249 249 /* Count entries in NULL terminated preempt_modes */