diff options
author | Stefan Hajnoczi | 2022-02-23 16:57:03 +0100 |
---|---|---|
committer | Stefan Hajnoczi | 2022-03-17 12:23:18 +0100 |
commit | fc8796465c6cd4091efe6a2f8b353f07324f49c7 (patch) | |
tree | c1d90f2342f0b9cc84f57d70ccf7cda07e6e20a6 /tests/unit/test-qobject-input-visitor.c | |
parent | aio-posix: fix build failure io_uring 2.2 (diff) | |
download | qemu-fc8796465c6cd4091efe6a2f8b353f07324f49c7.tar.gz qemu-fc8796465c6cd4091efe6a2f8b353f07324f49c7.tar.xz qemu-fc8796465c6cd4091efe6a2f8b353f07324f49c7.zip |
aio-posix: fix spurious ->poll_ready() callbacks in main loop
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 <stefanha@redhat.com>
Reported-by: Jason Wang <jasowang@redhat.com>
Tested-by: Jason Wang <jasowang@redhat.com>
Message-id: 20220223155703.136833-1-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/unit/test-qobject-input-visitor.c')
0 files changed, 0 insertions, 0 deletions