Re: [RFC/RFT PATCH 1/2] sched/core: Check and schedule ksoftirq
From: srinivas pandruvada
Date: Mon Jan 09 2023 - 21:33:46 EST
On Tue, 2022-12-20 at 22:18 +0100, Peter Zijlstra wrote:
> On Tue, Dec 20, 2022 at 09:51:09PM +0100, Peter Zijlstra wrote:
> > On Mon, Dec 19, 2022 at 02:54:55PM -0800, srinivas pandruvada
> > wrote:
> >
> > > But after ksoftirqd_run_end(), which will renable local irq, this
> > > may
> > > further cause more soft irq pending. Here RCU soft irq entry
> > > continues
> >
> > Right you are.. what about if we spell the idle.c thing like so
> > instead?
> >
> > Then we repeat the softirq thing every time we drop out of the idle
> > loop
> > for a reschedule.
>
> Uff, that obviously can't work because we already have preemption
> disabled here, this needs a bit more work. I think it's possible to
> re-arrange things a bit.
Didn't work.
Also when __do_softirq returns, softirq can be pending again. I think
if local_softirq_pending(), we can break do_idle() loop.
Thanks,
Srinivas
>
> I'll try and have a look tomorrow, but the kids have their xmas play
> at
> school so who knows what I'll get done.
>
> > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> > index f26ab2675f7d..6dce49813bcc 100644
> > --- a/kernel/sched/idle.c
> > +++ b/kernel/sched/idle.c
> > @@ -381,8 +381,13 @@ void play_idle_precise(u64 duration_ns, u64
> > latency_ns)
> > hrtimer_start(&it.timer, ns_to_ktime(duration_ns),
> > HRTIMER_MODE_REL_PINNED_HARD);
> >
> > - while (!READ_ONCE(it.done))
> > + while (!READ_ONCE(it.done)) {
> > + rt_mutex_lock(&per_cpu(ksoftirq_lock, cpu));
> > + __run_ksoftirqd(smp_processor_id());
> > + rt_mutex_unlock(&per_cpu(ksoftirq_lock, cpu));
> > +
> > do_idle();
> > + }
> >
> > cpuidle_use_deepest_state(0);
> > current->flags &= ~PF_IDLE;