Skip to content

Commit 6ef869e

Browse files
Michal Hockoingomolnar
authored andcommitted
preempt: Introduce CONFIG_PREEMPT_DYNAMIC
Preemption mode selection is currently hardcoded on Kconfig choices. Introduce a dedicated option to tune preemption flavour at boot time, This will be only available on architectures efficiently supporting static calls in order not to tempt with the feature against additional overhead that might be prohibitive or undesirable. CONFIG_PREEMPT_DYNAMIC is automatically selected by CONFIG_PREEMPT if the architecture provides the necessary support (CONFIG_STATIC_CALL_INLINE, CONFIG_GENERIC_ENTRY, and provide with __preempt_schedule_function() / __preempt_schedule_notrace_function()). Suggested-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> [peterz: relax requirement to HAVE_STATIC_CALL] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lkml.kernel.org/r/20210118141223.123667-5-frederic@kernel.org
1 parent 29fd019 commit 6ef869e

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎Documentation/admin-guide/kernel-parameters.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3916,6 +3916,13 @@
39163916
Format: {"off"}
39173917
Disable Hardware Transactional Memory
39183918

3919+
preempt= [KNL]
3920+
Select preemption mode if you have CONFIG_PREEMPT_DYNAMIC
3921+
none - Limited to cond_resched() calls
3922+
voluntary - Limited to cond_resched() and might_sleep() calls
3923+
full - Any section that isn't explicitly preempt disabled
3924+
can be preempted anytime.
3925+
39193926
print-fatal-signals=
39203927
[KNL] debug: print fatal signals
39213928

‎arch/Kconfig‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,15 @@ config HAVE_STATIC_CALL_INLINE
10901090
bool
10911091
depends on HAVE_STATIC_CALL
10921092

1093+
config HAVE_PREEMPT_DYNAMIC
1094+
bool
1095+
depends on HAVE_STATIC_CALL
1096+
depends on GENERIC_ENTRY
1097+
help
1098+
Select this if the architecture support boot time preempt setting
1099+
on top of static calls. It is strongly advised to support inline
1100+
static call to avoid any overhead.
1101+
10931102
config ARCH_WANT_LD_ORPHAN_WARN
10941103
bool
10951104
help

‎arch/x86/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ config X86
224224
select HAVE_STACK_VALIDATION if X86_64
225225
select HAVE_STATIC_CALL
226226
select HAVE_STATIC_CALL_INLINE if HAVE_STACK_VALIDATION
227+
select HAVE_PREEMPT_DYNAMIC
227228
select HAVE_RSEQ
228229
select HAVE_SYSCALL_TRACEPOINTS
229230
select HAVE_UNSTABLE_SCHED_CLOCK

‎kernel/Kconfig.preempt‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ config PREEMPT
4040
depends on !ARCH_NO_PREEMPT
4141
select PREEMPTION
4242
select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
43+
select PREEMPT_DYNAMIC if HAVE_PREEMPT_DYNAMIC
4344
help
4445
This option reduces the latency of the kernel by making
4546
all kernel code (that is not executing in a critical section)
@@ -80,3 +81,21 @@ config PREEMPT_COUNT
8081
config PREEMPTION
8182
bool
8283
select PREEMPT_COUNT
84+
85+
config PREEMPT_DYNAMIC
86+
bool
87+
help
88+
This option allows to define the preemption model on the kernel
89+
command line parameter and thus override the default preemption
90+
model defined during compile time.
91+
92+
The feature is primarily interesting for Linux distributions which
93+
provide a pre-built kernel binary to reduce the number of kernel
94+
flavors they offer while still offering different usecases.
95+
96+
The runtime overhead is negligible with HAVE_STATIC_CALL_INLINE enabled
97+
but if runtime patching is not available for the specific architecture
98+
then the potential overhead should be considered.
99+
100+
Interesting if you want the same pre-built kernel should be used for
101+
both Server and Desktop workloads.

0 commit comments

Comments
 (0)