[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 0/8] Improve futex usage
From: |
Akihiko Odaki |
Subject: |
[PATCH 0/8] Improve futex usage |
Date: |
Wed, 25 Dec 2024 14:44:12 +0900 |
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", and
"migration/postcopy: 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
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
Akihiko Odaki (8):
futex: Check value after qemu_futex_wait()
futex: Support Windows
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
meson.build | 2 +
include/qemu/futex.h | 43 ++++++++++-
include/qemu/lockcnt.h | 2 +-
include/qemu/thread-posix.h | 9 ---
include/qemu/thread-win32.h | 6 --
include/qemu/thread.h | 11 ++-
migration/migration.h | 16 ++---
migration/colo.c | 20 +++---
migration/migration.c | 33 ++++-----
migration/postcopy-ram.c | 10 +--
migration/savevm.c | 2 +-
tests/unit/test-aio-multithread.c | 6 +-
util/event.c | 144 +++++++++++++++++++++++++++++++++++++
util/lockcnt.c | 9 +--
util/qemu-thread-posix.c | 148 --------------------------------------
util/qemu-thread-win32.c | 129 ---------------------------------
util/meson.build | 3 +-
17 files changed, 247 insertions(+), 346 deletions(-)
---
base-commit: 34754a3a627e1937be7f3daaa0c5e73d91c7d9b5
change-id: 20241031-event-785a2f0dda4a
Best regards,
--
Akihiko Odaki <akihiko.odaki@daynix.com>
- [PATCH 0/8] Improve futex usage,
Akihiko Odaki <=
- [PATCH 1/8] futex: Check value after qemu_futex_wait(), Akihiko Odaki, 2024/12/25
- [PATCH 2/8] futex: Support Windows, Akihiko Odaki, 2024/12/25
- [PATCH 3/8] qemu-thread: Avoid futex abstraction for non-Linux, Akihiko Odaki, 2024/12/25
- [PATCH 4/8] qemu-thread: Use futex for QemuEvent on Windows, Akihiko Odaki, 2024/12/25
- [PATCH 5/8] qemu-thread: Use futex if available for QemuLockCnt, Akihiko Odaki, 2024/12/25
- [PATCH 6/8] migration: Replace QemuSemaphore with QemuEvent, Akihiko Odaki, 2024/12/25
- [PATCH 7/8] migration/colo: Replace QemuSemaphore with QemuEvent, Akihiko Odaki, 2024/12/25