sched: Enable PREEMPT_DYNAMIC for PREEMPT_RT

In order to enable PREEMPT_DYNAMIC for PREEMPT_RT, remove PREEMPT_RT
from the 'Preemption Model' choice. Strictly speaking PREEMPT_RT is
not a change in how preemption works, but rather it makes a ton more
code preemptible.

Notably, take away NONE and VOLUNTARY options for PREEMPT_RT, they make
no sense (but are techincally possible).

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lkml.kernel.org/r/20241007075055.441622332@infradead.org
This commit is contained in:
Peter Zijlstra 2024-10-04 14:46:56 +02:00
parent 7c70cb94d2
commit 35772d627b
3 changed files with 11 additions and 7 deletions

View File

@ -20,6 +20,7 @@ choice
config PREEMPT_NONE config PREEMPT_NONE
bool "No Forced Preemption (Server)" bool "No Forced Preemption (Server)"
depends on !PREEMPT_RT
select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC
help help
This is the traditional Linux preemption model, geared towards This is the traditional Linux preemption model, geared towards
@ -35,6 +36,7 @@ config PREEMPT_NONE
config PREEMPT_VOLUNTARY config PREEMPT_VOLUNTARY
bool "Voluntary Kernel Preemption (Desktop)" bool "Voluntary Kernel Preemption (Desktop)"
depends on !ARCH_NO_PREEMPT depends on !ARCH_NO_PREEMPT
depends on !PREEMPT_RT
select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC
help help
This option reduces the latency of the kernel by adding more This option reduces the latency of the kernel by adding more
@ -54,7 +56,7 @@ config PREEMPT_VOLUNTARY
config PREEMPT config PREEMPT
bool "Preemptible Kernel (Low-Latency Desktop)" bool "Preemptible Kernel (Low-Latency Desktop)"
depends on !ARCH_NO_PREEMPT depends on !ARCH_NO_PREEMPT
select PREEMPT_BUILD select PREEMPT_BUILD if !PREEMPT_DYNAMIC
help help
This option reduces the latency of the kernel by making This option reduces the latency of the kernel by making
all kernel code (that is not executing in a critical section) all kernel code (that is not executing in a critical section)
@ -74,7 +76,7 @@ config PREEMPT_LAZY
bool "Scheduler controlled preemption model" bool "Scheduler controlled preemption model"
depends on !ARCH_NO_PREEMPT depends on !ARCH_NO_PREEMPT
depends on ARCH_HAS_PREEMPT_LAZY depends on ARCH_HAS_PREEMPT_LAZY
select PREEMPT_BUILD select PREEMPT_BUILD if !PREEMPT_DYNAMIC
help help
This option provides a scheduler driven preemption model that This option provides a scheduler driven preemption model that
is fundamentally similar to full preemption, but is less is fundamentally similar to full preemption, but is less
@ -82,6 +84,8 @@ config PREEMPT_LAZY
reduce lock holder preemption and recover some of the performance reduce lock holder preemption and recover some of the performance
gains seen from using Voluntary preemption. gains seen from using Voluntary preemption.
endchoice
config PREEMPT_RT config PREEMPT_RT
bool "Fully Preemptible Kernel (Real-Time)" bool "Fully Preemptible Kernel (Real-Time)"
depends on EXPERT && ARCH_SUPPORTS_RT depends on EXPERT && ARCH_SUPPORTS_RT
@ -99,8 +103,6 @@ config PREEMPT_RT
Select this if you are building a kernel for systems which Select this if you are building a kernel for systems which
require real-time guarantees. require real-time guarantees.
endchoice
config PREEMPT_COUNT config PREEMPT_COUNT
bool bool
@ -110,7 +112,7 @@ config PREEMPTION
config PREEMPT_DYNAMIC config PREEMPT_DYNAMIC
bool "Preemption behaviour defined on boot" bool "Preemption behaviour defined on boot"
depends on HAVE_PREEMPT_DYNAMIC && !PREEMPT_RT depends on HAVE_PREEMPT_DYNAMIC
select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY
select PREEMPT_BUILD select PREEMPT_BUILD
default y if HAVE_PREEMPT_DYNAMIC_CALL default y if HAVE_PREEMPT_DYNAMIC_CALL

View File

@ -7450,11 +7450,13 @@ int preempt_dynamic_mode = preempt_dynamic_undefined;
int sched_dynamic_mode(const char *str) int sched_dynamic_mode(const char *str)
{ {
#ifndef CONFIG_PREEMPT_RT
if (!strcmp(str, "none")) if (!strcmp(str, "none"))
return preempt_dynamic_none; return preempt_dynamic_none;
if (!strcmp(str, "voluntary")) if (!strcmp(str, "voluntary"))
return preempt_dynamic_voluntary; return preempt_dynamic_voluntary;
#endif
if (!strcmp(str, "full")) if (!strcmp(str, "full"))
return preempt_dynamic_full; return preempt_dynamic_full;

View File

@ -248,9 +248,9 @@ static int sched_dynamic_show(struct seq_file *m, void *v)
"none", "voluntary", "full", "lazy", "none", "voluntary", "full", "lazy",
}; };
int j = ARRAY_SIZE(preempt_modes) - !IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY); int j = ARRAY_SIZE(preempt_modes) - !IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY);
int i; int i = IS_ENABLED(CONFIG_PREEMPT_RT) * 2;
for (i = 0; i < j; i++) { for (; i < j; i++) {
if (preempt_dynamic_mode == i) if (preempt_dynamic_mode == i)
seq_puts(m, "("); seq_puts(m, "(");
seq_puts(m, preempt_modes[i]); seq_puts(m, preempt_modes[i]);