[PATCH V8 00/15] iothread: Support tracking and querying IOThread holders

Zhang Chen posted 15 patches 19 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260529213321.96271-1-zhangckid@gmail.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@mailo.com>, Stefan Hajnoczi <stefanha@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony PERARD <anthony@xenproject.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Fam Zheng <fam@euphon.net>, John Levon <john.levon@nutanix.com>, Thanos Makatos <thanos.makatos@nutanix.com>, "Cédric Le Goater" <clg@redhat.com>, David Hildenbrand <david@kernel.org>, "Dr. David Alan Gilbert" <dave@treblig.org>, Markus Armbruster <armbru@redhat.com>, Zhang Chen <zhangckid@gmail.com>, Li Zhijian <lizhijian@fujitsu.com>, Jason Wang <jasowang@redhat.com>, Eric Blake <eblake@redhat.com>
block/export/export.c                   |  62 +++++++++--
blockdev.c                              |   2 +-
chardev/char.c                          |   2 +-
gdbstub/system.c                        |   3 +-
hw/block/dataplane/xen-block.c          |  19 +++-
hw/block/virtio-blk.c                   |  22 ++--
hw/scsi/virtio-scsi-dataplane.c         |  22 ++--
hw/vfio-user/proxy.c                    |  15 ++-
hw/virtio/iothread-vq-mapping.c         |  19 +++-
hw/virtio/virtio-balloon.c              |  22 +++-
include/block/export.h                  |   6 ++
include/hw/virtio/iothread-vq-mapping.h |   6 +-
include/monitor/monitor.h               |   6 +-
include/system/iothread.h               |  17 ++-
iothread.c                              | 136 +++++++++++++++++++++++-
monitor/hmp-cmds.c                      |  26 +++++
monitor/hmp.c                           |  20 +++-
monitor/monitor-internal.h              |   5 +
monitor/monitor.c                       |  24 ++++-
monitor/qmp.c                           |  21 +++-
net/colo-compare.c                      |  29 +++--
qapi/misc.json                          |  84 ++++++++++++++-
stubs/monitor-internal.c                |   3 +-
23 files changed, 505 insertions(+), 66 deletions(-)
[PATCH V8 00/15] iothread: Support tracking and querying IOThread holders
Posted by Zhang Chen 19 hours ago
### 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 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
* Atomic API Design: Merged iothread_get_aio_context and 
  iothread_ref_and_get_aio_context into a single unified function. The new 
  API enforces a 'holder' parameter, making "retrieval" and "tracking" an  
  atomic operation to prevent reference tracking leaks.
* Subsystem Integration: Fully migrated and adapted core modules including 
  Virtio (blk, vq-mapping, balloon, scsi), Block Layer (export, xen), 
  Network (COLO), VFIO, and the Monitor subsystem.
* Introspection: Expanded the IOThreadInfo QAPI structure to include a 
  'holders' array (list of QOM paths), accessible via both 
  query-iothreads (QMP) and info iothreads (HMP).

### V7 -> V8 Changelog
  - Drop the assumption of the Monitor QOM, add the new type
    IO_THREAD_HOLDER_KIND_MONITOR_NAME.
  - Drop the assumption of the string '/' as QOM path.
  - Introduce new patch for Monitor:
    [PATCH 06/15] assign unique default ID to anonymous monitors
  - Fixed Monitor ID for the IOThread.
  - Refactorcode according comments.
  - Update QMP example.
  - Rebased patches on upstream code.
  - Fixed comments issues.
  - Removed redundant code.

### V6 -> V7 Changelog
  - Fixed comments issues in patch 02/14 (Thanks Markus).
  - Removed redundant code.
  - Rebased patches on upstream code.
  - Fixed code conflict with latest patches.
  - Added detailed description in git log and code.
  - Added comments for patch 06/14 assuming the monitor is a QOM object,
    Depends on Daniel Berrange's RFC patch:
    [PATCH RFC 00/17] monitor: turn QMP and HMP into QOM objects

### V5 -> V6 Changelog
* API Refactoring (Breaking Change):
  - Implement the 'union': 'IoThreadHolder' for combine the QOM objects
    and the block-node.
  - Completely merged iothread_get_aio_context variants.
  - The iothread_get_aio_context function now strictly requires a 'holder' 
    argument to ensure every context retrieval is accounted for.
* Expanded Module Coverage:
  - Added holder tracking for the monitor subsystem (tracking threads used 
    by QMP/HMP).
  - Added support for the virtio-scsi dataplane.
* Code Cleanup:
  - Removed redundant and obsolete API declarations.
  - Standardized the use of object_get_canonical_path() across all callers 
    to provide consistent and unique holder names.
* Bug Fixes:
  - Updated qapi/misc.json documentation to fix missing descriptions in
    query-iothreads items.
* Build System:
  - Improved header inclusion logic to avoid redundant declaration errors
    in unit tests.
* QAPI part:
  - Sorry to drop the "Acked-by: Markus Armbruster <armbru@redhat.com>",
    because this version have lots of changes in the:
    [PATCH V6 13/14]qapi: examine IOThread attachment status via query-iothreads
 


Zhang Chen (15):
  qapi/misc: Fix missed query-iothreads items
  iothread: introduce iothread_ref/unref to track attached devices
  iothread: tracking iothread users with holder name
  iothread: introduce iothread_unsafe_get_aio_context()
  block/export: track IOThread reference in BlockExport
  monitor: assign unique default ID to anonymous monitors
  monitor: Update tracking iothread users with holder
  virtio-vq-mapping: track iothread-vq-mapping references using device
    path
  virtio: use iothread_get/put_aio_context 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 holder name
  xen-block: Update tracking iothread users with holder name
  qapi: examine IOThread attachment status via query-iothreads
  iothread: simplify API by merging iothread_get_aio_context variants

 block/export/export.c                   |  62 +++++++++--
 blockdev.c                              |   2 +-
 chardev/char.c                          |   2 +-
 gdbstub/system.c                        |   3 +-
 hw/block/dataplane/xen-block.c          |  19 +++-
 hw/block/virtio-blk.c                   |  22 ++--
 hw/scsi/virtio-scsi-dataplane.c         |  22 ++--
 hw/vfio-user/proxy.c                    |  15 ++-
 hw/virtio/iothread-vq-mapping.c         |  19 +++-
 hw/virtio/virtio-balloon.c              |  22 +++-
 include/block/export.h                  |   6 ++
 include/hw/virtio/iothread-vq-mapping.h |   6 +-
 include/monitor/monitor.h               |   6 +-
 include/system/iothread.h               |  17 ++-
 iothread.c                              | 136 +++++++++++++++++++++++-
 monitor/hmp-cmds.c                      |  26 +++++
 monitor/hmp.c                           |  20 +++-
 monitor/monitor-internal.h              |   5 +
 monitor/monitor.c                       |  24 ++++-
 monitor/qmp.c                           |  21 +++-
 net/colo-compare.c                      |  29 +++--
 qapi/misc.json                          |  84 ++++++++++++++-
 stubs/monitor-internal.c                |   3 +-
 23 files changed, 505 insertions(+), 66 deletions(-)

-- 
2.49.0