lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANpmjNN7mW=7jjkXDPHV6=SbjAMYq=vFRDi+6aGFCdPFm1LZ-A@mail.gmail.com>
Date:   Wed, 10 Nov 2021 16:03:10 +0100
From:   Marco Elver <elver@...gle.com>
To:     Valentin Schneider <valentin.schneider@....com>
Cc:     Mike Galbraith <efault@....de>,
        Frederic Weisbecker <frederic@...nel.org>,
        linux-kernel@...r.kernel.org,
        Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH] sched: Split preemption model selection between DYNAMIC & !DYNAMIC

On Wed, 10 Nov 2021 at 15:45, Valentin Schneider
<valentin.schneider@....com> wrote:
>
> On 10/11/21 11:24, Valentin Schneider wrote:
> > Following Frederic's _STATIC suggestion, I got to the below. The nice thing
> > is if a defconfig picks say PREEMPT_VOLUNTARY and the arch supports
> > PREEMPT_DYNAMIC, then it'll pick PREEMPT_VOLUNTARY_BEHAVIOUR. The less nice
> > thing is that we end up selecting PREEMPT_STATIC for PREEMPT_DYNAMIC
> > kernels, naming's hard... Maybe _BUILD rather than _STATIC?
> >
>
> And now without a legacy compatibility layer crud...

If this works for everyone else, then I think this is the least
intrusive and hopefully won't require telling everyone about this
config change.

For the final version, it seems to be missing s/_BEHAVIOUR// in
kernel/sched/core.c.

