All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] sched: Define default preempt dynamic boot mode on Kconfig
@ 2021-06-08 12:04 Frederic Weisbecker
  2021-06-08 12:04 ` [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig Frederic Weisbecker
  2021-06-08 12:04 ` [PATCH 2/2] sched: Always print out preempt dynamic state Frederic Weisbecker
  0 siblings, 2 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2021-06-08 12:04 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar; +Cc: LKML, Frederic Weisbecker

Make life easier for distros and automatic kernel robot testing.

git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
	sched/core

HEAD: 54b77d028543df2d5b091b5542e68e5fe2dca1b8

Thanks,
	Frederic
---

Frederic Weisbecker (2):
      sched: Add default dynamic preempt mode Kconfig
      sched: Always print out preempt dynamic state


 kernel/Kconfig.preempt | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
 kernel/sched/core.c    | 40 +++++++++++++++++++++++++++++++++----
 2 files changed, 89 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig
  2021-06-08 12:04 [PATCH 0/2] sched: Define default preempt dynamic boot mode on Kconfig Frederic Weisbecker
@ 2021-06-08 12:04 ` Frederic Weisbecker
  2021-06-08 13:55   ` Peter Zijlstra
  2021-06-08 13:55   ` Peter Zijlstra
  2021-06-08 12:04 ` [PATCH 2/2] sched: Always print out preempt dynamic state Frederic Weisbecker
  1 sibling, 2 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2021-06-08 12:04 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar; +Cc: LKML, Frederic Weisbecker

Currently the default behaviour for CONFIG_PREEMPT_DYNAMIC is
preempt=full. So distros always have to override that with the boot
option if it's not their default choice.

Make things more convenient for them with providing that choice at
Kconfig time.

This should also encourage automatic testing robots relying on randconfig
to run through all the various preempt dynamic flavours.

(Unfortunately this involved copy-pasting help text for static PREEMPT
Kconfig entries. Perhaps referring to them would be enough?)

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 kernel/Kconfig.preempt | 53 ++++++++++++++++++++++++++++++++++++++++++
 kernel/sched/core.c    | 23 +++++++++++++++++-
 2 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index bd7c4147b9a8..384110d1a215 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -100,6 +100,59 @@ config PREEMPT_DYNAMIC
 	  Interesting if you want the same pre-built kernel should be used for
 	  both Server and Desktop workloads.
 
