[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 3/4] hw/nvme: add iothread support
From: |
Klaus Jensen |
Subject: |
Re: [PATCH v3 3/4] hw/nvme: add iothread support |
Date: |
Thu, 20 Oct 2022 13:13:45 +0200 |
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! :)
signature.asc
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH v3 3/4] hw/nvme: add iothread support,
Klaus Jensen <=