On Wed, Feb 23, 2022 at 03:57:03PM +0000, Stefan Hajnoczi wrote: > When ->poll() succeeds the AioHandler is placed on the ready list with > revents set to the magic value 0. This magic value causes > aio_dispatch_handler() to invoke ->poll_ready() instead of ->io_read() > for G_IO_IN or ->io_write() for G_IO_OUT. > > This magic value 0 hack works for the IOThread where AioHandlers are > placed on ->ready_list and processed by aio_dispatch_ready_handlers(). > It does not work for the main loop where all AioHandlers are processed > by aio_dispatch_handlers(), even those that are not ready and have a > revents value of 0. > > As a result the main loop invokes ->poll_ready() on AioHandlers that are > not ready. These spurious ->poll_ready() calls waste CPU cycles and > could lead to crashes if the code assumes ->poll() must have succeeded > before ->poll_ready() is called (a reasonable asumption but I haven't > seen it in practice). > > Stop using revents to track whether ->poll_ready() will be called on an > AioHandler. Introduce a separate AioHandler->poll_ready field instead. > This eliminates spurious ->poll_ready() calls in the main loop. > > Fixes: 826cc32423db2a99d184dbf4f507c737d7e7a4ae ("aio-posix: split poll check > from ready handler") > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> > --- > util/aio-posix.h | 1 + > util/aio-posix.c | 32 ++++++++++++++++++-------------- > 2 files changed, 19 insertions(+), 14 deletions(-)
Applied to my block tree: https://gitlab.com/stefanha/qemu/commits/block Stefan
signature.asc
Description: PGP signature