Re: [PATCH] smpboot: Run the thread function only once before parking

From: Sebastian Andrzej Siewior

Date: Wed Nov 04 2026 - 02:45:10 EST


On 2026-11-03 16:19:23 [-0500], Mani Tofigh wrote:
> > Would avoid it. On the other hand networking has HP-handler which
> > ensures that the queues of the offlined CPU are handled.
>
> True, cpu_active() is the better check there (and the RFS check a few
> lines up probably wants the same). I'm happy to send that to netdev
> separately.

No, I don't think it is needed.

> It only covers RPS though. A NIC IRQ still affine to that CPU, or a
> tasklet that's scheduled while disabled, keeps ksoftirqd busy the same
> way. So I'd keep the smpboot change and do the get_rps_cpu() one on top.

softirq/ ksoftirqd have an abort criteria so they don't run for too
long. If you manage to come up with a case that softirq/NET_RX
processing stalls the CPU bring down then we can think about it.
Otherwise I wouldn't bother.

> > > --- a/kernel/smpboot.c
> > > +++ b/kernel/smpboot.c
> > > @@ -119,9 +119,12 @@ static int smpboot_thread_fn(void *data)
> > > }
> > > should_run = td->status == HP_THREAD_ACTIVE && ht->thread_should_run(td->cpu);
> > > - if (kthread_should_park() && !should_run) {
> > > + if (kthread_should_park()) {
> > > __set_current_state(TASK_RUNNING);
> > > preempt_enable();
> > > + /* Run pending work once, new work may keep coming */
> > /*
> > * Run pending work once to handle queued work prior the parking
> > * request. Don't try to process everything in case new work
> > * continues to come and the handler has a hotplug notifier for
> > * everything that was enqueued later.
> > */
>
> Thanks! I will use that in v2.
>
> > The thread_fn should only run in HP_THREAD_ACTIVE case.
> >
> It does already, should_run includes td->status == HP_THREAD_ACTIVE.

Ach, indeed. Then it looks fine.

> Mani

Sebastian