Re: [PATCH] sched: Split preemption model selection between DYNAMIC & !DYNAMIC

From: Marco Elver
Date: Wed Nov 10 2021 - 10:16:44 EST


On Wed, 10 Nov 2021 at 16:03, Marco Elver <elver@xxxxxxxxxx> wrote:
[...]
> 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.

I just realised that in both these cases the original version is less
broken than the below, because the non-suffixed CONFIG_PREEMPT*
variables now denote the dynamic default. So if someone doesn't use
'preempt=' at boot, the original code will actually do the right
thing.

> > 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",