qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 01/16] aio: introduce aio_co_schedule and aio_co


From: Fam Zheng
Subject: Re: [Qemu-devel] [PATCH 01/16] aio: introduce aio_co_schedule and aio_co_wake
Date: Mon, 16 Jan 2017 20:44:53 +0800
User-agent: Mutt/1.7.1 (2016-10-04)

On Mon, 01/16 13:19, Paolo Bonzini wrote:
> >> +static void co_schedule_bh_cb(void *opaque)
> >> +{
> >> +    AioContext *ctx = opaque;
> >> +    QSLIST_HEAD(, Coroutine) straight, reversed;
> >> +
> >> +    QSLIST_MOVE_ATOMIC(&reversed, &ctx->scheduled_coroutines);
> >> +    QSLIST_INIT(&straight);
> > 
> > Worth special casing 1 element case?
> 
> Sounds like premature optimization; the QSLIST_MOVE_ATOMIC is going to
> be pretty expensive anyway.  Do you mean something like:
> 
>       if (QSLIST_EMPTY(&reversed)) {
>           return;
>       }
>       Coroutine *co = QSLIST_FIRST(&reversed);
>       if (!QSLIST_NEXT(co, co_scheduled_next)) {
>           straight = reversed;
>       } else {
>           do {
>                 ...
>           } while (!QSLIST_EMPTY(&reversed);
>       }
> 
>       do {
>           ...
>       } while (!QSLIST_EMPTY(&straight);
> 
> ?  Looks a but busy.  However, removing the QSLIST_EMPTY case and then
> using do/while may be a nice middle.

I think QSLIST_EMPTY is very unusual. I don't know if these are premature or
not, just asked because the !QSLIST_NEXT() case will be the most common one.

Fam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]