[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/8] qemu-thread: Use futex if available for QemuLockCnt
From: |
Akihiko Odaki |
Subject: |
[PATCH 5/8] qemu-thread: Use futex if available for QemuLockCnt |
Date: |
Wed, 25 Dec 2024 14:44:17 +0900 |
This unlocks the futex-based implementation of QemuLockCnt to Windows.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
include/qemu/lockcnt.h | 2 +-
util/lockcnt.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/qemu/lockcnt.h b/include/qemu/lockcnt.h
index f4b62a3f7011..5a2800e3f182 100644
--- a/include/qemu/lockcnt.h
+++ b/include/qemu/lockcnt.h
@@ -17,7 +17,7 @@
typedef struct QemuLockCnt QemuLockCnt;
struct QemuLockCnt {
-#ifndef CONFIG_LINUX
+#ifndef HAVE_FUTEX
QemuMutex mutex;
#endif
unsigned count;
diff --git a/util/lockcnt.c b/util/lockcnt.c
index ca27d8e61a5c..92c9f8ceca88 100644
--- a/util/lockcnt.c
+++ b/util/lockcnt.c
@@ -12,10 +12,11 @@
#include "qemu/atomic.h"
#include "trace.h"
-#ifdef CONFIG_LINUX
-#include "qemu/futex.h"
+#ifdef HAVE_FUTEX
-/* On Linux, bits 0-1 are a futex-based lock, bits 2-31 are the counter.
+/*
+ * When futex is available, bits 0-1 are a futex-based lock, bits 2-31 are the
+ * counter.
* For the mutex algorithm see Ulrich Drepper's "Futexes Are Tricky" (ok,
* this is not the most relaxing citation I could make...). It is similar
* to mutex2 in the paper.
--
2.47.1
- [PATCH 0/8] Improve futex usage, Akihiko Odaki, 2024/12/25
- [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 <=
- [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
- [PATCH 8/8] migration/postcopy: Replace QemuSemaphore with QemuEvent, Akihiko Odaki, 2024/12/25