* Mon Jun 27 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.0.0-7
- kvm-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch [bz#1952483] - kvm-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch [bz#1952483] - kvm-coroutine-win32-use-QEMU_DEFINE_STATIC_CO_TLS.patch [bz#1952483] - kvm-Enable-virtio-iommu-pci-on-x86_64.patch [bz#2094252] - kvm-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch [bz#2092788] - kvm-linux-aio-explain-why-max-batch-is-checked-in-laio_i.patch [bz#2092788] - Resolves: bz#1952483 (RFE: QEMU's coroutines fail with CFLAGS=-flto on non-x86_64 architectures) - Resolves: bz#2094252 (Compile the virtio-iommu device on x86_64) - Resolves: bz#2092788 (Stalled IO Operations in VM)
This commit is contained in:
parent
0552c42c39
commit
0ddb1bc433
41
kvm-Enable-virtio-iommu-pci-on-x86_64.patch
Normal file
41
kvm-Enable-virtio-iommu-pci-on-x86_64.patch
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
From c531a39171201f8a1d063e6af752e5d629c1b4bf Mon Sep 17 00:00:00 2001
|
||||||
|
From: Eric Auger <eric.auger@redhat.com>
|
||||||
|
Date: Thu, 9 Jun 2022 11:35:18 +0200
|
||||||
|
Subject: [PATCH 4/6] Enable virtio-iommu-pci on x86_64
|
||||||
|
|
||||||
|
RH-Author: Eric Auger <eric.auger@redhat.com>
|
||||||
|
RH-MergeRequest: 100: Enable virtio-iommu-pci on x86_64
|
||||||
|
RH-Commit: [1/1] a164af477efc7cb9d3d76a0e644f198f7c9fb2b5 (eauger1/centos-qemu-kvm)
|
||||||
|
RH-Bugzilla: 2094252
|
||||||
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
||||||
|
RH-Acked-by: MST <mst@redhat.com>
|
||||||
|
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
||||||
|
|
||||||
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094252
|
||||||
|
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=45871185
|
||||||
|
Upstream Status: RHEL-only
|
||||||
|
Tested: With virtio-net-pci and virtio-block-pci
|
||||||
|
|
||||||
|
let's enable the virtio-iommu-pci device on x86_64 by
|
||||||
|
turning CONFIG_VIRTIO_IOMMU on.
|
||||||
|
|
||||||
|
Signed-off-by: Eric Auger <eric.auger@redhat.com>
|
||||||
|
---
|
||||||
|
configs/devices/x86_64-softmmu/x86_64-rh-devices.mak | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak b/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
|
||||||
|
index d0c9e66641..3850b9de72 100644
|
||||||
|
--- a/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
|
||||||
|
+++ b/configs/devices/x86_64-softmmu/x86_64-rh-devices.mak
|
||||||
|
@@ -90,6 +90,7 @@ CONFIG_VHOST_USER_BLK=y
|
||||||
|
CONFIG_VIRTIO_MEM=y
|
||||||
|
CONFIG_VIRTIO_PCI=y
|
||||||
|
CONFIG_VIRTIO_VGA=y
|
||||||
|
+CONFIG_VIRTIO_IOMMU=y
|
||||||
|
CONFIG_VMMOUSE=y
|
||||||
|
CONFIG_VMPORT=y
|
||||||
|
CONFIG_VTD=y
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
132
kvm-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
Normal file
132
kvm-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
From ffbd90e5f4eba620c7cd631b04f0ed31beb22ffa Mon Sep 17 00:00:00 2001
|
||||||
|
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Date: Tue, 17 May 2022 12:07:56 +0100
|
||||||
|
Subject: [PATCH 1/6] coroutine-ucontext: use QEMU_DEFINE_STATIC_CO_TLS()
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
RH-MergeRequest: 89: coroutine: use coroutine TLS macros to protect thread-local variables
|
||||||
|
RH-Commit: [1/3] a9782fe8e919c4bd317b7e8744c7ff57d898add3 (stefanha/centos-stream-qemu-kvm)
|
||||||
|
RH-Bugzilla: 1952483
|
||||||
|
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
|
||||||
|
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
||||||
|
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
|
||||||
|
Thread-Local Storage variables cannot be used directly from coroutine
|
||||||
|
code because the compiler may optimize TLS variable accesses across
|
||||||
|
qemu_coroutine_yield() calls. When the coroutine is re-entered from
|
||||||
|
another thread the TLS variables from the old thread must no longer be
|
||||||
|
used.
|
||||||
|
|
||||||
|
Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
|
||||||
|
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Message-Id: <20220307153853.602859-2-stefanha@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
(cherry picked from commit 34145a307d849d0b6734d0222a7aa0bb9eef7407)
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
---
|
||||||
|
util/coroutine-ucontext.c | 38 ++++++++++++++++++++++++--------------
|
||||||
|
1 file changed, 24 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/util/coroutine-ucontext.c b/util/coroutine-ucontext.c
|
||||||
|
index 904b375192..127d5a13c8 100644
|
||||||
|
--- a/util/coroutine-ucontext.c
|
||||||
|
+++ b/util/coroutine-ucontext.c
|
||||||
|
@@ -25,6 +25,7 @@
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include <ucontext.h>
|
||||||
|
#include "qemu/coroutine_int.h"
|
||||||
|
+#include "qemu/coroutine-tls.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_VALGRIND_H
|
||||||
|
#include <valgrind/valgrind.h>
|
||||||
|
@@ -66,8 +67,8 @@ typedef struct {
|
||||||
|
/**
|
||||||
|
* Per-thread coroutine bookkeeping
|
||||||
|
*/
|
||||||
|
-static __thread CoroutineUContext leader;
|
||||||
|
-static __thread Coroutine *current;
|
||||||
|
+QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current);
|
||||||
|
+QEMU_DEFINE_STATIC_CO_TLS(CoroutineUContext, leader);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* va_args to makecontext() must be type 'int', so passing
|
||||||
|
@@ -97,14 +98,15 @@ static inline __attribute__((always_inline))
|
||||||
|
void finish_switch_fiber(void *fake_stack_save)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_ASAN
|
||||||
|
+ CoroutineUContext *leaderp = get_ptr_leader();
|
||||||
|
const void *bottom_old;
|
||||||
|
size_t size_old;
|
||||||
|
|
||||||
|
__sanitizer_finish_switch_fiber(fake_stack_save, &bottom_old, &size_old);
|
||||||
|
|
||||||
|
- if (!leader.stack) {
|
||||||
|
- leader.stack = (void *)bottom_old;
|
||||||
|
- leader.stack_size = size_old;
|
||||||
|
+ if (!leaderp->stack) {
|
||||||
|
+ leaderp->stack = (void *)bottom_old;
|
||||||
|
+ leaderp->stack_size = size_old;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_TSAN
|
||||||
|
@@ -161,8 +163,10 @@ static void coroutine_trampoline(int i0, int i1)
|
||||||
|
|
||||||
|
/* Initialize longjmp environment and switch back the caller */
|
||||||
|
if (!sigsetjmp(self->env, 0)) {
|
||||||
|
- start_switch_fiber_asan(COROUTINE_YIELD, &fake_stack_save, leader.stack,
|
||||||
|
- leader.stack_size);
|
||||||
|
+ CoroutineUContext *leaderp = get_ptr_leader();
|
||||||
|
+
|
||||||
|
+ start_switch_fiber_asan(COROUTINE_YIELD, &fake_stack_save,
|
||||||
|
+ leaderp->stack, leaderp->stack_size);
|
||||||
|
start_switch_fiber_tsan(&fake_stack_save, self, true); /* true=caller */
|
||||||
|
siglongjmp(*(sigjmp_buf *)co->entry_arg, 1);
|
||||||
|
}
|
||||||
|
@@ -297,7 +301,7 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
|
||||||
|
int ret;
|
||||||
|
void *fake_stack_save = NULL;
|
||||||
|
|
||||||
|
- current = to_;
|
||||||
|
+ set_current(to_);
|
||||||
|
|
||||||
|
ret = sigsetjmp(from->env, 0);
|
||||||
|
if (ret == 0) {
|
||||||
|
@@ -315,18 +319,24 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
|
||||||
|
|
||||||
|
Coroutine *qemu_coroutine_self(void)
|
||||||
|
{
|
||||||
|
- if (!current) {
|
||||||
|
- current = &leader.base;
|
||||||
|
+ Coroutine *self = get_current();
|
||||||
|
+ CoroutineUContext *leaderp = get_ptr_leader();
|
||||||
|
+
|
||||||
|
+ if (!self) {
|
||||||
|
+ self = &leaderp->base;
|
||||||
|
+ set_current(self);
|
||||||
|
}
|
||||||
|
#ifdef CONFIG_TSAN
|
||||||
|
- if (!leader.tsan_co_fiber) {
|
||||||
|
- leader.tsan_co_fiber = __tsan_get_current_fiber();
|
||||||
|
+ if (!leaderp->tsan_co_fiber) {
|
||||||
|
+ leaderp->tsan_co_fiber = __tsan_get_current_fiber();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
- return current;
|
||||||
|
+ return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool qemu_in_coroutine(void)
|
||||||
|
{
|
||||||
|
- return current && current->caller;
|
||||||
|
+ Coroutine *self = get_current();
|
||||||
|
+
|
||||||
|
+ return self && self->caller;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
139
kvm-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
Normal file
139
kvm-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
From 9c2e55d25fec6ffb21e344513b7dbeed7e21f641 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Date: Tue, 17 May 2022 12:08:04 +0100
|
||||||
|
Subject: [PATCH 2/6] coroutine: use QEMU_DEFINE_STATIC_CO_TLS()
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
RH-MergeRequest: 89: coroutine: use coroutine TLS macros to protect thread-local variables
|
||||||
|
RH-Commit: [2/3] 68a8847e406e2eace6ddc31b0c5676a60600d606 (stefanha/centos-stream-qemu-kvm)
|
||||||
|
RH-Bugzilla: 1952483
|
||||||
|
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
|
||||||
|
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
||||||
|
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
|
||||||
|
Thread-Local Storage variables cannot be used directly from coroutine
|
||||||
|
code because the compiler may optimize TLS variable accesses across
|
||||||
|
qemu_coroutine_yield() calls. When the coroutine is re-entered from
|
||||||
|
another thread the TLS variables from the old thread must no longer be
|
||||||
|
used.
|
||||||
|
|
||||||
|
Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
|
||||||
|
The alloc_pool QSLIST needs a typedef so the return value of
|
||||||
|
get_ptr_alloc_pool() can be stored in a local variable.
|
||||||
|
|
||||||
|
One example of why this code is necessary: a coroutine that yields
|
||||||
|
before calling qemu_coroutine_create() to create another coroutine is
|
||||||
|
affected by the TLS issue.
|
||||||
|
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Message-Id: <20220307153853.602859-3-stefanha@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
(cherry picked from commit ac387a08a9c9f6b36757da912f0339c25f421f90)
|
||||||
|
|
||||||
|
Conflicts:
|
||||||
|
- Context conflicts due to commit 5411171c3ef4 ("coroutine: Revert to
|
||||||
|
constant batch size").
|
||||||
|
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
---
|
||||||
|
util/qemu-coroutine.c | 41 ++++++++++++++++++++++++-----------------
|
||||||
|
1 file changed, 24 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c
|
||||||
|
index 804f672e0a..4a8bd63ef0 100644
|
||||||
|
--- a/util/qemu-coroutine.c
|
||||||
|
+++ b/util/qemu-coroutine.c
|
||||||
|
@@ -18,6 +18,7 @@
|
||||||
|
#include "qemu/atomic.h"
|
||||||
|
#include "qemu/coroutine.h"
|
||||||
|
#include "qemu/coroutine_int.h"
|
||||||
|
+#include "qemu/coroutine-tls.h"
|
||||||
|
#include "block/aio.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -35,17 +36,20 @@ enum {
|
||||||
|
static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
|
||||||
|
static unsigned int pool_max_size = POOL_INITIAL_MAX_SIZE;
|
||||||
|
static unsigned int release_pool_size;
|
||||||
|
-static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
|
||||||
|
-static __thread unsigned int alloc_pool_size;
|
||||||
|
-static __thread Notifier coroutine_pool_cleanup_notifier;
|
||||||
|
+
|
||||||
|
+typedef QSLIST_HEAD(, Coroutine) CoroutineQSList;
|
||||||
|
+QEMU_DEFINE_STATIC_CO_TLS(CoroutineQSList, alloc_pool);
|
||||||
|
+QEMU_DEFINE_STATIC_CO_TLS(unsigned int, alloc_pool_size);
|
||||||
|
+QEMU_DEFINE_STATIC_CO_TLS(Notifier, coroutine_pool_cleanup_notifier);
|
||||||
|
|
||||||
|
static void coroutine_pool_cleanup(Notifier *n, void *value)
|
||||||
|
{
|
||||||
|
Coroutine *co;
|
||||||
|
Coroutine *tmp;
|
||||||
|
+ CoroutineQSList *alloc_pool = get_ptr_alloc_pool();
|
||||||
|
|
||||||
|
- QSLIST_FOREACH_SAFE(co, &alloc_pool, pool_next, tmp) {
|
||||||
|
- QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
|
||||||
|
+ QSLIST_FOREACH_SAFE(co, alloc_pool, pool_next, tmp) {
|
||||||
|
+ QSLIST_REMOVE_HEAD(alloc_pool, pool_next);
|
||||||
|
qemu_coroutine_delete(co);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -55,27 +59,30 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry, void *opaque)
|
||||||
|
Coroutine *co = NULL;
|
||||||
|
|
||||||
|
if (CONFIG_COROUTINE_POOL) {
|
||||||
|
- co = QSLIST_FIRST(&alloc_pool);
|
||||||
|
+ CoroutineQSList *alloc_pool = get_ptr_alloc_pool();
|
||||||
|
+
|
||||||
|
+ co = QSLIST_FIRST(alloc_pool);
|
||||||
|
if (!co) {
|
||||||
|
if (release_pool_size > POOL_MIN_BATCH_SIZE) {
|
||||||
|
/* Slow path; a good place to register the destructor, too. */
|
||||||
|
- if (!coroutine_pool_cleanup_notifier.notify) {
|
||||||
|
- coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup;
|
||||||
|
- qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier);
|
||||||
|
+ Notifier *notifier = get_ptr_coroutine_pool_cleanup_notifier();
|
||||||
|
+ if (!notifier->notify) {
|
||||||
|
+ notifier->notify = coroutine_pool_cleanup;
|
||||||
|
+ qemu_thread_atexit_add(notifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is not exact; there could be a little skew between
|
||||||
|
* release_pool_size and the actual size of release_pool. But
|
||||||
|
* it is just a heuristic, it does not need to be perfect.
|
||||||
|
*/
|
||||||
|
- alloc_pool_size = qatomic_xchg(&release_pool_size, 0);
|
||||||
|
- QSLIST_MOVE_ATOMIC(&alloc_pool, &release_pool);
|
||||||
|
- co = QSLIST_FIRST(&alloc_pool);
|
||||||
|
+ set_alloc_pool_size(qatomic_xchg(&release_pool_size, 0));
|
||||||
|
+ QSLIST_MOVE_ATOMIC(alloc_pool, &release_pool);
|
||||||
|
+ co = QSLIST_FIRST(alloc_pool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (co) {
|
||||||
|
- QSLIST_REMOVE_HEAD(&alloc_pool, pool_next);
|
||||||
|
- alloc_pool_size--;
|
||||||
|
+ QSLIST_REMOVE_HEAD(alloc_pool, pool_next);
|
||||||
|
+ set_alloc_pool_size(get_alloc_pool_size() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -99,9 +106,9 @@ static void coroutine_delete(Coroutine *co)
|
||||||
|
qatomic_inc(&release_pool_size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
- if (alloc_pool_size < qatomic_read(&pool_max_size)) {
|
||||||
|
- QSLIST_INSERT_HEAD(&alloc_pool, co, pool_next);
|
||||||
|
- alloc_pool_size++;
|
||||||
|
+ if (get_alloc_pool_size() < qatomic_read(&pool_max_size)) {
|
||||||
|
+ QSLIST_INSERT_HEAD(get_ptr_alloc_pool(), co, pool_next);
|
||||||
|
+ set_alloc_pool_size(get_alloc_pool_size() + 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
99
kvm-coroutine-win32-use-QEMU_DEFINE_STATIC_CO_TLS.patch
Normal file
99
kvm-coroutine-win32-use-QEMU_DEFINE_STATIC_CO_TLS.patch
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
From 336581e6e9ace3f1ddd24ad0a258db9785f9b0ed Mon Sep 17 00:00:00 2001
|
||||||
|
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Date: Tue, 17 May 2022 12:08:12 +0100
|
||||||
|
Subject: [PATCH 3/6] coroutine-win32: use QEMU_DEFINE_STATIC_CO_TLS()
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
RH-MergeRequest: 89: coroutine: use coroutine TLS macros to protect thread-local variables
|
||||||
|
RH-Commit: [3/3] 55b35dfdae1bc7d6f614ac9f81a92f5c6431f713 (stefanha/centos-stream-qemu-kvm)
|
||||||
|
RH-Bugzilla: 1952483
|
||||||
|
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
|
||||||
|
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
||||||
|
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
|
||||||
|
Thread-Local Storage variables cannot be used directly from coroutine
|
||||||
|
code because the compiler may optimize TLS variable accesses across
|
||||||
|
qemu_coroutine_yield() calls. When the coroutine is re-entered from
|
||||||
|
another thread the TLS variables from the old thread must no longer be
|
||||||
|
used.
|
||||||
|
|
||||||
|
Use QEMU_DEFINE_STATIC_CO_TLS() for the current and leader variables.
|
||||||
|
|
||||||
|
I think coroutine-win32.c could get away with __thread because the
|
||||||
|
variables are only used in situations where either the stale value is
|
||||||
|
correct (current) or outside coroutine context (loading leader when
|
||||||
|
current is NULL). Due to the difficulty of being sure that this is
|
||||||
|
really safe in all scenarios it seems worth converting it anyway.
|
||||||
|
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Message-Id: <20220307153853.602859-4-stefanha@redhat.com>
|
||||||
|
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||||
|
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
(cherry picked from commit c1fe694357a328c807ae3cc6961c19e923448fcc)
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
---
|
||||||
|
util/coroutine-win32.c | 18 +++++++++++++-----
|
||||||
|
1 file changed, 13 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/util/coroutine-win32.c b/util/coroutine-win32.c
|
||||||
|
index de6bd4fd3e..c02a62c896 100644
|
||||||
|
--- a/util/coroutine-win32.c
|
||||||
|
+++ b/util/coroutine-win32.c
|
||||||
|
@@ -25,6 +25,7 @@
|
||||||
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu-common.h"
|
||||||
|
#include "qemu/coroutine_int.h"
|
||||||
|
+#include "qemu/coroutine-tls.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
@@ -34,8 +35,8 @@ typedef struct
|
||||||
|
CoroutineAction action;
|
||||||
|
} CoroutineWin32;
|
||||||
|
|
||||||
|
-static __thread CoroutineWin32 leader;
|
||||||
|
-static __thread Coroutine *current;
|
||||||
|
+QEMU_DEFINE_STATIC_CO_TLS(CoroutineWin32, leader);
|
||||||
|
+QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current);
|
||||||
|
|
||||||
|
/* This function is marked noinline to prevent GCC from inlining it
|
||||||
|
* into coroutine_trampoline(). If we allow it to do that then it
|
||||||
|
@@ -52,7 +53,7 @@ qemu_coroutine_switch(Coroutine *from_, Coroutine *to_,
|
||||||
|
CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, from_);
|
||||||
|
CoroutineWin32 *to = DO_UPCAST(CoroutineWin32, base, to_);
|
||||||
|
|
||||||
|
- current = to_;
|
||||||
|
+ set_current(to_);
|
||||||
|
|
||||||
|
to->action = action;
|
||||||
|
SwitchToFiber(to->fiber);
|
||||||
|
@@ -89,14 +90,21 @@ void qemu_coroutine_delete(Coroutine *co_)
|
||||||
|
|
||||||
|
Coroutine *qemu_coroutine_self(void)
|
||||||
|
{
|
||||||
|
+ Coroutine *current = get_current();
|
||||||
|
+
|
||||||
|
if (!current) {
|
||||||
|
- current = &leader.base;
|
||||||
|
- leader.fiber = ConvertThreadToFiber(NULL);
|
||||||
|
+ CoroutineWin32 *leader = get_ptr_leader();
|
||||||
|
+
|
||||||
|
+ current = &leader->base;
|
||||||
|
+ set_current(current);
|
||||||
|
+ leader->fiber = ConvertThreadToFiber(NULL);
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool qemu_in_coroutine(void)
|
||||||
|
{
|
||||||
|
+ Coroutine *current = get_current();
|
||||||
|
+
|
||||||
|
return current && current->caller;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -0,0 +1,49 @@
|
|||||||
|
From 49d9c9dced7278517105e9cfec34ea4af716432d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Date: Thu, 9 Jun 2022 17:47:12 +0100
|
||||||
|
Subject: [PATCH 6/6] linux-aio: explain why max batch is checked in
|
||||||
|
laio_io_unplug()
|
||||||
|
|
||||||
|
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
RH-MergeRequest: 102: linux-aio: fix unbalanced plugged counter in laio_io_unplug()
|
||||||
|
RH-Commit: [2/2] b3d6421086bde50d4baad2343b2df89c5f66950e (stefanha/centos-stream-qemu-kvm)
|
||||||
|
RH-Bugzilla: 2092788
|
||||||
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
||||||
|
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
|
||||||
|
It may not be obvious why laio_io_unplug() checks max batch. I discussed
|
||||||
|
this with Stefano and have added a comment summarizing the reason.
|
||||||
|
|
||||||
|
Cc: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
Cc: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
Message-id: 20220609164712.1539045-3-stefanha@redhat.com
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
(cherry picked from commit 99b969fbe105117f5af6060d3afef40ca39cc9c1)
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
---
|
||||||
|
block/linux-aio.c | 6 ++++++
|
||||||
|
1 file changed, 6 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/block/linux-aio.c b/block/linux-aio.c
|
||||||
|
index 6078da7e42..9c2393a2f7 100644
|
||||||
|
--- a/block/linux-aio.c
|
||||||
|
+++ b/block/linux-aio.c
|
||||||
|
@@ -365,6 +365,12 @@ void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
|
||||||
|
assert(s->io_q.plugged);
|
||||||
|
s->io_q.plugged--;
|
||||||
|
|
||||||
|
+ /*
|
||||||
|
+ * Why max batch checking is performed here:
|
||||||
|
+ * Another BDS may have queued requests with a higher dev_max_batch and
|
||||||
|
+ * therefore in_queue could now exceed our dev_max_batch. Re-check the max
|
||||||
|
+ * batch so we can honor our device's dev_max_batch.
|
||||||
|
+ */
|
||||||
|
if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
|
||||||
|
(!s->io_q.plugged &&
|
||||||
|
!s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -0,0 +1,56 @@
|
|||||||
|
From e7326c3a7e0fc022aa5c0ae07bc1e19ad1b6f2ed Mon Sep 17 00:00:00 2001
|
||||||
|
From: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Date: Thu, 9 Jun 2022 17:47:11 +0100
|
||||||
|
Subject: [PATCH 5/6] linux-aio: fix unbalanced plugged counter in
|
||||||
|
laio_io_unplug()
|
||||||
|
|
||||||
|
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
RH-MergeRequest: 102: linux-aio: fix unbalanced plugged counter in laio_io_unplug()
|
||||||
|
RH-Commit: [1/2] 8a71da371c72521f1d70b8767ee564575e0d522b (stefanha/centos-stream-qemu-kvm)
|
||||||
|
RH-Bugzilla: 2092788
|
||||||
|
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
||||||
|
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
||||||
|
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
|
||||||
|
Every laio_io_plug() call has a matching laio_io_unplug() call. There is
|
||||||
|
a plugged counter that tracks the number of levels of plugging and
|
||||||
|
allows for nesting.
|
||||||
|
|
||||||
|
The plugged counter must reflect the balance between laio_io_plug() and
|
||||||
|
laio_io_unplug() calls accurately. Otherwise I/O stalls occur since
|
||||||
|
io_submit(2) calls are skipped while plugged.
|
||||||
|
|
||||||
|
Reported-by: Nikolay Tenev <nt@storpool.com>
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
Message-id: 20220609164712.1539045-2-stefanha@redhat.com
|
||||||
|
Cc: Stefano Garzarella <sgarzare@redhat.com>
|
||||||
|
Fixes: 68d7946648 ("linux-aio: add `dev_max_batch` parameter to laio_io_unplug()")
|
||||||
|
[Stefano Garzarella suggested adding a Fixes tag.
|
||||||
|
--Stefan]
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
(cherry picked from commit f387cac5af030a58ac5a0dacf64cab5e5a4fe5c7)
|
||||||
|
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
---
|
||||||
|
block/linux-aio.c | 4 +++-
|
||||||
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/block/linux-aio.c b/block/linux-aio.c
|
||||||
|
index 4c423fcccf..6078da7e42 100644
|
||||||
|
--- a/block/linux-aio.c
|
||||||
|
+++ b/block/linux-aio.c
|
||||||
|
@@ -363,8 +363,10 @@ void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s,
|
||||||
|
uint64_t dev_max_batch)
|
||||||
|
{
|
||||||
|
assert(s->io_q.plugged);
|
||||||
|
+ s->io_q.plugged--;
|
||||||
|
+
|
||||||
|
if (s->io_q.in_queue >= laio_max_batch(s, dev_max_batch) ||
|
||||||
|
- (--s->io_q.plugged == 0 &&
|
||||||
|
+ (!s->io_q.plugged &&
|
||||||
|
!s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending))) {
|
||||||
|
ioq_submit(s);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
@ -151,7 +151,7 @@ Obsoletes: %{name}-block-ssh <= %{epoch}:%{version} \
|
|||||||
Summary: QEMU is a machine emulator and virtualizer
|
Summary: QEMU is a machine emulator and virtualizer
|
||||||
Name: qemu-kvm
|
Name: qemu-kvm
|
||||||
Version: 7.0.0
|
Version: 7.0.0
|
||||||
Release: 6%{?rcrel}%{?dist}%{?cc_suffix}
|
Release: 7%{?rcrel}%{?dist}%{?cc_suffix}
|
||||||
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
|
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
|
||||||
# Epoch 15 used for RHEL 8
|
# Epoch 15 used for RHEL 8
|
||||||
# Epoch 17 used for RHEL 9 (due to release versioning offset in RHEL 8.5)
|
# Epoch 17 used for RHEL 9 (due to release versioning offset in RHEL 8.5)
|
||||||
@ -276,6 +276,18 @@ Patch60: kvm-virtio-net-don-t-handle-mq-request-in-userspace-hand.patch
|
|||||||
Patch61: kvm-Revert-globally-limit-the-maximum-number-of-CPUs.patch
|
Patch61: kvm-Revert-globally-limit-the-maximum-number-of-CPUs.patch
|
||||||
# For bz#2086262 - [Win11][tpm]vfio_listener_region_del received unaligned region
|
# For bz#2086262 - [Win11][tpm]vfio_listener_region_del received unaligned region
|
||||||
Patch62: kvm-vfio-common-remove-spurious-warning-on-vfio_listener.patch
|
Patch62: kvm-vfio-common-remove-spurious-warning-on-vfio_listener.patch
|
||||||
|
# For bz#1952483 - RFE: QEMU's coroutines fail with CFLAGS=-flto on non-x86_64 architectures
|
||||||
|
Patch63: kvm-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch
|
||||||
|
# For bz#1952483 - RFE: QEMU's coroutines fail with CFLAGS=-flto on non-x86_64 architectures
|
||||||
|
Patch64: kvm-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch
|
||||||
|
# For bz#1952483 - RFE: QEMU's coroutines fail with CFLAGS=-flto on non-x86_64 architectures
|
||||||
|
Patch65: kvm-coroutine-win32-use-QEMU_DEFINE_STATIC_CO_TLS.patch
|
||||||
|
# For bz#2094252 - Compile the virtio-iommu device on x86_64
|
||||||
|
Patch66: kvm-Enable-virtio-iommu-pci-on-x86_64.patch
|
||||||
|
# For bz#2092788 - Stalled IO Operations in VM
|
||||||
|
Patch67: kvm-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch
|
||||||
|
# For bz#2092788 - Stalled IO Operations in VM
|
||||||
|
Patch68: kvm-linux-aio-explain-why-max-batch-is-checked-in-laio_i.patch
|
||||||
|
|
||||||
# Source-git patches
|
# Source-git patches
|
||||||
|
|
||||||
@ -1311,6 +1323,20 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jun 27 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.0.0-7
|
||||||
|
- kvm-coroutine-ucontext-use-QEMU_DEFINE_STATIC_CO_TLS.patch [bz#1952483]
|
||||||
|
- kvm-coroutine-use-QEMU_DEFINE_STATIC_CO_TLS.patch [bz#1952483]
|
||||||
|
- kvm-coroutine-win32-use-QEMU_DEFINE_STATIC_CO_TLS.patch [bz#1952483]
|
||||||
|
- kvm-Enable-virtio-iommu-pci-on-x86_64.patch [bz#2094252]
|
||||||
|
- kvm-linux-aio-fix-unbalanced-plugged-counter-in-laio_io_.patch [bz#2092788]
|
||||||
|
- kvm-linux-aio-explain-why-max-batch-is-checked-in-laio_i.patch [bz#2092788]
|
||||||
|
- Resolves: bz#1952483
|
||||||
|
(RFE: QEMU's coroutines fail with CFLAGS=-flto on non-x86_64 architectures)
|
||||||
|
- Resolves: bz#2094252
|
||||||
|
(Compile the virtio-iommu device on x86_64)
|
||||||
|
- Resolves: bz#2092788
|
||||||
|
(Stalled IO Operations in VM)
|
||||||
|
|
||||||
* Mon Jun 13 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.0.0-6
|
* Mon Jun 13 2022 Miroslav Rezanina <mrezanin@redhat.com> - 7.0.0-6
|
||||||
- kvm-Introduce-event-loop-base-abstract-class.patch [bz#2031024]
|
- kvm-Introduce-event-loop-base-abstract-class.patch [bz#2031024]
|
||||||
- kvm-util-main-loop-Introduce-the-main-loop-into-QOM.patch [bz#2031024]
|
- kvm-util-main-loop-Introduce-the-main-loop-into-QOM.patch [bz#2031024]
|
||||||
|
Loading…
Reference in New Issue
Block a user