[PATCH 0/4] hw/nvme: add irqfd support

Jinhao Fan posted 4 patches 1 year, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220811153739.3079672-1-fanjinhao21s@ict.ac.cn
Maintainers: Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>
There is a newer version of this series
hw/nvme/ctrl.c       | 251 +++++++++++++++++++++++++++++++++++++++----
hw/nvme/nvme.h       |   7 ++
hw/nvme/trace-events |   3 +
3 files changed, 243 insertions(+), 18 deletions(-)
[PATCH 0/4] hw/nvme: add irqfd support
Posted by Jinhao Fan 1 year, 8 months ago
This patch series changes qemu-nvme's interrupt emulation to use event
notifiers, which can ensure thread-safe interrupt delivery when iothread
is used. In the first two patches, I convert qemu-nvme's IO emulation
logic to send irq via eventfd, so that the actual assertion and
deassertion is always done in the main loop thread with BQL held. In the
third patch, support is added to send irq via KVM irqfd, bypassing
qemu's MSI-x emulation. In the last patch, I add MSI-x mask handlers
when irqfd is enabled so that qemu-nvme knows which vector is masked
even when qemu's MSI-x emulation is bypassed.

Jinhao Fan (4):
  hw/nvme: avoid unnecessary call to irq (de)assertion functions
  hw/nvme: add option to (de)assert irq with eventfd
  hw/nvme: use irqfd to send interrupts
  hw/nvme: add MSI-x mask handlers for irqfd

 hw/nvme/ctrl.c       | 251 +++++++++++++++++++++++++++++++++++++++----
 hw/nvme/nvme.h       |   7 ++
 hw/nvme/trace-events |   3 +
 3 files changed, 243 insertions(+), 18 deletions(-)

-- 
2.25.1
Re: [PATCH 0/4] hw/nvme: add irqfd support
Posted by Klaus Jensen 1 year, 8 months ago
On Aug 11 23:37, Jinhao Fan wrote:
> This patch series changes qemu-nvme's interrupt emulation to use event
> notifiers, which can ensure thread-safe interrupt delivery when iothread
> is used. In the first two patches, I convert qemu-nvme's IO emulation
> logic to send irq via eventfd, so that the actual assertion and
> deassertion is always done in the main loop thread with BQL held. In the
> third patch, support is added to send irq via KVM irqfd, bypassing
> qemu's MSI-x emulation. In the last patch, I add MSI-x mask handlers
> when irqfd is enabled so that qemu-nvme knows which vector is masked
> even when qemu's MSI-x emulation is bypassed.
> 
> Jinhao Fan (4):
>   hw/nvme: avoid unnecessary call to irq (de)assertion functions
>   hw/nvme: add option to (de)assert irq with eventfd
>   hw/nvme: use irqfd to send interrupts
>   hw/nvme: add MSI-x mask handlers for irqfd
> 
>  hw/nvme/ctrl.c       | 251 +++++++++++++++++++++++++++++++++++++++----
>  hw/nvme/nvme.h       |   7 ++
>  hw/nvme/trace-events |   3 +
>  3 files changed, 243 insertions(+), 18 deletions(-)
> 
> -- 
> 2.25.1
> 

Hi Jinhao,

This series all looks pretty good to me. And, incidentally, it is also
super cool work :)

It can use a bit of clean up (the code duplication mentioned previously
by both Stefan and me) - but all the logic seems sound to me and my
testing is happy. Following up on my suggestion to drop the MSI-X
mask/unmasking, I gave the logic a thorough look it looks sound to me.
I'm gonna see what I can come up with for qtest. I suggest you just keep
going on iothread support.

Please post a v2 (all 4 patches) with suggested cleanups and we take it
from there.
Re: [PATCH 0/4] hw/nvme: add irqfd support
Posted by Jinhao Fan 1 year, 8 months ago
at 11:37 PM, Jinhao Fan <fanjinhao21s@ict.ac.cn> wrote:

> This patch series changes qemu-nvme's interrupt emulation to use event
> notifiers, which can ensure thread-safe interrupt delivery when iothread
> is used. In the first two patches, I convert qemu-nvme's IO emulation
> logic to send irq via eventfd, so that the actual assertion and
> deassertion is always done in the main loop thread with BQL held. In the
> third patch, support is added to send irq via KVM irqfd, bypassing
> qemu's MSI-x emulation. In the last patch, I add MSI-x mask handlers
> when irqfd is enabled so that qemu-nvme knows which vector is masked
> even when qemu's MSI-x emulation is bypassed.
> 
> Jinhao Fan (4):
>  hw/nvme: avoid unnecessary call to irq (de)assertion functions
>  hw/nvme: add option to (de)assert irq with eventfd
>  hw/nvme: use irqfd to send interrupts
>  hw/nvme: add MSI-x mask handlers for irqfd
> 
> hw/nvme/ctrl.c       | 251 +++++++++++++++++++++++++++++++++++++++----
> hw/nvme/nvme.h       |   7 ++
> hw/nvme/trace-events |   3 +
> 3 files changed, 243 insertions(+), 18 deletions(-)
> 
> -- 
> 2.25.1

Ping~

Thanks!