Improve futex usage
Get series with b4
b4 am [email protected] change-id 20241031-event-785a2f0dda4aVersions newest first
- v5 Latest13 patches 5 repliesIn review
- v411 patches 15 repliesSuperseded
- v310 patches 18 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 9 patches | 2 replies | Superseded | |
| v1 | 8 patches | 3 replies | Superseded |
Changes in v5 from the cover letter
- Updated the documentation of the state transitions for the non-futex variant.
- Placed patch "qemu-thread: Remove qatomic_read() in qemu_event_set()"
after all other code changes.
- Added patches "qemu-thread: Document QemuEvent" and
"qemu-thread: Document QemuEvent memory ordering".
- Link to v4: https://lore.kernel.org/qemu-devel/[email protected]
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/13 | futex: Check value after qemu_futex_wait()include/ tests/ util/ | +25 | 0 replies | |
| 2/13 | futex: Support Windowsinclude/ meson.build tests/ +3 more | +48 | 0 replies | |
| 3/13 | qemu-thread: Replace __linux__ with CONFIG_LINUXinclude/ util/ | +4 | 0 replies | |
| 4/13 | qemu-thread: Avoid futex abstraction for non-Linuxutil/ | +24 | 0 replies | |
| 5/13 | qemu-thread: Use futex for QemuEvent on Windowsinclude/ include/ include/ +4 more | +149 | 0 replies | |
| 6/13 | qemu-thread: Use futex if available for QemuLockCntinclude/ util/ | +5 | 0 replies | |
| 7/13 | migration: Replace QemuSemaphore with QemuEventmigration/ migration/ | +10 | 1 reply | |
| 8/13 | migration/colo: Replace QemuSemaphore with QemuEventmigration/ migration/ | +13 | 0 replies | |
| 9/13 | migration/postcopy: Replace QemuSemaphore with QemuEventmigration/ migration/ migration/ | +8 | 0 replies | |
| 10/13 | hw/display/apple-gfx: Replace QemuSemaphore with QemuEventhw/ | +5 | 0 replies | |
| 11/13 | qemu-thread: Remove qatomic_read() in qemu_event_set()util/ | +5 | 0 replies | |
| 12/13 | qemu-thread: Document QemuEventinclude/ | +10 | 0 replies | |
| 13/13 | qemu-thread: Document QemuEvent memory orderinginclude/ util/ | +66 | 0 replies |
Reviews trailers per patch
7 of 13 patches have a Reviewed-by or Acked-by.
| Patch | Philippe Mathieu-Daudé | Fabiano Rosas | Phil Dennis-Jordan | Peter Xu |
|---|---|---|---|---|
| 1/13 | ||||
| 2/13 | ||||
| 3/13 | R-b | |||
| 4/13 | T-b R-b | |||
| 5/13 | R-b | |||
| 6/13 | ||||
| 7/13 | R-b | R-b | ||
| 8/13 | R-b | R-b | ||
| 9/13 | R-b | |||
| 10/13 | R-b | |||
| 11/13 | ||||
| 12/13 | ||||
| 13/13 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.
Cover letter [PATCH v5 00/13] Improve futex usage
In a recent discussion, Phil Dennis-Jordan pointed out a quirk in QemuEvent destruction due to futex-like abstraction, which prevented the usage of QemuEvent in new and existing code[1]. With some more thoughts after this discussion, I also found other problem and room of improvement in futex usage. Here is a stack of patches to resolve them.
Patch "futex: Check value after qemu_futex_wait()" ensures qemu_futex_wait() is used in loops as suggested in the man page.
Patch "futex: Support Windows" implements futex functions for Windows.
Patch "qemu-thread: Avoid futex abstraction for non-Linux" and "qemu-thread: Use futex for QemuEvent on Windows" enable destroying QemuEvent immediately after qemu_event_wait().
Patch "qemu-thread: Use futex for QemuEvent on Windows" and "qemu-thread: Use futex if available for QemuLockCnt" make the use of futex functions added for Windows.
Patches "migration: Replace QemuSemaphore with QemuEvent", "migration/colo: Replace QemuSemaphore with QemuEvent", "migration/postcopy: Replace QemuSemaphore with QemuEvent", and "hw/display/apple-gfx: Replace QemuSemaphore with QemuEvent" replace some QemuSemaphores with QemuEvents, which can utilize futex. Some of them rely on that QemuEvent can be destroyed immediately after qemu_event_wait().
[1]: https://lore.kernel.org/r/CAAibmn3HZeDeK8FrYhHa1GGwc+N8rBuB2VvMRm7LCt0mUGmsYQ@mail.gmail.com
---
Changes in v5:
- Updated the documentation of the state transitions for the non-futex variant.
- Placed patch "qemu-thread: Remove qatomic_read() in qemu_event_set()"
after all other code changes.
- Added patches "qemu-thread: Document QemuEvent" and
"qemu-thread: Document QemuEvent memory ordering".
- Link to v4: https://lore.kernel.org/qemu-devel/[email protected]
Changes in v4:
- Added patch "qemu-thread: Remove qatomic_read() in qemu_event_set()".
- Renamed patch "futex: Replace __linux__ with CONFIG_LINUX" to
"qemu-thread: Replace __linux__ with CONFIG_LINUX".
- Reverted changes to convert rp_pong_acks to QemuEvent.
- Link to v3: https://lore.kernel.org/qemu-devel/[email protected]
Changes in v3:
- Fixed race between qemu_event_reset() and qemu_event_set().
- Prepared for spurious pthread_cond_wait() wakeups.
- Added patch "futex: Replace __linux__ with CONFIG_LINUX".
- Link to v2: https://lore.kernel.org/qemu-devel/[email protected]
Changes in v2:
- Rebased.
- Added patch
"hw/display/apple-gfx: Replace QemuSemaphore with QemuEvent".
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Akihiko Odaki (13):
futex: Check value after qemu_futex_wait()
futex: Support Windows
qemu-thread: Replace __linux__ with CONFIG_LINUX
qemu-thread: Avoid futex abstraction for non-Linux
qemu-thread: Use futex for QemuEvent on Windows
qemu-thread: Use futex if available for QemuLockCnt
migration: Replace QemuSemaphore with QemuEvent migration/colo: Replace QemuSemaphore with QemuEvent migration/postcopy: Replace QemuSemaphore with QemuEvent hw/display/apple-gfx: Replace QemuSemaphore with QemuEvent
qemu-thread: Remove qatomic_read() in qemu_event_set()
qemu-thread: Document QemuEvent
qemu-thread: Document QemuEvent memory ordering
meson.build | 2 + include/qemu/futex.h | 44 +++++++++++- include/qemu/lockcnt.h | 2 +- include/qemu/thread-posix.h | 9 --- include/qemu/thread-win32.h | 6 -- include/qemu/thread.h | 40 ++++++++++- migration/migration.h | 12 ++-- migration/colo.c | 20 +++--- migration/migration.c | 21 +++--- migration/postcopy-ram.c | 10 +-- migration/savevm.c | 2 +- tests/unit/test-aio-multithread.c | 6 +- util/event.c | 139 +++++++++++++++++++++++++++++++++++ util/lockcnt.c | 9 +-- util/qemu-thread-posix.c | 148 -------------------------------------- util/qemu-thread-win32.c | 129 --------------------------------- hw/display/apple-gfx.m | 10 +-- util/meson.build | 3 +- 18 files changed, 269 insertions(+), 343 deletions(-)
---
base-commit: f0737158b483e7ec2b2512145aeab888b85cc1f7
change-id: 20241031-event-785a2f0dda4a
Best regards,
Signature · 1 line
Akihiko Odaki <[email protected]>