Re: [tip: sched/core] sched/core: Initialize the idle task with preemption disabled

From: Alexey Kardashevskiy
Date: Wed Jul 07 2021 - 10:35:32 EST




On 08/07/2021 00:14, Guenter Roeck wrote:
On 7/7/21 5:11 AM, Valentin Schneider wrote:
On 07/07/21 14:03, Frederic Weisbecker wrote:
On Wed, Jul 07, 2021 at 12:55:20AM +0100, Valentin Schneider wrote:
Thanks for the report.

So somehow the init task ends up with a non-zero preempt_count()? Per
FORK_PREEMPT_COUNT we should exit __ret_from_fork() with a zero count, are
you hitting the WARN_ONCE() in finish_task_switch()?

Does CONFIG_DEBUG_PREEMPT=y yield anything interesting?

I can't make sense of this right now, but it's a bit late :) I'll grab some
toolchain+qemu tomorrow and go poke at it (and while at it I need to do the
same with powerpc).

One possible issue is that s390's init_idle_preempt_count() doesn't apply on the
target idle task but on the _current_ CPU. And since smp_init() ->
idle_threads_init() is actually called remotely, we are overwriting the current
CPU preempt_count() instead of the target one.

Indeed, this becomes quite obvious when tracing the preemption count
changes. This also means that s390 relied on the idle_thread_get() from the
hotplug machinery to properly setup the preempt count, rather than
init_idle_preempt_count() - which is quite yuck.

I'll write a patch for that and likely one for powerpc.


Can you reproduce the problem with a powerpc qemu emulation ?
If so, how do you reproduce it there ? Reason for asking is that I don't see
the problem with any of my powerpc emulations, and I would like to add test
case(s) if possible.

I can reproduce the problem on powerpc easily - qemu with "-smp 2" does it.


--
Alexey