linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/3] cpuidle: add poll_source API and virtio vq polling
@ 2021-07-13 16:19 Stefan Hajnoczi
  2021-07-13 16:19 ` [RFC 1/3] cpuidle: add poll_source API Stefan Hajnoczi
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Stefan Hajnoczi @ 2021-07-13 16:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: Daniel Lezcano, Stefano Garzarella, Ming Lei,
	Michael S . Tsirkin, Marcelo Tosatti, Jens Axboe, Jason Wang,
	linux-block, Rafael J. Wysocki, virtualization, linux-pm,
	Christoph Hellwig, Stefan Hajnoczi

These patches are not polished yet but I would like request feedback on this
approach and share performance results with you.

Idle CPUs tentatively enter a busy wait loop before halting when the cpuidle
haltpoll driver is enabled inside a virtual machine. This reduces wakeup
latency for events that occur soon after the vCPU becomes idle.

This patch series extends the cpuidle busy wait loop with the new poll_source
API so drivers can participate in polling. Such polling-aware drivers disable
their device's irq during the busy wait loop to avoid the cost of interrupts.
This reduces latency further than regular cpuidle haltpoll, which still relies
on irqs.

Virtio drivers are modified to use the poll_source API so all virtio device
types get this feature. The following virtio-blk fio benchmark results show the
improvement:

             IOPS (numjobs=4, iodepth=1, 4 virtqueues)
               before   poll_source      io_poll
4k randread    167102  186049 (+11%)  186654 (+11%)
4k randwrite   162204  181214 (+11%)  181850 (+12%)
4k randrw      159520  177071 (+11%)  177928 (+11%)

The comparison against io_poll shows that cpuidle poll_source achieves
equivalent performance to the block layer's io_poll feature (which I
implemented in a separate patch series [1]).

The advantage of poll_source is that applications do not need to explicitly set
the RWF_HIPRI I/O request flag. The poll_source approach is attractive because
few applications actually use RWF_HIPRI and it takes advantage of CPU cycles we
would have spent in cpuidle haltpoll anyway.

The current series does not improve virtio-net. I haven't investigated deeply,
but it is possible that NAPI and poll_source do not combine. See the final
patch for a starting point on making the two work together.

I have not tried this on bare metal but it might help there too. The cost of
disabling a device's irq must be less than the savings from avoiding irq
handling for this optimization to make sense.

[1] https://lore.kernel.org/linux-block/20210520141305.355961-1-stefanha@redhat.com/

Stefan Hajnoczi (3):
  cpuidle: add poll_source API
  virtio: add poll_source virtqueue polling
  softirq: participate in cpuidle polling

 drivers/cpuidle/Makefile           |   1 +
 drivers/virtio/virtio_pci_common.h |   7 ++
 include/linux/interrupt.h          |   2 +
 include/linux/poll_source.h        |  53 +++++++++++++++
 include/linux/virtio.h             |   2 +
 include/linux/virtio_config.h      |   2 +
 drivers/cpuidle/poll_source.c      | 102 +++++++++++++++++++++++++++++
 drivers/cpuidle/poll_state.c       |   6 ++
 drivers/virtio/virtio.c            |  34 ++++++++++
 drivers/virtio/virtio_pci_common.c |  86 ++++++++++++++++++++++++
 drivers/virtio/virtio_pci_modern.c |   2 +
 kernel/softirq.c                   |  14 ++++
 12 files changed, 311 insertions(+)
 create mode 100644 include/linux/poll_source.h
 create mode 100644 drivers/cpuidle/poll_source.c

-- 
2.31.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-07-27 13:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 16:19 [RFC 0/3] cpuidle: add poll_source API and virtio vq polling Stefan Hajnoczi
2021-07-13 16:19 ` [RFC 1/3] cpuidle: add poll_source API Stefan Hajnoczi
2021-07-19 21:03   ` Marcelo Tosatti
2021-07-20 14:15     ` Stefan Hajnoczi
2021-07-13 16:19 ` [RFC 2/3] virtio: add poll_source virtqueue polling Stefan Hajnoczi
2021-07-13 16:19 ` [RFC 3/3] softirq: participate in cpuidle polling Stefan Hajnoczi
2021-07-21  3:29 ` [RFC 0/3] cpuidle: add poll_source API and virtio vq polling Jason Wang
2021-07-21  9:41   ` Stefan Hajnoczi
2021-07-22  9:04     ` Jason Wang
2021-07-26 15:17       ` Stefan Hajnoczi
2021-07-26 15:47         ` Rafael J. Wysocki
2021-07-26 16:01           ` Stefan Hajnoczi
2021-07-26 16:37             ` Rafael J. Wysocki
2021-07-27 13:32               ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).