[PATCH 03/19] cpu/hotplug: Avoid busy-polling on archs where cpu_relax() is a no-op

Will Deacon will at kernel.org
Fri Sep 11 05:57:39 PDT 2026


On Fri, Sep 11, 2026 at 03:16:23PM +0800, Jinjie Ruan wrote:
> 在 2026/9/8 0:40, Will Deacon 写道:
> > diff --git a/kernel/cpu.c b/kernel/cpu.c
> > index 97a9bfe4edad..d9fe204f02cb 100644
> > --- a/kernel/cpu.c
> > +++ b/kernel/cpu.c
> > @@ -303,7 +303,13 @@ static inline void cpuhp_ap_update_sync_state(enum cpuhp_sync_state state)
> >  	(void)atomic_xchg(st, state);
> >  }
> >  
> > -void __weak arch_cpuhp_sync_state_poll(void) { cpu_relax(); }
> > +void __weak arch_cpuhp_sync_state_poll(atomic_t *st, int old)
> > +{
> > +	if (old < SYNC_STATE_ALIVE)
> > +		cpu_relax();
> > +	else
> > +		atomic_cond_read_relaxed(st, VAL != old);
> > +}
> 
> As sashiko pointed out, it seems that the else branch unreachable for
> the call of cpuhp_wait_for_sync_state(cpu, SYNC_STATE_ALIVE,
> SYNC_STATE_SHOULD_ONLINE), the old state can only be "SYNC_STATE_KICKED"
> or "SYNC_STATE_SHOULD_DIE", which go the if branch.

Ah yes, it's a harmless leftover from my initial (failed) attempt to use
cpuhp_wait_for_sync_state() in cpuhp_ap_sync_alive(). I can drop this
part and reword the commit message.

Will



More information about the linux-arm-kernel mailing list