crosvm/cros_async
Chirantan Ekbote 418cc5abac uring: Check if executor runs on current thread
Commit "1fcc8a8f io_uring: Make UringContext Sync" uncovered an issue
where wakeups were lost if a uring operation was added from a different
thread while the executor thread was blocked inside an io_uring_enter
call.   To fix this, PendingOperation calls UringContext::submit
whenever the pending IO is not yet completed and has not been submitted.

Unfortunately, since we tend to write code like
`r.read_to_vec(..).await`, this meant that we would call
UringContext::submit every time after adding a new operation to the
submit queue, kind of defeating the purpose of batching multiple IO ops
in a single syscall.  Instead only call UringContext::submit when the
current thread is not the same as the executor thread.  The executor
will submit all pending operations anyway the next time it calls
UringContext::wait so there's no need to do it from PendingOperation
when it is polled on the executor thread.

BUG=none
TEST=unit tests

Change-Id: Ia95f3844790d3392e074e3ab55a9c6ef59f29db2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2684063
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-02-15 14:54:22 +00:00
..
src uring: Check if executor runs on current thread 2021-02-15 14:54:22 +00:00
.build_test_skip build_test: misc options, improvements, amd bug fixes 2020-10-15 13:40:32 +00:00
Cargo.toml cros_async: Refactor executors 2021-01-25 08:52:27 +00:00