On Fri, Oct 20, 2023 at 03:48:36PM +0200, Peter Zijlstra wrote: > On Fri, Oct 20, 2023 at 02:31:13PM +0200, Frederic Weisbecker wrote: > > > Yeah I can't say I really like the old coverage of PF_IDLE either. The new one > > (after Liam's patch) is only halfway better defined though: it makes the boot > > CPU's idle behave quite well: PF_IDLE is set on idle entry. And secondary > > CPU's idle behave quite well also except when they go offline and then online > > again. And then the secondary boot code becomes PF_IDLE. > > Bah offline, yeah, we should just not do that :-) > > > We probably need something like this: > > > > diff --git a/kernel/cpu.c b/kernel/cpu.c > > index 3b9d5c7eb4a2..b24d7937b989 100644 > > --- a/kernel/cpu.c > > +++ b/kernel/cpu.c > > @@ -1394,7 +1394,9 @@ void cpuhp_report_idle_dead(void) > > { > > struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state); > > > > + current->flags &= ~PF_IDLE; > > BUG_ON(st->state != CPUHP_AP_OFFLINE); > > + > > rcutree_report_cpu_dead(); > > st->state = CPUHP_AP_IDLE_DEAD; > > /* > > @@ -1642,6 +1644,8 @@ void cpuhp_online_idle(enum cpuhp_state state) > > { > > struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state); > > > > + current->flags |= PF_IDLE; > > + > > /* Happens for the boot cpu */ > > if (state != CPUHP_AP_ONLINE_IDLE) > > return; > > Yeah that works I suppose. Booting up kernels being what it is, there might not be a completely pretty solution. Not that I would say "no" to such a solution should it appear, mind you! ;-) Thanx, Paul