Skip to content

iothread: Support tracking and querying IOThread holder

Zhang Chen qemu-devel 22 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v20 Latest14 patches 2 repliesIn review
  2. v1914 patches 1 replySuperseded
  3. v1813 patches 11 repliesSuperseded
Earlier versions · 19
VersionPostedPatchesRepliesStatus
v1713 patches16 repliesSuperseded
v1613 patches6 repliesSuperseded
v1514 patches11 repliesSuperseded
v1415 patches20 repliesSuperseded
v1315 patches6 repliesSuperseded
v1215 patches16 repliesSuperseded
v1115 patches12 repliesSuperseded
v10 posting 2/215 patches14 repliesSuperseded
v10 posting 1/215 patches3 repliesSuperseded
v917 patches26 repliesSuperseded
v815 patches15 repliesSuperseded
v714 patches11 repliesSuperseded
v614 patches8 repliesSuperseded
v513 patches37 repliesSuperseded
v44 patches10 repliesSuperseded
v3 posting 2/23 patches8 repliesSuperseded
v3 posting 1/23 patches1 replySuperseded
v24 patches4 repliesSuperseded
v13 patches8 repliesSuperseded

Patches in v20 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14iothread: introduce holder trackinginclude/system/iothread.h iothread.c qapi/misc.json+150 -120 replies
2/14iothread: add holder-aware AioContext accessorsinclude/system/iothread.h iothread.c+45 -10 replies
3/14block/export: track IOThread referencesblock/export/export.c include/block/export.h+58 -90 replies
4/14monitor: track IOThread users with QOM pathsmonitor/monitor-internal.h monitor/monitor.c monitor/qmp.c+38 -190 replies
5/14virtio-vq-mapping: track iothread-vq-mapping references using device pathhw/block/virtio-blk.c hw/scsi/virtio-scsi-dataplane.c hw/virtio/iothread-vq-mapping.c +2 more+47 -90 replies
6/14virtio: track IOThread references for thread pinninghw/block/virtio-blk.c hw/scsi/virtio-scsi-dataplane.c+26 -200 replies
7/14net/colo: track IOThread references using path-based holdernet/colo-compare.c+24 -120 replies
8/14virtio-balloon: Update tracking iothread users with holderhw/virtio/virtio-balloon.c include/hw/virtio/virtio-balloon.h+17 -50 replies
9/14vfio-user/proxy: Update tracking iothread users with device QOM pathshw/vfio-user/pci.c hw/vfio-user/proxy.c hw/vfio-user/proxy.h+22 -40 replies
10/14xen-block: Update tracking iothread users with holder namehw/block/dataplane/xen-block.c+16 -30 replies
11/14monitor/hmp: display IOThread holdersmonitor/hmp-cmds.c+20 -00 replies
12/14iothread: make legacy AioContext getter explicitly unsafeblockdev.c include/system/iothread.h iothread.c+19 -30 replies
13/14tests/unit/iothread: update AioContext ref/put helperstests/unit/iothread.c tests/unit/iothread.h tests/unit/test-aio-multithread.c +2 more+49 -200 replies
14/14docs/devel: document holder-aware IOThread AioContext APIsdocs/devel/multiple-iothreads.rst+14 -50 replies

Reviews trailers per patch

All 14 patches have a Reviewed-by or Acked-by.

PatchStefan HajnocziMarkus Armbruster
1/14R-b R-b
2/14R-b R-b
3/14R-b
4/14R-b R-b
5/14R-b
6/14R-b
7/14R-b
8/14R-b
9/14R-b
10/14R-b
11/14R-b R-b
12/14R-b R-b
13/14R-b
14/14R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v20 thread

Cover letter [PATCH V20 00/14] iothread: Support tracking and querying IOThread holder

### Motivation
Currently, the relationship between IOThreads and the resources using them is opaque. From a management perspective, it is difficult to determine which devices or block exports are currently associated with a specific IOThread via QMP or HMP.

This series introduces a "holder" tracking mechanism based on QOM paths or block exports to significantly improve IOThread observability. In high-performance virtualization environments, users often pre-allocate a set of IOThreads to serve as a persistent thread pool. During device hotplug/unplug cycles, while IOThread objects remain persistent, their attachment state changes dynamically.

By tracking these "holders," administrators can use query-iothreads to monitor the real-time load distribution of the thread pool and identify which specific devices (e.g., virtio-blk, BlockExport) are attached to which thread.

### Technical Overview
* Holder tracking

Add a QAPI holder list to each IOThread. A holder identifies either a QOM object by its canonical path or a block export by its unique BlockExportOptions ID.

* Explicit reference lifecycle

Add iothread_ref_and_get_aio_context() and the matching iothread_unref_and_put_aio_context(). Acquiring an AioContext registers a holder and keeps the IOThread alive until the matching put.

Legacy callers without a matching lifecycle use the explicitly named iothread_unsafe_get_aio_context(). The ambiguous legacy iothread_get_aio_context() is removed after all production callers are migrated.

