[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
- [Qemu-devel] [PATCH 04/16] io: add methods to set I/O handlers on AioContext, (continued)
[Qemu-devel] [PATCH 06/16] nbd: do not block on partial reply header reads, Paolo Bonzini, 2017/01/13
[Qemu-devel] [PATCH 08/16] qed: introduce qed_aio_start_io and qed_aio_next_io_cb, Paolo Bonzini, 2017/01/13