+choice
+	prompt "Preemption dynamic default boot mode"
+	default PREEMPT_DYNAMIC_FULL
+	depends on PREEMPT_DYNAMIC
+
+config PREEMPT_DYNAMIC_NONE
+	bool "Default boot with no Forced Preemption (Server)"
+	help
+	  This is the traditional Linux preemption model, geared towards
+	  throughput. It will still provide good latencies most of the
+	  time, but there are no guarantees and occasional longer delays
+	  are possible.
+
+	  Select this option if you are building a kernel for a server or
+	  scientific/computation system, or if you want to maximize the
+	  raw processing power of the kernel, irrespective of scheduling
+	  latencies.
+
+config PREEMPT_DYNAMIC_VOLUNTARY
+	bool "Default boot with Voluntary Kernel Preemption (Desktop)"
+	help
+	  This option reduces the latency of the kernel by adding more
+	  "explicit preemption points" to the kernel code. These new
+	  preemption points have been selected to reduce the maximum
+	  latency of rescheduling, providing faster application reactions,
+	  at the cost of slightly lower throughput.
+
+	  This allows reaction to interactive events by allowing a
+	  low priority process to voluntarily preempt itself even if it
+	  is in kernel mode executing a system call. This allows
+	  applications to run more 'smoothly' even when the system is
+	  under load.
+
+	  Select this if you are building a kernel for a desktop system.
+
+config PREEMPT_DYNAMIC_FULL
+	bool "Default boot with Preemptible Kernel (Low-Latency Desktop)"
+	help
+	  This option reduces the latency of the kernel by making
+	  all kernel code (that is not executing in a critical section)
+	  preemptible.  This allows reaction to interactive events by
+	  permitting a low priority process to be preempted involuntarily
+	  even if it is in kernel mode executing a system call and would
+	  otherwise not be about to reach a natural preemption point.
+	  This allows applications to run more 'smoothly' even when the
+	  system is under load, at the cost of slightly lower throughput
+	  and a slight runtime overhead to kernel code.
+
+	  Select this if you are building a kernel for a desktop or
+	  embedded system with latency requirements in the milliseconds
+	  range.
+endchoice
+
 config SCHED_CORE
 	bool "Core Scheduling for SMT"
 	default y
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9e9a5be35cde..df47a8275c37 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6238,6 +6238,14 @@ enum {
 
 int preempt_dynamic_mode = preempt_dynamic_full;
 
+#if defined(CONFIG_PREEMPT_DYNAMIC_FULL)
+static __initdata int preempt_dynamic_mode_init = preempt_dynamic_full;
+#elif defined(CONFIG_PREEMPT_DYNAMIC_VOLUNTARY)
+static __initdata int preempt_dynamic_mode_init = preempt_dynamic_voluntary;
+#elif defined(CONFIG_PREEMPT_DYNAMIC_NONE)
+static __initdata int preempt_dynamic_mode_init = preempt_dynamic_none;
+#endif
+
 int sched_dynamic_mode(const char *str)
 {
 	if (!strcmp(str, "none"))
@@ -6254,6 +6262,9 @@ int sched_dynamic_mode(const char *str)
 
 void sched_dynamic_update(int mode)
 {
+	if (preempt_dynamic_mode == mode)
+		return;
+
 	/*
 	 * Avoid {NONE,VOLUNTARY} -> FULL transitions from ever ending up in
 	 * the ZERO state, which is invalid.
@@ -6304,13 +6315,22 @@ static int __init setup_preempt_mode(char *str)
 		return 1;
 	}
 
-	sched_dynamic_update(mode);
+	preempt_dynamic_mode_init = mode;
+
 	return 0;
 }
 __setup("preempt=", setup_preempt_mode);
 
+static void __init init_preempt(void)
+{
+	if (preempt_dynamic_mode_init != preempt_dynamic_full)
+		sched_dynamic_update(preempt_dynamic_mode_init);
+}
+#else
+static inline void init_preempt(void) { }
 #endif /* CONFIG_PREEMPT_DYNAMIC */
 
+
 /*
  * This is the entry point to schedule() from kernel preemption
  * off of irq context.
@@ -9079,6 +9099,7 @@ void __init sched_init(void)
 	psi_init();
 
 	init_uclamp();
+	init_preempt();
 
 	scheduler_running = 1;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] sched: Always print out preempt dynamic state
  2021-06-08 12:04 [PATCH 0/2] sched: Define default preempt dynamic boot mode on Kconfig Frederic Weisbecker
  2021-06-08 12:04 ` [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig Frederic Weisbecker
@ 2021-06-08 12:04 ` Frederic Weisbecker
  2021-06-08 13:56   ` Peter Zijlstra
  1 sibling, 1 reply; 10+ messages in thread
From: Frederic Weisbecker @ 2021-06-08 12:04 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar; +Cc: LKML, Frederic Weisbecker

Previously the preempt dynamic mode wasn't printed out if it wasn't
overriden with the "preempt=" boot option.

But now that the default preempt dynamic behaviour can be selected at
Kconfig time, we can't assume anymore that preempt=full is the default.
The only way to retrieve that information is to browse the kernel config
file.

Better print it out unconditionally then.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 kernel/sched/core.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index df47a8275c37..6b883adad8f7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6262,6 +6262,21 @@ int sched_dynamic_mode(const char *str)
 
 void sched_dynamic_update(int mode)
 {
+	switch (mode) {
+		case preempt_dynamic_none:
+			pr_info("Dynamic Preempt: none\n");
+			break;
+		case preempt_dynamic_voluntary:
+			pr_info("Dynamic Preempt: voluntary\n");
+			break;
+		case preempt_dynamic_full:
+			pr_info("Dynamic Preempt: full\n");
+			break;
+		default:
+			pr_info("Dynamic Preempt: incorrect\n");
+			return;
+	}
+
 	if (preempt_dynamic_mode == mode)
 		return;
 
@@ -6282,7 +6297,6 @@ void sched_dynamic_update(int mode)
 		static_call_update(preempt_schedule, NULL);
 		static_call_update(preempt_schedule_notrace, NULL);
 		static_call_update(irqentry_exit_cond_resched, NULL);
-		pr_info("Dynamic Preempt: none\n");
 		break;
 
 	case preempt_dynamic_voluntary:
@@ -6291,7 +6305,6 @@ void sched_dynamic_update(int mode)
 		static_call_update(preempt_schedule, NULL);
 		static_call_update(preempt_schedule_notrace, NULL);
 		static_call_update(irqentry_exit_cond_resched, NULL);
-		pr_info("Dynamic Preempt: voluntary\n");
 		break;
 
 	case preempt_dynamic_full:
@@ -6300,7 +6313,6 @@ void sched_dynamic_update(int mode)
 		static_call_update(preempt_schedule, __preempt_schedule_func);
 		static_call_update(preempt_schedule_notrace, __preempt_schedule_notrace_func);
 		static_call_update(irqentry_exit_cond_resched, irqentry_exit_cond_resched);
-		pr_info("Dynamic Preempt: full\n");
 		break;
 	}
 
@@ -6323,8 +6335,7 @@ __setup("preempt=", setup_preempt_mode);
 
 static void __init init_preempt(void)
 {
-	if (preempt_dynamic_mode_init != preempt_dynamic_full)
-		sched_dynamic_update(preempt_dynamic_mode_init);
+	sched_dynamic_update(preempt_dynamic_mode_init);
 }
 #else
 static inline void init_preempt(void) { }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig
  2021-06-08 12:04 ` [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig Frederic Weisbecker
@ 2021-06-08 13:55   ` Peter Zijlstra
  2021-06-08 14:04     ` Peter Zijlstra
  2021-06-09 11:13     ` Frederic Weisbecker
  2021-06-08 13:55   ` Peter Zijlstra
  1 sibling, 2 replies; 10+ messages in thread
From: Peter Zijlstra @ 2021-06-08 13:55 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: Ingo Molnar, LKML

On Tue, Jun 08, 2021 at 02:04:41PM +0200, Frederic Weisbecker wrote:
> Currently the default behaviour for CONFIG_PREEMPT_DYNAMIC is
> preempt=full. So distros always have to override that with the boot
> option if it's not their default choice.
> 
> Make things more convenient for them with providing that choice at
> Kconfig time.
> 
> This should also encourage automatic testing robots relying on randconfig
> to run through all the various preempt dynamic flavours.
> 
> (Unfortunately this involved copy-pasting help text for static PREEMPT
> Kconfig entries. Perhaps referring to them would be enough?)
> 
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> ---
>  kernel/Kconfig.preempt | 53 ++++++++++++++++++++++++++++++++++++++++++
>  kernel/sched/core.c    | 23 +++++++++++++++++-
>  2 files changed, 75 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
> index bd7c4147b9a8..384110d1a215 100644
> --- a/kernel/Kconfig.preempt
> +++ b/kernel/Kconfig.preempt
> @@ -100,6 +100,59 @@ config PREEMPT_DYNAMIC
>  	  Interesting if you want the same pre-built kernel should be used for
>  	  both Server and Desktop workloads.
>  
> +choice
> +	prompt "Preemption dynamic default boot mode"
> +	default PREEMPT_DYNAMIC_FULL
> +	depends on PREEMPT_DYNAMIC
> +
> +config PREEMPT_DYNAMIC_NONE
> +	bool "Default boot with no Forced Preemption (Server)"
> +	help
> +	  This is the traditional Linux preemption model, geared towards
> +	  throughput. It will still provide good latencies most of the
> +	  time, but there are no guarantees and occasional longer delays
> +	  are possible.
> +
> +	  Select this option if you are building a kernel for a server or
> +	  scientific/computation system, or if you want to maximize the
> +	  raw processing power of the kernel, irrespective of scheduling
> +	  latencies.
> +
> +config PREEMPT_DYNAMIC_VOLUNTARY
> +	bool "Default boot with Voluntary Kernel Preemption (Desktop)"
> +	help
> +	  This option reduces the latency of the kernel by adding more
> +	  "explicit preemption points" to the kernel code. These new
> +	  preemption points have been selected to reduce the maximum
> +	  latency of rescheduling, providing faster application reactions,
> +	  at the cost of slightly lower throughput.
> +
> +	  This allows reaction to interactive events by allowing a
> +	  low priority process to voluntarily preempt itself even if it
> +	  is in kernel mode executing a system call. This allows
> +	  applications to run more 'smoothly' even when the system is
> +	  under load.
> +
> +	  Select this if you are building a kernel for a desktop system.
> +
> +config PREEMPT_DYNAMIC_FULL
> +	bool "Default boot with Preemptible Kernel (Low-Latency Desktop)"
> +	help
> +	  This option reduces the latency of the kernel by making
> +	  all kernel code (that is not executing in a critical section)
> +	  preemptible.  This allows reaction to interactive events by
> +	  permitting a low priority process to be preempted involuntarily
> +	  even if it is in kernel mode executing a system call and would
> +	  otherwise not be about to reach a natural preemption point.
> +	  This allows applications to run more 'smoothly' even when the
> +	  system is under load, at the cost of slightly lower throughput
> +	  and a slight runtime overhead to kernel code.
> +
> +	  Select this if you are building a kernel for a desktop or
> +	  embedded system with latency requirements in the milliseconds
> +	  range.
> +endchoice
> +
>  config SCHED_CORE
>  	bool "Core Scheduling for SMT"
>  	default y

Urgh, would something like this work?

---
 kernel/Kconfig.preempt | 64 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 51 insertions(+), 13 deletions(-)

diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index bd7c4147b9a8..43c68a806e4e 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -1,11 +1,25 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
+config PREEMPT_COUNT
+       bool
+
+config PREEMPTION
+       bool
+       select PREEMPT_COUNT
+
+config PREEMPT_DYNAMIC_OPTION
+	bool
+	help
+	  Symbol that gates availablility of PREEMPT_DYNAMIC, selected
+	  by preemption models that can be dynamically selected.
+
 choice
 	prompt "Preemption Model"
-	default PREEMPT_NONE
+	default PREEMPT_TYPE_NONE
 
-config PREEMPT_NONE
+config PREEMPT_TYPE_NONE
 	bool "No Forced Preemption (Server)"
+	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
 	help
 	  This is the traditional Linux preemption model, geared towards
 	  throughput. It will still provide good latencies most of the
@@ -17,9 +31,10 @@ config PREEMPT_NONE
 	  raw processing power of the kernel, irrespective of scheduling
 	  latencies.
 
-config PREEMPT_VOLUNTARY
+config PREEMPT_TYPE_VOLUNTARY
 	bool "Voluntary Kernel Preemption (Desktop)"
 	depends on !ARCH_NO_PREEMPT
+	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
 	help
 	  This option reduces the latency of the kernel by adding more
 	  "explicit preemption points" to the kernel code. These new
@@ -35,12 +50,10 @@ config PREEMPT_VOLUNTARY
 
 	  Select this if you are building a kernel for a desktop system.
 
-config PREEMPT
+config PREEMPT_TYPE_FULL
 	bool "Preemptible Kernel (Low-Latency Desktop)"
 	depends on !ARCH_NO_PREEMPT
-	select PREEMPTION
-	select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
-	select PREEMPT_DYNAMIC if HAVE_PREEMPT_DYNAMIC
+	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
 	help
 	  This option reduces the latency of the kernel by making
 	  all kernel code (that is not executing in a critical section)
@@ -75,15 +88,24 @@ config PREEMPT_RT
 
 endchoice
 
-config PREEMPT_COUNT
-       bool
+# default model for PREEMPT_DYNAMIC
 
-config PREEMPTION
-       bool
-       select PREEMPT_COUNT
+config PREEMPT_DYNAMIC_NONE
+	bool
 
-config PREEMPT_DYNAMIC
+config PREEMPT_DYNAMIC_VOLUNTARY
+	bool
+
+config PREEMPT_DYNAMIC_FULL
 	bool
+
+config PREEMPT_DYNAMIC
+	bool "Dynamic Preemption Mode"
+	depends on PREEMPT_DYNAMIC_OPTION
+	select PREEMPT
+	select PREEMPT_DYNAMIC_NONE if PREEMPT_TYPE_NONE
+	select PREEMPT_DYNAMIC_VOLUNTARY if PREEMPT_TYPE_VOLUNTARY
+	select PREEMPT_DYNAMIC_FULL if PREEMPT_TYPE_FULL
 	help
 	  This option allows to define the preemption model on the kernel
 	  command line parameter and thus override the default preemption
@@ -100,6 +122,22 @@ config PREEMPT_DYNAMIC
 	  Interesting if you want the same pre-built kernel should be used for
 	  both Server and Desktop workloads.
 
+# actual preemption model
+
+config PREEMPT_NONE
+	bool
+	default y if !PREEMPT_DYNAMIC && PREEMPT_TYPE_NONE
+
+config PREEMPT_VOLUNTARY
+	bool
+	default y if !PREEMPT_DYNAMIC && PREEMPT_TYPE_VOLUNTARY
+
+config PREEMPT
+	bool
+	default y if !PREEMPT_DYNAMIC && PREEMPT_TYPE_FULL
+	select PREEMPTION
+	select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
+
 config SCHED_CORE
 	bool "Core Scheduling for SMT"
 	default y

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig
  2021-06-08 12:04 ` [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig Frederic Weisbecker
  2021-06-08 13:55   ` Peter Zijlstra
@ 2021-06-08 13:55   ` Peter Zijlstra
  2021-06-09 11:25     ` Frederic Weisbecker
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Zijlstra @ 2021-06-08 13:55 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: Ingo Molnar, LKML

On Tue, Jun 08, 2021 at 02:04:41PM +0200, Frederic Weisbecker wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 9e9a5be35cde..df47a8275c37 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6238,6 +6238,14 @@ enum {
>  
>  int preempt_dynamic_mode = preempt_dynamic_full;
>  
> +#if defined(CONFIG_PREEMPT_DYNAMIC_FULL)
> +static __initdata int preempt_dynamic_mode_init = preempt_dynamic_full;
> +#elif defined(CONFIG_PREEMPT_DYNAMIC_VOLUNTARY)
> +static __initdata int preempt_dynamic_mode_init = preempt_dynamic_voluntary;
> +#elif defined(CONFIG_PREEMPT_DYNAMIC_NONE)
> +static __initdata int preempt_dynamic_mode_init = preempt_dynamic_none;
> +#endif

Why does preempt_dynamic_mode_init exist? Why can't we simply set
preempt_dynamic_mode?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] sched: Always print out preempt dynamic state
  2021-06-08 12:04 ` [PATCH 2/2] sched: Always print out preempt dynamic state Frederic Weisbecker
@ 2021-06-08 13:56   ` Peter Zijlstra
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2021-06-08 13:56 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: Ingo Molnar, LKML

On Tue, Jun 08, 2021 at 02:04:42PM +0200, Frederic Weisbecker wrote:
> Previously the preempt dynamic mode wasn't printed out if it wasn't
> overriden with the "preempt=" boot option.
> 
> But now that the default preempt dynamic behaviour can be selected at
> Kconfig time, we can't assume anymore that preempt=full is the default.
> The only way to retrieve that information is to browse the kernel config
> file.
> 
> Better print it out unconditionally then.
> 
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> ---
>  kernel/sched/core.c | 21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index df47a8275c37..6b883adad8f7 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6262,6 +6262,21 @@ int sched_dynamic_mode(const char *str)
>  
>  void sched_dynamic_update(int mode)
>  {
> +	switch (mode) {
> +		case preempt_dynamic_none:
> +			pr_info("Dynamic Preempt: none\n");
> +			break;
> +		case preempt_dynamic_voluntary:
> +			pr_info("Dynamic Preempt: voluntary\n");
> +			break;
> +		case preempt_dynamic_full:
> +			pr_info("Dynamic Preempt: full\n");
> +			break;
> +		default:
> +			pr_info("Dynamic Preempt: incorrect\n");
> +			return;
> +	}

Indent fail; for vim, use: set cino=(0:0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig
  2021-06-08 13:55   ` Peter Zijlstra
@ 2021-06-08 14:04     ` Peter Zijlstra
  2021-06-09 11:27       ` Frederic Weisbecker
  2021-06-09 11:13     ` Frederic Weisbecker
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Zijlstra @ 2021-06-08 14:04 UTC (permalink / raw)
  To: Frederic Weisbecker; +Cc: Ingo Molnar, LKML

On Tue, Jun 08, 2021 at 03:55:09PM +0200, Peter Zijlstra wrote:
> Urgh, would something like this work?
> 
> ---
>  kernel/Kconfig.preempt | 64 ++++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 51 insertions(+), 13 deletions(-)
> 
> diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
> index bd7c4147b9a8..43c68a806e4e 100644
> --- a/kernel/Kconfig.preempt
> +++ b/kernel/Kconfig.preempt
> @@ -1,11 +1,25 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  
> +config PREEMPT_COUNT
> +       bool
> +
> +config PREEMPTION
> +       bool
> +       select PREEMPT_COUNT
> +
> +config PREEMPT_DYNAMIC_OPTION
> +	bool
> +	help
> +	  Symbol that gates availablility of PREEMPT_DYNAMIC, selected
> +	  by preemption models that can be dynamically selected.
> +
>  choice
>  	prompt "Preemption Model"
> +	default PREEMPT_TYPE_NONE
>  
> +config PREEMPT_TYPE_NONE
>  	bool "No Forced Preemption (Server)"
> +	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
>  	help
>  	  This is the traditional Linux preemption model, geared towards
>  	  throughput. It will still provide good latencies most of the
> @@ -17,9 +31,10 @@ config PREEMPT_NONE
>  	  raw processing power of the kernel, irrespective of scheduling
>  	  latencies.
>  
> +config PREEMPT_TYPE_VOLUNTARY
>  	bool "Voluntary Kernel Preemption (Desktop)"
>  	depends on !ARCH_NO_PREEMPT
> +	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
>  	help
>  	  This option reduces the latency of the kernel by adding more
>  	  "explicit preemption points" to the kernel code. These new
> @@ -35,12 +50,10 @@ config PREEMPT_VOLUNTARY
>  
>  	  Select this if you are building a kernel for a desktop system.
>  
> -config PREEMPT
> +config PREEMPT_TYPE_FULL
>  	bool "Preemptible Kernel (Low-Latency Desktop)"
>  	depends on !ARCH_NO_PREEMPT
> +	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
>  	help
>  	  This option reduces the latency of the kernel by making
>  	  all kernel code (that is not executing in a critical section)
> @@ -75,15 +88,24 @@ config PREEMPT_RT
>  
>  endchoice
>  
> +# default model for PREEMPT_DYNAMIC
>  
> +config PREEMPT_DYNAMIC_NONE
> +	bool
>  
> +config PREEMPT_DYNAMIC_VOLUNTARY
> +	bool
> +
> +config PREEMPT_DYNAMIC_FULL
>  	bool
> +
> +config PREEMPT_DYNAMIC
> +	bool "Dynamic Preemption Mode"
> +	depends on PREEMPT_DYNAMIC_OPTION
> +	select PREEMPT
> +	select PREEMPT_DYNAMIC_NONE if PREEMPT_TYPE_NONE
> +	select PREEMPT_DYNAMIC_VOLUNTARY if PREEMPT_TYPE_VOLUNTARY
> +	select PREEMPT_DYNAMIC_FULL if PREEMPT_TYPE_FULL

Arguably PREEMPT_DYNAMIC_{NONE,VOLUNTARY,FULL} are superfluous and the
default selection can use PREEMPT_TYPE_*.

>  	help
>  	  This option allows to define the preemption model on the kernel
>  	  command line parameter and thus override the default preemption
> @@ -100,6 +122,22 @@ config PREEMPT_DYNAMIC
>  	  Interesting if you want the same pre-built kernel should be used for
>  	  both Server and Desktop workloads.
>  
> +# actual preemption model
> +
> +config PREEMPT_NONE
> +	bool
> +	default y if !PREEMPT_DYNAMIC && PREEMPT_TYPE_NONE
> +
> +config PREEMPT_VOLUNTARY
> +	bool
> +	default y if !PREEMPT_DYNAMIC && PREEMPT_TYPE_VOLUNTARY
> +
> +config PREEMPT
> +	bool
> +	default y if !PREEMPT_DYNAMIC && PREEMPT_TYPE_FULL
> +	select PREEMPTION
> +	select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
> +
>  config SCHED_CORE
>  	bool "Core Scheduling for SMT"
>  	default y

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig
  2021-06-08 13:55   ` Peter Zijlstra
  2021-06-08 14:04     ` Peter Zijlstra
@ 2021-06-09 11:13     ` Frederic Weisbecker
  1 sibling, 0 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2021-06-09 11:13 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Ingo Molnar, LKML

On Tue, Jun 08, 2021 at 03:55:09PM +0200, Peter Zijlstra wrote:
> Urgh, would something like this work?

Oh yes much better thanks! lemme try again.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig
  2021-06-08 13:55   ` Peter Zijlstra
@ 2021-06-09 11:25     ` Frederic Weisbecker
  0 siblings, 0 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2021-06-09 11:25 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Ingo Molnar, LKML

On Tue, Jun 08, 2021 at 03:55:59PM +0200, Peter Zijlstra wrote:
> On Tue, Jun 08, 2021 at 02:04:41PM +0200, Frederic Weisbecker wrote:
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 9e9a5be35cde..df47a8275c37 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -6238,6 +6238,14 @@ enum {
> >  
> >  int preempt_dynamic_mode = preempt_dynamic_full;
> >  
> > +#if defined(CONFIG_PREEMPT_DYNAMIC_FULL)
> > +static __initdata int preempt_dynamic_mode_init = preempt_dynamic_full;
> > +#elif defined(CONFIG_PREEMPT_DYNAMIC_VOLUNTARY)
> > +static __initdata int preempt_dynamic_mode_init = preempt_dynamic_voluntary;
> > +#elif defined(CONFIG_PREEMPT_DYNAMIC_NONE)
> > +static __initdata int preempt_dynamic_mode_init = preempt_dynamic_none;
> > +#endif
> 
> Why does preempt_dynamic_mode_init exist? Why can't we simply set
> preempt_dynamic_mode?

To avoid the unconditional calls to static_call_update() on boot but I can do
it in a more simple way.

Thanks.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig
  2021-06-08 14:04     ` Peter Zijlstra
@ 2021-06-09 11:27       ` Frederic Weisbecker
  0 siblings, 0 replies; 10+ messages in thread
From: Frederic Weisbecker @ 2021-06-09 11:27 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Ingo Molnar, LKML

On Tue, Jun 08, 2021 at 04:04:47PM +0200, Peter Zijlstra wrote:
> On Tue, Jun 08, 2021 at 03:55:09PM +0200, Peter Zijlstra wrote:
> > Urgh, would something like this work?
> > 
> > ---
> >  kernel/Kconfig.preempt | 64 ++++++++++++++++++++++++++++++++++++++++----------
> >  1 file changed, 51 insertions(+), 13 deletions(-)
> > 
> > diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
> > index bd7c4147b9a8..43c68a806e4e 100644
> > --- a/kernel/Kconfig.preempt
> > +++ b/kernel/Kconfig.preempt
> > @@ -1,11 +1,25 @@
> >  # SPDX-License-Identifier: GPL-2.0-only
> >  
> > +config PREEMPT_COUNT
> > +       bool
> > +
> > +config PREEMPTION
> > +       bool
> > +       select PREEMPT_COUNT
> > +
> > +config PREEMPT_DYNAMIC_OPTION
> > +	bool
> > +	help
> > +	  Symbol that gates availablility of PREEMPT_DYNAMIC, selected
> > +	  by preemption models that can be dynamically selected.
> > +
> >  choice
> >  	prompt "Preemption Model"
> > +	default PREEMPT_TYPE_NONE
> >  
> > +config PREEMPT_TYPE_NONE
> >  	bool "No Forced Preemption (Server)"
> > +	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
> >  	help
> >  	  This is the traditional Linux preemption model, geared towards
> >  	  throughput. It will still provide good latencies most of the
> > @@ -17,9 +31,10 @@ config PREEMPT_NONE
> >  	  raw processing power of the kernel, irrespective of scheduling
> >  	  latencies.
> >  
> > +config PREEMPT_TYPE_VOLUNTARY
> >  	bool "Voluntary Kernel Preemption (Desktop)"
> >  	depends on !ARCH_NO_PREEMPT
> > +	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
> >  	help
> >  	  This option reduces the latency of the kernel by adding more
> >  	  "explicit preemption points" to the kernel code. These new
> > @@ -35,12 +50,10 @@ config PREEMPT_VOLUNTARY
> >  
> >  	  Select this if you are building a kernel for a desktop system.
> >  
> > -config PREEMPT
> > +config PREEMPT_TYPE_FULL
> >  	bool "Preemptible Kernel (Low-Latency Desktop)"
> >  	depends on !ARCH_NO_PREEMPT
> > +	select PREEMPT_DYNAMIC_OPTION if HAVE_PREEMPT_DYNAMIC
> >  	help
> >  	  This option reduces the latency of the kernel by making
> >  	  all kernel code (that is not executing in a critical section)
> > @@ -75,15 +88,24 @@ config PREEMPT_RT
> >  
> >  endchoice
> >  
> > +# default model for PREEMPT_DYNAMIC
> >  
> > +config PREEMPT_DYNAMIC_NONE
> > +	bool
> >  
> > +config PREEMPT_DYNAMIC_VOLUNTARY
> > +	bool
> > +
> > +config PREEMPT_DYNAMIC_FULL
> >  	bool
> > +
> > +config PREEMPT_DYNAMIC
> > +	bool "Dynamic Preemption Mode"
> > +	depends on PREEMPT_DYNAMIC_OPTION
> > +	select PREEMPT
> > +	select PREEMPT_DYNAMIC_NONE if PREEMPT_TYPE_NONE
> > +	select PREEMPT_DYNAMIC_VOLUNTARY if PREEMPT_TYPE_VOLUNTARY
> > +	select PREEMPT_DYNAMIC_FULL if PREEMPT_TYPE_FULL
> 
> Arguably PREEMPT_DYNAMIC_{NONE,VOLUNTARY,FULL} are superfluous and the
> default selection can use PREEMPT_TYPE_*.

Right, I'll try that.

Thanks.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-06-09 11:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 12:04 [PATCH 0/2] sched: Define default preempt dynamic boot mode on Kconfig Frederic Weisbecker
2021-06-08 12:04 ` [PATCH 1/2] sched: Add default dynamic preempt mode Kconfig Frederic Weisbecker
2021-06-08 13:55   ` Peter Zijlstra
2021-06-08 14:04     ` Peter Zijlstra
2021-06-09 11:27       ` Frederic Weisbecker
2021-06-09 11:13     ` Frederic Weisbecker
2021-06-08 13:55   ` Peter Zijlstra
2021-06-09 11:25     ` Frederic Weisbecker
2021-06-08 12:04 ` [PATCH 2/2] sched: Always print out preempt dynamic state Frederic Weisbecker
2021-06-08 13:56   ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.