[PATCH v2 00/19] block: Some multi-threading fixes

Hanna Czenczek posted 19 patches 4 days, 1 hour ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251110154854.151484-1-hreitz@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>, Ronnie Sahlberg <ronniesahlberg@gmail.com>, Peter Lieven <pl@dlhnet.de>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Ilya Dryomov <idryomov@gmail.com>, "Richard W.M. Jones" <rjones@redhat.com>, Stefan Weil <sw@weilnetz.de>
block/qcow2.h                    |   5 +-
include/block/aio.h              |  15 ++++
include/block/block_int-common.h |   7 +-
block/blkreplay.c                |   3 +-
block/curl.c                     |  45 +++++++---
block/gluster.c                  |  17 ++--
block/io.c                       |   3 +
block/iscsi.c                    |  63 ++++++--------
block/nfs.c                      |  41 ++++-----
block/null.c                     |   7 +-
block/nvme.c                     | 113 ++++++++++++++++--------
block/qcow2.c                    | 145 ++++++++++++++++++++++++-------
block/rbd.c                      |  12 +--
block/ssh.c                      |  22 ++---
block/win32-aio.c                |  31 +++++--
15 files changed, 347 insertions(+), 182 deletions(-)
[PATCH v2 00/19] block: Some multi-threading fixes
Posted by Hanna Czenczek 4 days, 1 hour ago
Hi,

See the v1 cover letter for a general overview:

https://lists.nongnu.org/archive/html/qemu-block/2025-10/msg00501.html

Changes in v2:
- Kept `.ret = EINPGORESS`-style initializations where they already had
  been (curl, nvme)
- Dropped trivial BH waking code (i.e. which can be directly replaced by
  aio_co_wake()) in iscsi, nfs, nvme
- curl: Yield in curl_do_preadv() (former curl_setup_preadv()) and
  curl_find_buf() instead of returning whether curl_co_preadv() has to
  yield or not
- nvme: Added a patch that annotates some functions (primarily BHs and
  CBs) with which AioContext they (must) run in
- qcow2 cache-cleaning timer: Run the timer as a coroutine instead of in
  a timer CB; use a CoQueue to await it exiting instead of polling
  (well, we still need to poll in case we don’t run in a coroutine, but
  that’s standard procedure, I believe)
  - The need to initialize the CoQueue showed that there is a code path
    in qcow2 that doesn’t initialize its CoMutex.  Added a patch to do
    that.
  - Also added a patch to have the timer use realtime instead of virtual
    time.


git backport-diff against v1:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/19:[----] [--] 'block: Note on aio_co_wake use if not yet yielding'
002/19:[----] [--] 'rbd: Run co BH CB in the coroutine’s AioContext'
003/19:[0019] [FC] 'iscsi: Run co BH CB in the coroutine’s AioContext'
004/19:[0022] [FC] 'nfs: Run co BH CB in the coroutine’s AioContext'
005/19:[0060] [FC] 'curl: Fix coroutine waking'
006/19:[----] [--] 'gluster: Do not move coroutine into BDS context'
007/19:[----] [--] 'nvme: Kick and check completions in BDS context'
008/19:[0038] [FC] 'nvme: Fix coroutine waking'
009/19:[down] 'nvme: Note in which AioContext some functions run'
010/19:[----] [--] 'block/io: Take reqs_lock for tracked_requests'
011/19:[down] 'qcow2: Re-initialize lock in invalidate_cache'
012/19:[0145] [FC] 'qcow2: Fix cache_clean_timer'
013/19:[down] 'qcow2: Schedule cache-clean-timer in realtime'
014/19:[----] [--] 'ssh: Run restart_coroutine in current AioContext'
015/19:[----] [--] 'blkreplay: Run BH in coroutine’s AioContext'
016/19:[----] [--] 'block: Note in which AioContext AIO CBs are called'
017/19:[----] [--] 'iscsi: Create AIO BH in original AioContext'
018/19:[----] [--] 'null-aio: Run CB in original AioContext'
019/19:[----] [--] 'win32-aio: Run CB in original context'


Hanna Czenczek (19):
  block: Note on aio_co_wake use if not yet yielding
  rbd: Run co BH CB in the coroutine’s AioContext
  iscsi: Run co BH CB in the coroutine’s AioContext
  nfs: Run co BH CB in the coroutine’s AioContext
  curl: Fix coroutine waking
  gluster: Do not move coroutine into BDS context
  nvme: Kick and check completions in BDS context
  nvme: Fix coroutine waking
  nvme: Note in which AioContext some functions run
  block/io: Take reqs_lock for tracked_requests
  qcow2: Re-initialize lock in invalidate_cache
  qcow2: Fix cache_clean_timer
  qcow2: Schedule cache-clean-timer in realtime
  ssh: Run restart_coroutine in current AioContext
  blkreplay: Run BH in coroutine’s AioContext
  block: Note in which AioContext AIO CBs are called
  iscsi: Create AIO BH in original AioContext
  null-aio: Run CB in original AioContext
  win32-aio: Run CB in original context

 block/qcow2.h                    |   5 +-
 include/block/aio.h              |  15 ++++
 include/block/block_int-common.h |   7 +-
 block/blkreplay.c                |   3 +-
 block/curl.c                     |  45 +++++++---
 block/gluster.c                  |  17 ++--
 block/io.c                       |   3 +
 block/iscsi.c                    |  63 ++++++--------
 block/nfs.c                      |  41 ++++-----
 block/null.c                     |   7 +-
 block/nvme.c                     | 113 ++++++++++++++++--------
 block/qcow2.c                    | 145 ++++++++++++++++++++++++-------
 block/rbd.c                      |  12 +--
 block/ssh.c                      |  22 ++---
 block/win32-aio.c                |  31 +++++--
 15 files changed, 347 insertions(+), 182 deletions(-)

-- 
2.51.1