Skip to content

Commit 35772d6

Browse files
author
Peter Zijlstra
committed
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) <[email protected]> Reviewed-by: Sebastian Andrzej Siewior <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 7c70cb9 commit 35772d6

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

kernel/Kconfig.preempt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ choice
2020

2121
config PREEMPT_NONE
2222
bool "No Forced Preemption (Server)"
23+
depends on !PREEMPT_RT
2324
select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC
2425
help
2526
This is the traditional Linux preemption model, geared towards
@@ -35,6 +36,7 @@ config PREEMPT_NONE
3536
config PREEMPT_VOLUNTARY
3637
bool "Voluntary Kernel Preemption (Desktop)"
3738
depends on !ARCH_NO_PREEMPT
39+
depends on !PREEMPT_RT
3840
select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC
3941
help
4042
This option reduces the latency of the kernel by adding more
@@ -54,7 +56,7 @@ config PREEMPT_VOLUNTARY
5456
config PREEMPT
5557
bool "Preemptible Kernel (Low-Latency Desktop)"
5658
depends on !ARCH_NO_PREEMPT
57-
select PREEMPT_BUILD
59+
select PREEMPT_BUILD if !PREEMPT_DYNAMIC
5860
help
5961
This option reduces the latency of the kernel by making
6062
all kernel code (that is not executing in a critical section)
@@ -74,14 +76,16 @@ config PREEMPT_LAZY
7476
bool "Scheduler controlled preemption model"
7577
depends on !ARCH_NO_PREEMPT
7678
depends on ARCH_HAS_PREEMPT_LAZY
77-
select PREEMPT_BUILD
79+
select PREEMPT_BUILD if !PREEMPT_DYNAMIC
7880
help
7981
This option provides a scheduler driven preemption model that
8082
is fundamentally similar to full preemption, but is less
8183
eager to preempt SCHED_NORMAL tasks in an attempt to
8284
reduce lock holder preemption and recover some of the performance
8385
gains seen from using Voluntary preemption.
8486

87+
endchoice
88+
8589
config PREEMPT_RT
8690
bool "Fully Preemptible Kernel (Real-Time)"
8791
depends on EXPERT && ARCH_SUPPORTS_RT
@@ -99,8 +103,6 @@ config PREEMPT_RT
99103
Select this if you are building a kernel for systems which
100104
require real-time guarantees.
101105

102-
endchoice
103-
104106
config PREEMPT_COUNT
105107
bool
106108

@@ -110,7 +112,7 @@ config PREEMPTION
110112

111113
config PREEMPT_DYNAMIC
112114
bool "Preemption behaviour defined on boot"
113-
depends on HAVE_PREEMPT_DYNAMIC && !PREEMPT_RT
115+
depends on HAVE_PREEMPT_DYNAMIC
114116
select JUMP_LABEL if HAVE_PREEMPT_DYNAMIC_KEY
115117
select PREEMPT_BUILD
116118
default y if HAVE_PREEMPT_DYNAMIC_CALL

kernel/sched/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7450,11 +7450,13 @@ int preempt_dynamic_mode = preempt_dynamic_undefined;
74507450

74517451
int sched_dynamic_mode(const char *str)
74527452
{
7453+
#ifndef CONFIG_PREEMPT_RT
74537454
if (!strcmp(str, "none"))
74547455
return preempt_dynamic_none;
74557456

74567457
if (!strcmp(str, "voluntary"))
74577458
return preempt_dynamic_voluntary;
7459+
#endif
74587460

74597461
if (!strcmp(str, "full"))
74607462
return preempt_dynamic_full;

kernel/sched/debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ static int sched_dynamic_show(struct seq_file *m, void *v)
248248
"none", "voluntary", "full", "lazy",
249249
};
250250
int j = ARRAY_SIZE(preempt_modes) - !IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY);
251-
int i;
251+
int i = IS_ENABLED(CONFIG_PREEMPT_RT) * 2;
252252

253-
for (i = 0; i < j; i++) {
253+
for (; i < j; i++) {
254254
if (preempt_dynamic_mode == i)
255255
seq_puts(m, "(");
256256
seq_puts(m, preempt_modes[i]);

0 commit comments

Comments
 (0)