qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] virtio-blk: remove AioContext lock
@ 2022-11-08 21:19 Stefan Hajnoczi
  2022-11-08 21:19 ` [PATCH 1/8] virtio_queue_aio_attach_host_notifier: " Stefan Hajnoczi
                   ` (7 more replies)
  0 siblings, 8 replies; 21+ messages in thread
From: Stefan Hajnoczi @ 2022-11-08 21:19 UTC (permalink / raw)
  To: qemu-devel
  Cc: Emanuele Giuseppe Esposito, Michael S. Tsirkin, qemu-block,
	Kevin Wolf, Hanna Reitz, Paolo Bonzini, Fam Zheng,
	Stefan Hajnoczi

This is a continuation of Emanuele Esposito's work to remove the AioContext
lock in virtio-blk. In the past it was necessary to acquire the AioContext lock
in order to do I/O. Paolo Bonzini and Emanuele have removed the need for the
AioContext in the core block layer code, with a few exceptions like blk_drain()
and blk_set_aio_context().

This patch series annotates virtio-blk functions with
IO_CODE()/GLOBAL_STATE_CODE() so it's clear in which context they are called.
It also removes unnecessary AioContext locks.

The end result is that virtio-blk rarely takes the AioContext lock. Future
patch series will add support for multiple IOThreads so that true multi-queue
can be achieved, but right now virtio-blk still has unprotected shared state
like s->rq so that needs to wait for another day.

Based-on: <20221102182337.252202-1-stefanha@redhat.com>

Emanuele Giuseppe Esposito (6):
  virtio_queue_aio_attach_host_notifier: remove AioContext lock
  block-backend: enable_write_cache should be atomic
  virtio: categorize callbacks in GS
  virtio-blk: mark GLOBAL_STATE_CODE functions
  virtio-blk: mark IO_CODE functions
  virtio-blk: remove unnecessary AioContext lock from function already
    safe

Stefan Hajnoczi (2):
  virtio-blk: don't acquire AioContext in virtio_blk_handle_vq()
  virtio-blk: minimize virtio_blk_reset() AioContext lock region

 include/block/aio-wait.h        |  4 +-
 block/block-backend.c           |  6 +--
 hw/block/dataplane/virtio-blk.c | 18 +++++--
 hw/block/virtio-blk.c           | 92 ++++++++++++++++++++++++---------
 hw/scsi/virtio-scsi-dataplane.c | 10 ++--
 hw/virtio/virtio-bus.c          |  5 ++
 hw/virtio/virtio-pci.c          |  2 +
 hw/virtio/virtio.c              |  8 +++
 util/aio-wait.c                 |  2 +-
 9 files changed, 106 insertions(+), 41 deletions(-)

-- 
2.38.1



