summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorStefan Hajnoczi2022-10-13 20:58:56 +0200
committerStefan Hajnoczi2022-10-26 20:56:42 +0200
commit0421b563ab4d947a388078331c057daa9b979f41 (patch)
tree2806a9b2fec0cb8e8865016d269f9b4ec6071457 /util
parentMerge tag 'trivial-branch-for-7.2-pull-request' of https://gitlab.com/laurent... (diff)
downloadqemu-0421b563ab4d947a388078331c057daa9b979f41.tar.gz
qemu-0421b563ab4d947a388078331c057daa9b979f41.tar.xz
qemu-0421b563ab4d947a388078331c057daa9b979f41.zip
coroutine: add flag to re-queue at front of CoQueue
When a coroutine wakes up it may determine that it must re-queue. Normally coroutines are pushed onto the back of the CoQueue, but for fairness it may be necessary to push it onto the front of the CoQueue. Add a flag to specify that the coroutine should be pushed onto the front of the CoQueue. A later patch will use this to ensure fairness in the bounce buffer CoQueue used by the blkio BlockDriver. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20221013185908.1297568-2-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/qemu-coroutine-lock.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c
index 15c82d9348..45c6b57374 100644
--- a/util/qemu-coroutine-lock.c
+++ b/util/qemu-coroutine-lock.c
@@ -39,10 +39,15 @@ void qemu_co_queue_init(CoQueue *queue)
QSIMPLEQ_INIT(&queue->entries);
}
-void coroutine_fn qemu_co_queue_wait_impl(CoQueue *queue, QemuLockable *lock)
+void coroutine_fn qemu_co_queue_wait_impl(CoQueue *queue, QemuLockable *lock,
+ CoQueueWaitFlags flags)
{
Coroutine *self = qemu_coroutine_self();
- QSIMPLEQ_INSERT_TAIL(&queue->entries, self, co_queue_next);
+ if (flags & CO_QUEUE_WAIT_FRONT) {
+ QSIMPLEQ_INSERT_HEAD(&queue->entries, self, co_queue_next);
+ } else {
+ QSIMPLEQ_INSERT_TAIL(&queue->entries, self, co_queue_next);
+ }
if (lock) {
qemu_lockable_unlock(lock);