summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPeter Maydell2021-03-31 17:38:49 +0200
committerPeter Maydell2021-03-31 17:38:49 +0200
commit1bd16067b652cce41a9214d0c62c73d5b45ab4b1 (patch)
tree594b7ebcd1e1e348f5a25f7670af6e7d8d8072ac /include
parentMerge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.0-20210331' in... (diff)
parenttest-coroutine: Add rwlock downgrade test (diff)
downloadqemu-1bd16067b652cce41a9214d0c62c73d5b45ab4b1.tar.gz
qemu-1bd16067b652cce41a9214d0c62c73d5b45ab4b1.tar.xz
qemu-1bd16067b652cce41a9214d0c62c73d5b45ab4b1.zip
Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/block-pull-request' into staging
Pull request A fix for VDI image files and more generally for CoRwlock. # gpg: Signature made Wed 31 Mar 2021 10:50:39 BST # gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full] # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full] # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha-gitlab/tags/block-pull-request: test-coroutine: Add rwlock downgrade test test-coroutine: Add rwlock upgrade test coroutine-lock: Reimplement CoRwlock to fix downgrade bug coroutine-lock: Store the coroutine in the CoWaitRecord only once block/vdi: Don't assume that blocks are larger than VdiHeader block/vdi: When writing new bmap entry fails, don't leak the buffer Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/coroutine.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h
index 84eab6e3bf..ce5b9c6851 100644
--- a/include/qemu/coroutine.h
+++ b/include/qemu/coroutine.h
@@ -237,11 +237,15 @@ bool qemu_co_enter_next_impl(CoQueue *queue, QemuLockable *lock);
bool qemu_co_queue_empty(CoQueue *queue);
+typedef struct CoRwTicket CoRwTicket;
typedef struct CoRwlock {
- int pending_writer;
- int reader;
CoMutex mutex;
- CoQueue queue;
+
+ /* Number of readers, or -1 if owned for writing. */
+ int owners;
+
+ /* Waiting coroutines. */
+ QSIMPLEQ_HEAD(, CoRwTicket) tickets;
} CoRwlock;
/**
@@ -260,10 +264,9 @@ void qemu_co_rwlock_rdlock(CoRwlock *lock);
/**
* Write Locks the CoRwlock from a reader. This is a bit more efficient than
* @qemu_co_rwlock_unlock followed by a separate @qemu_co_rwlock_wrlock.
- * However, if the lock cannot be upgraded immediately, control is transferred
- * to the caller of the current coroutine. Also, @qemu_co_rwlock_upgrade
- * only overrides CoRwlock fairness if there are no concurrent readers, so
- * another writer might run while @qemu_co_rwlock_upgrade blocks.
+ * Note that if the lock cannot be upgraded immediately, control is transferred
+ * to the caller of the current coroutine; another writer might run while
+ * @qemu_co_rwlock_upgrade blocks.
*/
void qemu_co_rwlock_upgrade(CoRwlock *lock);