All of lore.kernel.org
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: Jinhao Fan <fanjinhao21s@ict.ac.cn>
Cc: qemu-devel@nongnu.org, kbusch@kernel.org, stefanha@gmail.com,
	"open list:nvme" <qemu-block@nongnu.org>
Subject: Re: [PATCH v3 3/4] hw/nvme: add iothread support
Date: Thu, 20 Oct 2022 13:13:45 +0200	[thread overview]
Message-ID: <Y1Etac3z2PWv/Zq6@cormorant.local> (raw)
In-Reply-To: <20220827091258.3589230-4-fanjinhao21s@ict.ac.cn>

[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]

On Aug 27 17:12, Jinhao Fan wrote:
> Add an option "iothread=x" to do emulation in a seperate iothread.
> This improves the performance because QEMU's main loop is responsible
> for a lot of other work while iothread is dedicated to NVMe emulation.
> Moreover, emulating in iothread brings the potential of polling on
> SQ/CQ doorbells, which I will bring up in a following patch.
> 
> Iothread can be enabled by:
> -object iothread,id=nvme0 \
> -device nvme,iothread=nvme0 \
> 
> Performance comparisons (KIOPS):
> 
> QD         1   4  16  64
> QEMU      41 136 242 338
> iothread  53 155 245 309
> 
> Signed-off-by: Jinhao Fan <fanjinhao21s@ict.ac.cn>
> ---
>  hw/nvme/ctrl.c | 67 ++++++++++++++++++++++++++++++++++++++++++++------
>  hw/nvme/ns.c   | 21 +++++++++++++---
>  hw/nvme/nvme.h |  6 ++++-
>  3 files changed, 82 insertions(+), 12 deletions(-)
> 

In hw/nvme/ns.c you need to guard the blk_flush and blk_drain calls with
an aio_context_acquire and aio_context_release pair.

diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c
index eb9141a67b5c..dcf889f6d5ce 100644
--- a/hw/nvme/ns.c
+++ b/hw/nvme/ns.c
@@ -520,12 +520,21 @@ int nvme_ns_setup(NvmeNamespace *ns, AioContext *ctx, Error **errp)

 void nvme_ns_drain(NvmeNamespace *ns)
 {
+    AioContext *ctx = blk_get_aio_context(ns->blkconf.blk);
+
+    aio_context_acquire(ctx);
     blk_drain(ns->blkconf.blk);
+    aio_context_release(ctx);
 }

 void nvme_ns_shutdown(NvmeNamespace *ns)
 {
+    AioContext *ctx = blk_get_aio_context(ns->blkconf.blk);
+
+    aio_context_acquire(ctx);
     blk_flush(ns->blkconf.blk);
+    aio_context_release(ctx);
+
     if (ns->params.zoned) {
         nvme_zoned_ns_shutdown(ns);
     }

Otherwise, it all looks fine. I'm still seeing the weird slowdown when
an iothread is enabled. I have yet to figure out why that is... But it
scales! :)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-10-20 11:46 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-27  9:12 [PATCH v3 0/4] irqfd, iothread and polling support Jinhao Fan
2022-08-27  9:12 ` [PATCH v3 1/4] hw/nvme: support irq(de)assertion with eventfd Jinhao Fan
2022-08-27  9:12 ` [PATCH v3 2/4] hw/nvme: use KVM irqfd when available Jinhao Fan
2022-08-27  9:12 ` [PATCH v3 3/4] hw/nvme: add iothread support Jinhao Fan
2022-10-20 11:13   ` Klaus Jensen [this message]
2022-11-03  1:51     ` Jinhao Fan
2022-11-03 12:11       ` Klaus Jensen
2022-11-03 13:10         ` Jinhao Fan
2022-08-27  9:12 ` [PATCH v3 4/4] hw/nvme: add polling support Jinhao Fan
2022-10-20 11:10   ` Klaus Jensen
2022-11-03  2:18     ` Jinhao Fan
2022-11-03 12:10       ` Klaus Jensen
2022-11-03 13:19         ` Jinhao Fan
2022-11-04  6:32           ` Klaus Jensen
2022-11-08 12:39             ` John Levon
2022-11-08 14:11               ` Klaus Jensen
2022-11-09  4:35                 ` Jinhao Fan
2022-10-20 11:16 ` [PATCH v3 0/4] irqfd, iothread and " Klaus Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y1Etac3z2PWv/Zq6@cormorant.local \
    --to=its@irrelevant.dk \
    --cc=fanjinhao21s@ict.ac.cn \
    --cc=kbusch@kernel.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.