[Top][All Lists]

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

Re: [Qemu-devel] [PATCH 1/1] Revert "linux-aio: Cancel BH if not needed"

From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 1/1] Revert "linux-aio: Cancel BH if not needed"
Date: Tue, 28 Jun 2016 09:41:49 +0100

On Fri, Jun 24, 2016 at 3:46 PM, Kevin Wolf <address@hidden> wrote:
>> diff --git a/block/linux-aio.c b/block/linux-aio.c
>> index e468960..fe7cece 100644
>> --- a/block/linux-aio.c
>> +++ b/block/linux-aio.c
>> @@ -149,8 +149,6 @@ static void qemu_laio_completion_bh(void *opaque)
>>      if (!s->io_q.plugged && !QSIMPLEQ_EMPTY(&s->io_q.pending)) {
>>          ioq_submit(s);
>>      }
>> -
>> -    qemu_bh_cancel(s->completion_bh);
>>  }
> Maybe if a nested event loops cancels the BH, it's missing on the next
> loop iteration. Before my patch, the nested callback happened to leave
> an additional BH around which the outer one actually needs.

The scenario you described is:

 -> cb1()
     -> aio_poll()
         -> qemu_laio_completion_bh()
         <- qemu_laio_completion_bh() (cancel BH)
     <- aio_poll()
 <- cb1()
 -> cb2()
     -> aio_poll()

This hang seems impossible because the qemu_laio_completion_bh() loop
processes all pending events.  Therefore cb1() consumes all pending
events and cb2() will not poll.

If new I/O was submitted during cb1() and cb2() waits for it, then the
eventfd will become readable upon completion and cb2() does not hang
in that case either.

If, instead of the original scenario, cb1() nests deeper then the BH
is still scheduled and events will be processed without a hang.

In summary, the job of scheduling the BH is not to force all nested
callbacks to call qemu_laio_completion_bh().  Only the first nested
callback needs the BH so that all pending events will be processed.


reply via email to

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