Re: [tip: sched/core] sched/core: Initialize the idle task with preemption disabled
From: Valentin Schneider
Date: Wed Jul 07 2021 - 08:12:07 EST
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.