Re: [PATCH v2 2/3] hw/nvme: use KVM irqfd when available

2022-08-27 Thread Jinhao Fan
at 11:34 PM, Keith Busch wrote: > On Fri, Aug 26, 2022 at 11:12:04PM +0800, Jinhao Fan wrote: >> Use KVM's irqfd to send interrupts when possible. This approach is >> thread safe. Moreover, it does not have the inter-thread communication >> overhead of plain event notifiers since handler callback

[PATCH v3 2/4] hw/nvme: use KVM irqfd when available

2022-08-27 Thread Jinhao Fan
Use KVM's irqfd to send interrupts when possible. This approach is thread safe. Moreover, it does not have the inter-thread communication overhead of plain event notifiers since handler callback are called in the same system call as irqfd write. Signed-off-by: Jinhao Fan Signed-off-by: Klaus Jens

[PATCH v3 3/4] hw/nvme: add iothread support

2022-08-27 Thread Jinhao Fan
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

[PATCH v3 1/4] hw/nvme: support irq(de)assertion with eventfd

2022-08-27 Thread Jinhao Fan
When the new option 'irq-eventfd' is turned on, the IO emulation code signals an eventfd when it want to (de)assert an irq. The main loop eventfd handler does the actual irq (de)assertion. This paves the way for iothread support since QEMU's interrupt emulation is not thread safe. Asserting and d

[PATCH v3 4/4] hw/nvme: add polling support

2022-08-27 Thread Jinhao Fan
Add AioContext polling handlers for NVMe SQ and CQ. By employing polling, the latency of NVMe IO emulation is greatly reduced. The SQ polling handler checks for updates on the SQ tail shadow doorbell buffer. The CQ polling handler is an empty function because we procatively polls the CQ head shadow