From: Klaus Jensen <its@irrelevant.dk>
To: Jinhao Fan <fanjinhao21s@ict.ac.cn>
Cc: qemu-devel@nongnu.org, kbusch@kernel.org
Subject: Re: [PATCH v3] hw/nvme: Use ioeventfd to handle doorbell updates
Date: Tue, 5 Jul 2022 10:04:49 +0200 [thread overview]
Message-ID: <YsPwoSy8qUXAf5ef@apples> (raw)
In-Reply-To: <20220704032620.2710779-1-fanjinhao21s@ict.ac.cn>
[-- Attachment #1: Type: text/plain, Size: 2777 bytes --]
On Jul 4 11:26, Jinhao Fan wrote:
> Add property "ioeventfd" which is enabled by default. When this is
> enabled, updates on the doorbell registers will cause KVM to signal
> an event to the QEMU main loop to handle the doorbell updates.
> Therefore, instead of letting the vcpu thread run both guest VM and
> IO emulation, we now use the main loop thread to do IO emulation and
> thus the vcpu thread has more cycles for the guest VM.
>
> Since ioeventfd does not tell us the exact value that is written, it is
> only useful when shadow doorbell buffer is enabled, where we check
> for the value in the shadow doorbell buffer when we get the doorbell
> update event.
>
> IOPS comparison on Linux 5.19-rc2: (Unit: KIOPS)
>
> qd 1 4 16 64
> qemu 35 121 176 153
> ioeventfd 41 133 258 313
>
> Changes since v2:
> - Add memory_region_del_eventfd() when freeing queues to avoid leak
>
> Signed-off-by: Jinhao Fan <fanjinhao21s@ict.ac.cn>
> ---
> hw/nvme/ctrl.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++-
> hw/nvme/nvme.h | 5 +++
> 2 files changed, 112 insertions(+), 1 deletion(-)
>
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index c952c34f94..9ceedf0c29 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> static void nvme_free_sq(NvmeSQueue *sq, NvmeCtrl *n)
> {
> + uint16_t offset = sq->sqid << 3;
> +
> n->sq[sq->sqid] = NULL;
> timer_free(sq->timer);
> + memory_region_del_eventfd(&n->iomem,
> + 0x1000 + offset, 4, false, 0, &sq->notifier);
> + event_notifier_cleanup(&sq->notifier);
Need to guard this with an `if (sq->ioeventfd_enabled)`.
> g_free(sq->io_req);
> if (sq->sqid) {
> g_free(sq);
> @@ -4271,6 +4348,12 @@ static void nvme_init_sq(NvmeSQueue *sq, NvmeCtrl *n, uint64_t dma_addr,
> if (n->dbbuf_enabled) {
> sq->db_addr = n->dbbuf_dbs + (sqid << 3);
> sq->ei_addr = n->dbbuf_eis + (sqid << 3);
> +
> + if (n->params.ioeventfd && sq->sqid != 0) {
> + if (!nvme_init_sq_ioeventfd(sq)) {
> + sq->ioeventfd_enabled = true;
> + }
> + }
> }
>
> assert(n->cq[cqid]);
> @@ -4575,8 +4658,13 @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req)
>
> static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n)
> {
> + uint16_t offset = (cq->cqid << 3) + (1 << 2);
> +
> n->cq[cq->cqid] = NULL;
> timer_free(cq->timer);
> + memory_region_del_eventfd(&n->iomem,
> + 0x1000 + offset, 4, false, 0, &cq->notifier);
> + event_notifier_cleanup(&cq->notifier);
Same, should also be guarded.
Otherwise, looks good to me!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2022-07-05 8:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 3:26 [PATCH v3] hw/nvme: Use ioeventfd to handle doorbell updates Jinhao Fan
2022-07-05 8:04 ` Klaus Jensen [this message]
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=YsPwoSy8qUXAf5ef@apples \
--to=its@irrelevant.dk \
--cc=fanjinhao21s@ict.ac.cn \
--cc=kbusch@kernel.org \
--cc=qemu-devel@nongnu.org \
/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.