Re: [PATCH v4 2/2] io_uring: Add support for napi_busy_poll
From: Olivier Langlois
Date: Wed Mar 02 2022 - 00:12:43 EST
On Wed, 2022-03-02 at 02:31 +0800, Hao Xu wrote:
> > +static void io_blocking_napi_busy_loop(struct list_head
> > *napi_list,
> > + struct io_wait_queue *iowq)
> > +{
> > + unsigned long start_time =
> > + list_is_singular(napi_list) ? 0 :
> > + busy_loop_current_time();
> > +
> > + do {
> > + if (list_is_singular(napi_list)) {
> > + struct napi_entry *ne =
> > + list_first_entry(napi_list,
> > + struct napi_entry,
> > list);
> > +
> > + napi_busy_loop(ne->napi_id,
> > io_busy_loop_end, iowq,
> > + true, BUSY_POLL_BUDGET);
> > + io_check_napi_entry_timeout(ne);
> > + break;
> > + }
> > + } while (io_napi_busy_loop(napi_list) &&
> > + !io_busy_loop_end(iowq, start_time));
> > +}
> > +
>
> How about:
>
> if (list is singular) {
>
> do something;
>
> return;
>
> }
>
> while (!io_busy_loop_end() && io_napi_busy_loop())
>
> ;
>
>
> Btw, start_time seems not used in singular branch.
Hao,
it takes me few readings before being able to figure out the idea
behind your suggestions. Sorry about that!
So, if I get it correctly, you are proposing extract out the singular
block out of the while loop...
IMHO, this is not a good idea because you could start iterating the
do/while loop with a multiple entries list that ends up becoming a
singular list after one or few iterations.
Check what io_napi_busy_loop() is doing...
It does not look like that but a lot thoughts have been put into
writing io_blocking_napi_busy_loop()...