* Subsystem integration

Track holders for block exports, monitors, virtio-blk, virtio-scsi, virtio queue mappings, virtio balloon thread pinning, COLO compare, vfio-user proxy, and xen-block.

* Introspection

Extend IOThreadInfo with a holders array returned by query-iothreads. Display the same information with info iothreads.

=====================================================================

### V20 -> V19 Changelog
- Rebased onto upstream v11.2.0-rc0 (29760efaf96b).
- Add the RB in the patch 14/14.
- Adapted patches 1 and 5 to the updated QOM property registration context, and resolved patch 9's conflicts with vfio-user region FD cleanup. No functional changes to the series.

### V19 -> V18 Changelog
- Added new patch in the last:
docs/devel: document holder-aware IOThread AioContext APIs
- Rebased on upstream code.
- Added IOThread prepare_delete() to reject deletion while holders remain, preventing NULL IOThread lookups during virtqueue mapping cleanup.

### V18 -> V17 Changelog
- Saved the COLO object's QOM path for finalization and guarded holder cleanup against incomplete initialization.
- Used the owning PCI device's QOM path for vfio-user holders and saved it for disconnect().
- Simplified the monitor QOM path field name and clarified PATCH 12's commit message.
- Rebased on upstream and collected Reviewed-by tags.

### V17 -> V16 Changelog
- Rebase code to resolve code conflicts for patch 8:
"virtio-balloon: Update tracking iothread users with holder". This issue caused by latest merged patch "fdc3f9a83d".

### V16 -> V15 Changelog
- Unified per-monitor IOThread checks and accesses through

    mon->iothread after initialization.

- Simplified PATCH 13's commit message and clarified why blockdev cannot use the holder-aware get/put APIs.
- Dropped the v15 Patch 1 in this series, It will be taken away independently by trivial-patches tree.

### V15 -> V14 Changelog
- Moved monitor IOThread cleanup from unparent() to monitor_finalize(), pairing complete() with instance finalization.
- Squashed V14 PATCH 04 and PATCH 14 into PATCH 13 and clarified the blockdev lifetime assumption. Since the additional changes are minimal, PATCH 13 retains Stefan's Reviewed-by from V14 PATCH 04.
- Rebased and adapted info iothreads to the MonitorHMP interface.

### V14 -> V13 Changelog
- Renamed patch 3 and clarified that it introduces holder-tracking infrastructure, with users converted in subsequent patches.
- Documented that monitor holders are not visible to management applications, while retaining the tracking for a consistent holder and IOThread reference lifecycle.
- Rebased on the latest upstream.

Zhang Chen (14):
iothread: introduce holder tracking
iothread: add holder-aware AioContext accessors block/export: track IOThread references
monitor: track IOThread users with QOM paths
virtio-vq-mapping: track iothread-vq-mapping references using device
path
virtio: track IOThread references for thread pinning net/colo: track IOThread references using path-based holder
virtio-balloon: Update tracking iothread users with holder vfio-user/proxy: Update tracking iothread users with device QOM paths
xen-block: Update tracking iothread users with holder name monitor/hmp: display IOThread holders
iothread: make legacy AioContext getter explicitly unsafe tests/unit/iothread: update AioContext ref/put helpers docs/devel: document holder-aware IOThread AioContext APIs

 block/export/export.c                   |  62 +++++++++++---
 blockdev.c                              |   9 ++-
 docs/devel/multiple-iothreads.rst       |  19 +++--
 hw/block/dataplane/xen-block.c          |  19 ++++-
 hw/block/virtio-blk.c                   |  21 +++--
 hw/scsi/virtio-scsi-dataplane.c         |  22 +++--
 hw/vfio-user/pci.c                      |   2 +-
 hw/vfio-user/proxy.c                    |  20 ++++-
 hw/vfio-user/proxy.h                    |   4 +-
 hw/virtio/iothread-vq-mapping.c         |  20 +++--
 hw/virtio/virtio-balloon.c              |  21 +++--
 include/block/export.h                  |   5 ++
 include/hw/virtio/iothread-vq-mapping.h |   6 +-
 include/hw/virtio/virtio-balloon.h      |   1 +
 include/system/iothread.h               |  38 ++++++++-
 iothread.c                              | 102 +++++++++++++++++++++++-
 monitor/hmp-cmds.c                      |  20 +++++
 monitor/monitor-internal.h              |   7 +-
 monitor/monitor.c                       |  36 ++++++---
 monitor/qmp.c                           |  14 ++--
 net/colo-compare.c                      |  36 ++++++---
 qapi/misc.json                          |  94 +++++++++++++++++++---
 tests/unit/iothread.c                   |  18 +++--
 tests/unit/iothread.h                   |   7 +-
 tests/unit/test-aio-multithread.c       |   5 +-
 tests/unit/test-bdrv-drain.c            |  18 +++--
 tests/unit/test-block-iothread.c        |  21 +++--
 27 files changed, 535 insertions(+), 112 deletions(-)
Signature · 1 line
2.53.0