^ permalink raw reply	[flat|nested] 21+ messages in thread
* [PATCH 0/8] virtio-blk: removal of AioContext lock
@ 2022-06-09 14:37 Emanuele Giuseppe Esposito
  2022-06-09 14:37 ` [PATCH 1/8] virtio_queue_aio_attach_host_notifier: remove " Emanuele Giuseppe Esposito
  0 siblings, 1 reply; 21+ messages in thread
From: Emanuele Giuseppe Esposito @ 2022-06-09 14:37 UTC (permalink / raw)
  To: qemu-block
  Cc: Kevin Wolf, Hanna Reitz, Stefan Hajnoczi, Michael S. Tsirkin,
	Paolo Bonzini, Fam Zheng, qemu-devel, Emanuele Giuseppe Esposito

This serie aims to free virtio-blk (and in the future all
virtio devices) from the AioContext lock.

First step is to understand which functions are running in
the main loop and which are in iothreads.
Because many functions in virtio-blk are callbacks called
in some other virtio (pci, mmio, bus and so on) callbacks,
this is not trivial.
Patches 4-5-6 aim to split at least virtio-blk API.

There are two main things to consider when comparing this serie
with the block layer API split:

- sometimes we have data that is accessed by both IO and GS
  functions, but never together. For example, when the main
  loop access some data, iothread is guaranteed to be stopped.

- taking into account the multiqueue setup:
  this work aims to allow an iothread to access multiple
  virtio queues, while assigning the same queue to only one
  iothread. Currently, we have a single iothread running,
  so if we know that the main loop is not interfering, we
  are safe. However, if we want to consider multiple iothreads
  concurrently running, we need to take additional precautions.

A good example of the above is in patch 7.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>

Emanuele Giuseppe Esposito (8):
  virtio_queue_aio_attach_host_notifier: remove AioContext lock
  block-backend: enable_write_cache should be atomic
  virtio_blk_process_queued_requests: always run in a bh
  virtio: categorize callbacks in GS
  virtio-blk: mark GLOBAL_STATE_CODE functions
  virtio-blk: mark IO_CODE functions
  VirtIOBlock: protect rq with its own lock
  virtio-blk: remove unnecessary AioContext lock from function already
    safe

 block/block-backend.c           |   6 +-
 hw/block/dataplane/virtio-blk.c |  32 +++++++-
 hw/block/virtio-blk.c           | 132 ++++++++++++++++++++++++--------
 hw/scsi/virtio-scsi-dataplane.c |  12 ++-
 hw/virtio/virtio-bus.c          |   5 ++
 hw/virtio/virtio-pci.c          |   2 +
 hw/virtio/virtio.c              |   8 ++
 include/hw/virtio/virtio-blk.h  |   6 +-
 8 files changed, 163 insertions(+), 40 deletions(-)

-- 
2.31.1



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

end of thread, other threads:[~2022-11-11 13:47 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-08 21:19 [PATCH 0/8] virtio-blk: remove AioContext lock Stefan Hajnoczi
2022-11-08 21:19 ` [PATCH 1/8] virtio_queue_aio_attach_host_notifier: " Stefan Hajnoczi
2022-11-11 12:17   ` Emanuele Giuseppe Esposito
2022-11-08 21:19 ` [PATCH 2/8] block-backend: enable_write_cache should be atomic Stefan Hajnoczi
2022-11-11 12:17   ` Emanuele Giuseppe Esposito
2022-11-08 21:19 ` [PATCH 3/8] virtio: categorize callbacks in GS Stefan Hajnoczi
2022-11-11 12:19   ` Emanuele Giuseppe Esposito
2022-11-08 21:19 ` [PATCH 4/8] virtio-blk: mark GLOBAL_STATE_CODE functions Stefan Hajnoczi
2022-11-11 12:19   ` Emanuele Giuseppe Esposito
2022-11-08 21:19 ` [PATCH 5/8] virtio-blk: mark IO_CODE functions Stefan Hajnoczi
2022-11-11 12:20   ` Emanuele Giuseppe Esposito
2022-11-08 21:19 ` [PATCH 6/8] virtio-blk: remove unnecessary AioContext lock from function already safe Stefan Hajnoczi
2022-11-11 12:23   ` Emanuele Giuseppe Esposito
2022-11-08 21:19 ` [PATCH 7/8] virtio-blk: don't acquire AioContext in virtio_blk_handle_vq() Stefan Hajnoczi
2022-11-11 12:41   ` Emanuele Giuseppe Esposito
2022-11-08 21:19 ` [PATCH 8/8] virtio-blk: minimize virtio_blk_reset() AioContext lock region Stefan Hajnoczi
2022-11-11 12:41   ` Emanuele Giuseppe Esposito
  -- strict thread matches above, loose matches on Subject: below --
2022-06-09 14:37 [PATCH 0/8] virtio-blk: removal of AioContext lock Emanuele Giuseppe Esposito
2022-06-09 14:37 ` [PATCH 1/8] virtio_queue_aio_attach_host_notifier: remove " Emanuele Giuseppe Esposito
2022-07-05 14:11   ` Stefan Hajnoczi
2022-07-08  9:01     ` Emanuele Giuseppe Esposito
2022-07-12 12:47       ` 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).