Re: [PATCH v3] sched: async unthrottling for cfs bandwidth
From: Peter Zijlstra
Date: Mon Nov 21 2022 - 07:35:11 EST
On Fri, Nov 18, 2022 at 11:25:09AM -0800, Josh Don wrote:
> > Maybe have this function return false when local and save that cfs_rq in
> > a local var to process again later, dunno, that might turn messy.
>
> Maybe something like this? Apologies for inline diff formatting.
That looks entirely reasonable, not nearly as horrible as I feared. Let
me go make that happen.
> Note that one change we definitely want is the extra setting of
> throttled = true in the case that cfs_rq->runtime_remaining <= 0, to
> catch the case where we run out of runtime to distribute on the last
> entity in the list.
Done.
> > > +
> > > + /* Already enqueued */
> > > + if (SCHED_WARN_ON(!list_empty(&cfs_rq->throttled_csd_list)))
> > > + return;
> > > +
> > > + list_add_tail(&cfs_rq->throttled_csd_list, &rq->cfsb_csd_list);
> > > +
> > > + smp_call_function_single_async(cpu_of(rq), &rq->cfsb_csd);
> >
> > Hurmph.. so I was expecting something like:
> >
> > first = list_empty(&rq->cfsb_csd_list);
> > list_add_tail(&cfs_rq->throttled_csd_list, &rq->cfsb_csd_list);
> > if (first)
> > smp_call_function_single_async(cpu_of(rq), &rq->cfsb_csd);
> >
> > But I suppose I'm remembering the 'old' version. I don't think it is
> > broken as written. There's a very narrow window where you'll end up
> > sending a second IPI for naught, but meh.
>
> The CSD doesn't get unlocked until right before we call the func().
> But you're right that that's a (very) narrow window for an extra IPI.
> Please feel free to modify the patch with that diff if you like.
Since I was manually editing things, I did that too.
Please test the final version as found here:
https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/commit/?h=sched/core&id=4e3c1b7b489e218dfa576cd6af0680b975b8743e