Message ID | CAN05THTh4oQeo0cRZ8bjY4i7L8TNNsY0mNJuDyjJzW7NBZ_V9g@mail.gmail.com |
---|---|
State | New |
Headers | show |
Il 22/05/2012 11:15, ronnie sahlberg ha scritto: > Hi, > > Now that I see what happens, I can easily workaround this in block/iscsi.c > by the patch below, but I dont know if this is the right thing to do. > > It does appear that here, when I use qemu_set_fd_handler() and add a > handler for "writeble" it takes 55ms before the event system notices > this and reacts. > > > > diff --git a/block/iscsi.c b/block/iscsi.c > index d37c4ee..1ebff0f 100644 > --- a/block/iscsi.c > +++ b/block/iscsi.c > @@ -105,6 +105,10 @@ iscsi_set_events(IscsiLun *iscsilun) > { > struct iscsi_context *iscsi = iscsilun->iscsi; > > + if (iscsi_which_events(iscsi) & POLLOUT) { > + iscsi_process_write(iscsilun); > + } > + > qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), iscsi_process_read, > (iscsi_which_events(iscsi) & POLLOUT) > ? iscsi_process_write : NULL, Doh, now I remember. Whenever you change the aio handlers you need to call qemu_notify_event() afterwards, if the handler may fire right away. The alternative is your patch, which is correct. Can you resend it with SoB? Paolo
On Tue, May 22, 2012 at 7:29 PM, Paolo Bonzini <pbonzini@redhat.com> wrote: > Il 22/05/2012 11:15, ronnie sahlberg ha scritto: >> Hi, >> >> Now that I see what happens, I can easily workaround this in block/iscsi.c >> by the patch below, but I dont know if this is the right thing to do. >> >> It does appear that here, when I use qemu_set_fd_handler() and add a >> handler for "writeble" it takes 55ms before the event system notices >> this and reacts. >> >> >> >> diff --git a/block/iscsi.c b/block/iscsi.c >> index d37c4ee..1ebff0f 100644 >> --- a/block/iscsi.c >> +++ b/block/iscsi.c >> @@ -105,6 +105,10 @@ iscsi_set_events(IscsiLun *iscsilun) >> { >> struct iscsi_context *iscsi = iscsilun->iscsi; >> >> + if (iscsi_which_events(iscsi) & POLLOUT) { >> + iscsi_process_write(iscsilun); >> + } >> + >> qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), iscsi_process_read, >> (iscsi_which_events(iscsi) & POLLOUT) >> ? iscsi_process_write : NULL, > > Doh, now I remember. Whenever you change the aio handlers you need to > call qemu_notify_event() afterwards, if the handler may fire right away. Thanks. I just confirmed that qemu_notify_event() fixes the issue. Ill send a patch that uses qemu_notify_event() and a comment why this is needed. regards ronnie sahlberg
None of the other drivers in block/*.c call qemu_notify_event() Do you you think those should be audited and have this call added to where required ? regards ronnie sahlberg On Tue, May 22, 2012 at 7:48 PM, ronnie sahlberg <ronniesahlberg@gmail.com> wrote: > On Tue, May 22, 2012 at 7:29 PM, Paolo Bonzini <pbonzini@redhat.com> wrote: >> Il 22/05/2012 11:15, ronnie sahlberg ha scritto: >>> Hi, >>> >>> Now that I see what happens, I can easily workaround this in block/iscsi.c >>> by the patch below, but I dont know if this is the right thing to do. >>> >>> It does appear that here, when I use qemu_set_fd_handler() and add a >>> handler for "writeble" it takes 55ms before the event system notices >>> this and reacts. >>> >>> >>> >>> diff --git a/block/iscsi.c b/block/iscsi.c >>> index d37c4ee..1ebff0f 100644 >>> --- a/block/iscsi.c >>> +++ b/block/iscsi.c >>> @@ -105,6 +105,10 @@ iscsi_set_events(IscsiLun *iscsilun) >>> { >>> struct iscsi_context *iscsi = iscsilun->iscsi; >>> >>> + if (iscsi_which_events(iscsi) & POLLOUT) { >>> + iscsi_process_write(iscsilun); >>> + } >>> + >>> qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), iscsi_process_read, >>> (iscsi_which_events(iscsi) & POLLOUT) >>> ? iscsi_process_write : NULL, >> >> Doh, now I remember. Whenever you change the aio handlers you need to >> call qemu_notify_event() afterwards, if the handler may fire right away. > > Thanks. I just confirmed that qemu_notify_event() fixes the issue. > Ill send a patch that uses qemu_notify_event() and a comment why this is needed. > > > regards > ronnie sahlberg
On 22.05.2012 14:03, ronnie sahlberg wrote: [] >>> Doh, now I remember. Whenever you change the aio handlers you need to >>> call qemu_notify_event() afterwards, if the handler may fire right away. >> >> Thanks. I just confirmed that qemu_notify_event() fixes the issue. >> Ill send a patch that uses qemu_notify_event() and a comment why this is needed. When I were writing network block driver I tried to not call qemu_aio_set_fd_handler() unless absolutely necessary -- that is, trying to write as much as possible till the next write returns EAGAIN, or to read till the next read returns EAGAIN. This way there's no need to call qemu_notify_event(). FWIW. /mjt
On Wed, May 23, 2012 at 2:31 AM, Michael Tokarev <mjt@tls.msk.ru> wrote: > On 22.05.2012 14:03, ronnie sahlberg wrote: > [] >>>> Doh, now I remember. Whenever you change the aio handlers you need to >>>> call qemu_notify_event() afterwards, if the handler may fire right away. >>> >>> Thanks. I just confirmed that qemu_notify_event() fixes the issue. >>> Ill send a patch that uses qemu_notify_event() and a comment why this is needed. > > When I were writing network block driver I tried to not call qemu_aio_set_fd_handler() > unless absolutely necessary -- that is, trying to write as much as possible till > the next write returns EAGAIN, or to read till the next read returns EAGAIN. This > way there's no need to call qemu_notify_event(). FWIW. > Good idea. Ill create a patch that keeps track of which events we are listening on already and only calling these functions when the events change. regards ronnie sahlberg
diff --git a/block/iscsi.c b/block/iscsi.c index d37c4ee..1ebff0f 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -105,6 +105,10 @@ iscsi_set_events(IscsiLun *iscsilun) { struct iscsi_context *iscsi = iscsilun->iscsi; + if (iscsi_which_events(iscsi) & POLLOUT) { + iscsi_process_write(iscsilun); + } + qemu_aio_set_fd_handler(iscsi_get_fd(iscsi), iscsi_process_read, (iscsi_which_events(iscsi) & POLLOUT) ? iscsi_process_write : NULL,