And the kcsan_test.c change can be reverted, I think it's broken
either way now, because it wants the dynamic state (the test still
works in most configs, so fixing this isn't super urgent). Similarly
for kernel/trace/trace.c, which appears mainly cosmetic. So I'd defer
changing these until there are real helpers to get the true preemption
behaviour of the running system.

Thanks,
-- Marco

> ---
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 2776423a587e..9c7d774ef809 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -88,7 +88,7 @@
>  struct completion;
>  struct user;
>
> -#ifdef CONFIG_PREEMPT_VOLUNTARY
> +#ifdef CONFIG_PREEMPT_VOLUNTARY_BUILD
>
>  extern int __cond_resched(void);
>  # define might_resched() __cond_resched()
> diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
> index 1eaaa93c37bf..f2b71920024c 100644
> --- a/include/linux/vermagic.h
> +++ b/include/linux/vermagic.h
> @@ -15,7 +15,7 @@
>  #else
>  #define MODULE_VERMAGIC_SMP ""
>  #endif
> -#ifdef CONFIG_PREEMPT
> +#ifdef CONFIG_PREEMPT_BUILD
>  #define MODULE_VERMAGIC_PREEMPT "preempt "
>  #elif defined(CONFIG_PREEMPT_RT)
>  #define MODULE_VERMAGIC_PREEMPT "preempt_rt "
> @@ -39,9 +39,9 @@
>  #define MODULE_RANDSTRUCT_PLUGIN
>  #endif
>
> -#define VERMAGIC_STRING                                                \
> +#define VERMAGIC_STRING                                                        \
>         UTS_RELEASE " "                                                 \
> -       MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT                     \
> +       MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT                     \
>         MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS       \
>         MODULE_ARCH_VERMAGIC                                            \
>         MODULE_RANDSTRUCT_PLUGIN
> diff --git a/init/Makefile b/init/Makefile
> index 2846113677ee..04eeee12c076 100644
> --- a/init/Makefile
> +++ b/init/Makefile
> @@ -30,7 +30,7 @@ $(obj)/version.o: include/generated/compile.h
>  quiet_cmd_compile.h = CHK     $@
>        cmd_compile.h = \
>         $(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@       \
> -       "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)"    \
> +       "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT_BUILD)"      \
>         "$(CONFIG_PREEMPT_RT)" $(CONFIG_CC_VERSION_TEXT) "$(LD)"
>
>  include/generated/compile.h: FORCE
> diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
> index 60f1bfc3c7b2..ce77f0265660 100644
> --- a/kernel/Kconfig.preempt
> +++ b/kernel/Kconfig.preempt
> @@ -1,12 +1,23 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>
> +config PREEMPT_NONE_BUILD
> +       bool
> +
> +config PREEMPT_VOLUNTARY_BUILD
> +       bool
> +
> +config PREEMPT_BUILD
> +       bool
> +       select PREEMPTION
> +       select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
> +
>  choice
>         prompt "Preemption Model"
> -       default PREEMPT_NONE_BEHAVIOUR
> +       default PREEMPT_NONE
>
> -config PREEMPT_NONE_BEHAVIOUR
> +config PREEMPT_NONE
>         bool "No Forced Preemption (Server)"
> -       select PREEMPT_NONE if !PREEMPT_DYNAMIC
> +       select PREEMPT_NONE_BUILD if !PREEMPT_DYNAMIC
>         help
>           This is the traditional Linux preemption model, geared towards
>           throughput. It will still provide good latencies most of the
> @@ -18,10 +29,10 @@ config PREEMPT_NONE_BEHAVIOUR
>           raw processing power of the kernel, irrespective of scheduling
>           latencies.
>
> -config PREEMPT_VOLUNTARY_BEHAVIOUR
> +config PREEMPT_VOLUNTARY
>         bool "Voluntary Kernel Preemption (Desktop)"
>         depends on !ARCH_NO_PREEMPT
> -       select PREEMPT_VOLUNTARY if !PREEMPT_DYNAMIC
> +       select PREEMPT_VOLUNTARY_BUILD if !PREEMPT_DYNAMIC
>         help
>           This option reduces the latency of the kernel by adding more
>           "explicit preemption points" to the kernel code. These new
> @@ -37,10 +48,10 @@ config PREEMPT_VOLUNTARY_BEHAVIOUR
>
>           Select this if you are building a kernel for a desktop system.
>
> -config PREEMPT_BEHAVIOUR
> +config PREEMPT
>         bool "Preemptible Kernel (Low-Latency Desktop)"
>         depends on !ARCH_NO_PREEMPT
> -       select PREEMPT
> +       select PREEMPT_BUILD
>         help
>           This option reduces the latency of the kernel by making
>           all kernel code (that is not executing in a critical section)
> @@ -58,7 +69,7 @@ config PREEMPT_BEHAVIOUR
>
>  config PREEMPT_RT
>         bool "Fully Preemptible Kernel (Real-Time)"
> -       depends on EXPERT && ARCH_SUPPORTS_RT && !PREEMPT_DYNAMIC
> +       depends on EXPERT && ARCH_SUPPORTS_RT
>         select PREEMPTION
>         help
>           This option turns the kernel into a real-time kernel by replacing
> @@ -75,17 +86,6 @@ config PREEMPT_RT
>
>  endchoice
>
> -config PREEMPT_NONE
> -       bool
> -
> -config PREEMPT_VOLUNTARY
> -       bool
> -
> -config PREEMPT
> -       bool
> -       select PREEMPTION
> -       select UNINLINE_SPIN_UNLOCK if !ARCH_INLINE_SPIN_UNLOCK
> -
>  config PREEMPT_COUNT
>         bool
>
> @@ -95,8 +95,8 @@ config PREEMPTION
>
>  config PREEMPT_DYNAMIC
>         bool "Preemption behaviour defined on boot"
> -       depends on HAVE_PREEMPT_DYNAMIC
> -       select PREEMPT
> +       depends on HAVE_PREEMPT_DYNAMIC && !PREEMPT_RT
> +       select PREEMPT_BUILD
>         default y
>         help
>           This option allows to define the preemption model on the kernel
> diff --git a/kernel/kcsan/kcsan_test.c b/kernel/kcsan/kcsan_test.c
> index dc55fd5a36fc..845b17cf7811 100644
> --- a/kernel/kcsan/kcsan_test.c
> +++ b/kernel/kcsan/kcsan_test.c
> @@ -1005,13 +1005,13 @@ static const void *nthreads_gen_params(const void *prev, char *desc)
>         else
>                 nthreads *= 2;
>
> -       if (!IS_ENABLED(CONFIG_PREEMPT) || !IS_ENABLED(CONFIG_KCSAN_INTERRUPT_WATCHER)) {
> +       if (!IS_ENABLED(CONFIG_PREEMPTION) || !IS_ENABLED(CONFIG_KCSAN_INTERRUPT_WATCHER)) {
>                 /*
>                  * Without any preemption, keep 2 CPUs free for other tasks, one
>                  * of which is the main test case function checking for
>                  * completion or failure.
>                  */
> -               const long min_unused_cpus = IS_ENABLED(CONFIG_PREEMPT_NONE) ? 2 : 0;
> +               const long min_unused_cpus = IS_ENABLED(CONFIG_PREEMPT_NONE_BUILD) ? 2 : 0;
>                 const long min_required_cpus = 2 + min_unused_cpus;
>
>                 if (num_online_cpus() < min_required_cpus) {
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 7896d30d90f7..3b3226ffbafa 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -4271,11 +4271,11 @@ print_trace_header(struct seq_file *m, struct trace_iterator *iter)
>                    entries,
>                    total,
>                    buf->cpu,
> -#if defined(CONFIG_PREEMPT_NONE)
> +#if defined(CONFIG_PREEMPT_NONE_BUILD)
>                    "server",
> -#elif defined(CONFIG_PREEMPT_VOLUNTARY)
> +#elif defined(CONFIG_PREEMPT_VOLUNTARY_BUILD)
>                    "desktop",
> -#elif defined(CONFIG_PREEMPT)
> +#elif defined(CONFIG_PREEMPT_BUILD)
>                    "preempt",
>  #elif defined(CONFIG_PREEMPT_RT)
>                    "preempt_rt",

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