aboutsummaryrefslogtreecommitdiff
path: root/linux-headers
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2022-02-23 15:57:03 +0000
committerStefan Hajnoczi <stefanha@redhat.com>2022-03-17 11:23:18 +0000
commitfc8796465c6cd4091efe6a2f8b353f07324f49c7 (patch)
treec1d90f2342f0b9cc84f57d70ccf7cda07e6e20a6 /linux-headers
parent8a947c7a586e16a048894e1a0a73d154435e90ef (diff)
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 'linux-headers')
0 files changed, 0 insertions, 0 deletions