From 365a1410b6a94f099d06cd77b11c7b7b8483760c Mon Sep 17 00:00:00 2001 From: Miroslav Rezanina Date: Mon, 17 Jan 2022 06:13:57 -0500 Subject: [PATCH] * Mon Jan 17 2022 Miroslav Rezanina - 6.2.0-4 - kvm-block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch [bz#2024544] - kvm-rhel-machine-types-x86-set-prefer_sockets.patch [bz#2028623] - Resolves: bz#2024544 (Fio workers hangs when running fio with 32 jobs iodepth 32 and QEMU's userspace NVMe driver) - Resolves: bz#2028623 ([9.0] machine types: 6.2: Fix prefer_sockets) --- ...nfinite-loop-in-nvme_free_req_queue_.patch | 71 +++++++++++++++++++ ...machine-types-x86-set-prefer_sockets.patch | 52 ++++++++++++++ qemu-kvm.spec | 16 ++++- 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 kvm-block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch create mode 100644 kvm-rhel-machine-types-x86-set-prefer_sockets.patch diff --git a/kvm-block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch b/kvm-block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch new file mode 100644 index 0000000..bdebdc3 --- /dev/null +++ b/kvm-block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch @@ -0,0 +1,71 @@ +From 6989be9d0aa08470f8b287c243dc4bf027d5fbcf Mon Sep 17 00:00:00 2001 +From: Stefan Hajnoczi +Date: Wed, 8 Dec 2021 15:22:46 +0000 +Subject: [PATCH 1/2] block/nvme: fix infinite loop in nvme_free_req_queue_cb() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +RH-Author: Stefan Hajnoczi +RH-MergeRequest: 58: block/nvme: fix infinite loop in nvme_free_req_queue_cb() +RH-Commit: [1/1] 544b3f310d791a20c63b51947de0c6cbb60b0d5b (stefanha/centos-stream-qemu-kvm) +RH-Bugzilla: 2024544 +RH-Acked-by: Kevin Wolf +RH-Acked-by: Stefano Garzarella +RH-Acked-by: Hanna Reitz + +When the request free list is exhausted the coroutine waits on +q->free_req_queue for the next free request. Whenever a request is +completed a BH is scheduled to invoke nvme_free_req_queue_cb() and wake +up waiting coroutines. + +1. nvme_get_free_req() waits for a free request: + + while (q->free_req_head == -1) { + ... + trace_nvme_free_req_queue_wait(q->s, q->index); + qemu_co_queue_wait(&q->free_req_queue, &q->lock); + ... + } + +2. nvme_free_req_queue_cb() wakes up the coroutine: + + while (qemu_co_enter_next(&q->free_req_queue, &q->lock)) { + ^--- infinite loop when free_req_head == -1 + } + +nvme_free_req_queue_cb() and the coroutine form an infinite loop when +q->free_req_head == -1. Fix this by checking q->free_req_head in +nvme_free_req_queue_cb(). If the free request list is exhausted, don't +wake waiting coroutines. Eventually an in-flight request will complete +and the BH will be scheduled again, guaranteeing forward progress. + +Signed-off-by: Stefan Hajnoczi +Reviewed-by: Philippe Mathieu-Daudé +Message-id: 20211208152246.244585-1-stefanha@redhat.com +Signed-off-by: Stefan Hajnoczi +(cherry picked from commit cf4fbc3030c974fff726756a7ceef8386cdf500b) +Signed-off-by: Stefan Hajnoczi +--- + block/nvme.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/block/nvme.c b/block/nvme.c +index e4f336d79c..fa360b9b3c 100644 +--- a/block/nvme.c ++++ b/block/nvme.c +@@ -206,8 +206,9 @@ static void nvme_free_req_queue_cb(void *opaque) + NVMeQueuePair *q = opaque; + + qemu_mutex_lock(&q->lock); +- while (qemu_co_enter_next(&q->free_req_queue, &q->lock)) { +- /* Retry all pending requests */ ++ while (q->free_req_head != -1 && ++ qemu_co_enter_next(&q->free_req_queue, &q->lock)) { ++ /* Retry waiting requests */ + } + qemu_mutex_unlock(&q->lock); + } +-- +2.27.0 + diff --git a/kvm-rhel-machine-types-x86-set-prefer_sockets.patch b/kvm-rhel-machine-types-x86-set-prefer_sockets.patch new file mode 100644 index 0000000..83c912d --- /dev/null +++ b/kvm-rhel-machine-types-x86-set-prefer_sockets.patch @@ -0,0 +1,52 @@ +From ecadfaec992fda7f485522c9ee6e7c9b05614a22 Mon Sep 17 00:00:00 2001 +From: "Dr. David Alan Gilbert" +Date: Tue, 7 Dec 2021 18:39:47 +0000 +Subject: [PATCH 2/2] rhel machine types/x86: set prefer_sockets + +RH-Author: Dr. David Alan Gilbert +RH-MergeRequest: 59: rhel machine types/x86: set prefer_sockets +RH-Commit: [1/1] 9bcd9e2c95154e39ef30a8a342ad6c713fa4f1fb (dagrh/c-9-s-qemu-kvm) +RH-Bugzilla: 2028623 +RH-Acked-by: Miroslav Rezanina +RH-Acked-by: quintela1 +RH-Acked-by: Cornelia Huck + +When I fixed up the machine types for 8.5 I missed the + prefer_sockets = true + +add them in; it looks like Power, ARM already have them, and I see them +in thuth's s390 patch. + +Signed-off-by: Dr. David Alan Gilbert +--- + hw/i386/pc_piix.c | 1 + + hw/i386/pc_q35.c | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c +index 183b5d5464..fccb7f5fc9 100644 +--- a/hw/i386/pc_piix.c ++++ b/hw/i386/pc_piix.c +@@ -973,6 +973,7 @@ static void pc_machine_rhel7_options(MachineClass *m) + compat_props_add(m->compat_props, pc_rhel_compat, pc_rhel_compat_len); + m->alias = "pc"; + m->is_default = 1; ++ m->smp_props.prefer_sockets = true; + } + + static void pc_init_rhel760(MachineState *machine) +diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c +index 0e7e885e78..3b748ddd7b 100644 +--- a/hw/i386/pc_q35.c ++++ b/hw/i386/pc_q35.c +@@ -662,6 +662,7 @@ static void pc_q35_machine_rhel850_options(MachineClass *m) + hw_compat_rhel_8_5_len); + compat_props_add(m->compat_props, pc_rhel_8_5_compat, + pc_rhel_8_5_compat_len); ++ m->smp_props.prefer_sockets = true; + } + + DEFINE_PC_MACHINE(q35_rhel850, "pc-q35-rhel8.5.0", pc_q35_init_rhel850, +-- +2.27.0 + diff --git a/qemu-kvm.spec b/qemu-kvm.spec index d35d448..7732d76 100644 --- a/qemu-kvm.spec +++ b/qemu-kvm.spec @@ -130,7 +130,7 @@ Obsoletes: %{name}-block-iscsi <= %{version} \ Summary: QEMU is a machine emulator and virtualizer Name: qemu-kvm Version: 6.2.0 -Release: 3%{?rcrel}%{?dist}%{?cc_suffix} +Release: 4%{?rcrel}%{?dist}%{?cc_suffix} # Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped # Epoch 15 used for RHEL 8 # Epoch 17 used for RHEL 9 (due to release versioning offset in RHEL 8.5) @@ -193,6 +193,12 @@ Patch31: kvm-hw-arm-virt-Expose-the-RAS-option.patch Patch32: kvm-hw-arm-virt-Add-9.0-machine-type-and-remove-8.5-one.patch # For bz#2031044 - Add rhel-9.0.0 machine types for RHEL 9.0 [aarch64] Patch33: kvm-hw-arm-virt-Check-no_tcg_its-and-minor-style-changes.patch +# For bz#2024544 - Fio workers hangs when running fio with 32 jobs iodepth 32 and QEMU's userspace NVMe driver +Patch34: kvm-block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch +# For bz#2028623 - [9.0] machine types: 6.2: Fix prefer_sockets +Patch35: kvm-rhel-machine-types-x86-set-prefer_sockets.patch + +# Source-git patches %if %{have_clang} BuildRequires: clang @@ -1171,6 +1177,14 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %endif %changelog +* Mon Jan 17 2022 Miroslav Rezanina - 6.2.0-4 +- kvm-block-nvme-fix-infinite-loop-in-nvme_free_req_queue_.patch [bz#2024544] +- kvm-rhel-machine-types-x86-set-prefer_sockets.patch [bz#2028623] +- Resolves: bz#2024544 + (Fio workers hangs when running fio with 32 jobs iodepth 32 and QEMU's userspace NVMe driver) +- Resolves: bz#2028623 + ([9.0] machine types: 6.2: Fix prefer_sockets) + * Mon Jan 10 2022 Miroslav Rezanina - 6.2.0-3 - kvm-hw-arm-virt-Register-iommu-as-a-class-property.patch [bz#2031044] - kvm-hw-arm-virt-Register-its-as-a-class-property.patch [bz#2031044]