From: Markus Armbruster <armbru@redhat.com>
To: Zhang Chen <zhangckid@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
"Dr . David Alan Gilbert" <dave@treblig.org>,
Eric Blake <eblake@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PATCH V8 14/15] qapi: examine IOThread attachment status via query-iothreads
Date: Tue, 02 Jun 2026 19:34:24 +0200 [thread overview]
Message-ID: <87jysgrgm7.fsf@pond.sub.org> (raw)
In-Reply-To: <20260529213321.96271-15-zhangckid@gmail.com> (Zhang Chen's message of "Sat, 30 May 2026 05:33:20 +0800")
Zhang Chen <zhangckid@gmail.com> writes:
> Extend the 'IOThreadInfo' structure to include attachment metrics.
> This allows users to monitor the associated devices by identify them
> by their QOM paths.
Should we mention block nodes and monitors, too?
>
> New fields added to IOThreadInfo:
> @holders: IOThreadHolder of the devices currently associated with
> this iothread. Users can pre-allocate multiple iothread objects
> to serve as a persistent thread pool. When a device is hot-unplugged,
> it is detached from its iothread, but the iothread remains available,
> allowing future hot-plugged devices to attach to it. (Since 11.1)
>
> These fields are also exposed via the Human Monitor Interface (HMP)
> command 'info iothreads' to assist with manual debugging and
> performance tuning.
>
> Signed-off-by: Zhang Chen <zhangckid@gmail.com>
> ---
> iothread.c | 22 ++++++++++++++++++++++
> monitor/hmp-cmds.c | 26 ++++++++++++++++++++++++++
> qapi/misc.json | 11 +++++++++++
> 3 files changed, 59 insertions(+)
>
> diff --git a/iothread.c b/iothread.c
> index a85e960e45..5949785b32 100644
> --- a/iothread.c
> +++ b/iothread.c
> @@ -24,6 +24,8 @@
> #include "qemu/error-report.h"
> #include "qemu/rcu.h"
> #include "qemu/main-loop.h"
> +#include "qapi/clone-visitor.h"
> +#include "qapi/qapi-visit-misc.h"
>
> /*
> * iothread_ref:
> @@ -119,6 +121,25 @@ static void iothread_unref(IOThread *iothread, const IOThreadHolder *holder)
> object_unref(OBJECT(iothread));
> }
>
> +static IOThreadHolderList *iothread_get_holders_list(IOThread *iothread)
> +{
> + IOThreadHolderList *head = NULL;
> + IOThreadHolderList **prev = &head;
> + GList *l;
> +
> + for (l = iothread->holders; l; l = l->next) {
> + IOThreadHolder *src = l->data;
> + IOThreadHolderList *entry = g_new0(IOThreadHolderList, 1);
> +
> + entry->value = QAPI_CLONE(IOThreadHolder, src);
> +
> + *prev = entry;
> + prev = &entry->next;
> + }
If iothread->holders was a IOThreadHolderList instead of a GList, this
loop could be QAPI_CLONE(IOThreadHolderList, iothread->holders) instead.
> +
> + return head;
> +}
> +
> static void *iothread_run(void *opaque)
> {
> IOThread *iothread = opaque;
> @@ -488,6 +509,7 @@ static int query_one_iothread(Object *object, void *opaque)
> info = g_new0(IOThreadInfo, 1);
> info->id = iothread_get_id(iothread);
> info->thread_id = iothread->thread_id;
> + info->holders = iothread_get_holders_list(iothread);
> info->poll_max_ns = iothread->poll_max_ns;
> info->poll_grow = iothread->poll_grow;
> info->poll_shrink = iothread->poll_shrink;
> diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
> index 443b8c785d..1b5883147b 100644
> --- a/monitor/hmp-cmds.c
> +++ b/monitor/hmp-cmds.c
> @@ -237,11 +237,37 @@ void hmp_info_iothreads(Monitor *mon, const QDict *qdict)
> IOThreadInfoList *info_list = qmp_query_iothreads(NULL);
> IOThreadInfoList *info;
> IOThreadInfo *value;
> + IOThreadHolderList *h;
>
> for (info = info_list; info; info = info->next) {
> value = info->value;
> monitor_printf(mon, "%s:\n", value->id);
> monitor_printf(mon, " thread_id=%" PRId64 "\n", value->thread_id);
> + monitor_printf(mon, " holders=");
> + if (value->holders) {
> + for (h = value->holders; h; h = h->next) {
> + IOThreadHolder *holder = h->value;
> +
> + switch (holder->type) {
> + case IO_THREAD_HOLDER_KIND_BLOCK_NODE:
> + monitor_printf(mon, "[block-node: %s]",
> + holder->u.block_node.node_name);
> + break;
> + case IO_THREAD_HOLDER_KIND_QOM_OBJECT:
> + monitor_printf(mon, "[qom-path: %s]",
> + holder->u.qom_object.qom_path);
> + break;
> + case IO_THREAD_HOLDER_KIND_MONITOR_NAME:
> + monitor_printf(mon, "[monitor-name: %s]",
> + holder->u.monitor_name.monitor_name);
> + break;
> + default:
> + monitor_printf(mon, "[unknown]");
> + break;
> + }
> + }
> + monitor_printf(mon, "\n");
> + }
> monitor_printf(mon, " poll-max-ns=%" PRId64 "\n", value->poll_max_ns);
> monitor_printf(mon, " poll-grow=%" PRId64 "\n", value->poll_grow);
> monitor_printf(mon, " poll-shrink=%" PRId64 "\n", value->poll_shrink);
> diff --git a/qapi/misc.json b/qapi/misc.json
> index d9f82f0922..4c16be3fd4 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -137,6 +137,13 @@
> #
> # @thread-id: ID of the underlying host thread
> #
> +# @holders: IOThreadHolder of the devices currently associated with
This is rendered like
• holders ([IOThreadHolder]) – IOThreadHolder of the devices currently associated with
Better use something like
# @holders: the devices currently associated with ...
I'm not sure about "devices", though. It's QOM objects, block nodes,
and monitors. Perhaps the QOM objects are all be devices (subtypes of
TYPE_DEVICE), but I'd have to dig through your patches to be sure. Does
it matter?
> +# this iothread. Users can pre-allocate multiple iothread objects
> +# to serve as a persistent thread pool. When a device is
> +# hot-unplugged, it is detached from its iothread, but the
> +# iothread remains available, allowing future hot-plugged devices
> +# to attach to it. (Since 11.1)
This may need to be rewritten with block nodes and monitors in mind.
> +#
> # @poll-max-ns: maximum polling time in ns, 0 means polling is
> # disabled (since 2.9)
> #
> @@ -159,6 +166,7 @@
> { 'struct': 'IOThreadInfo',
> 'data': {'id': 'str',
> 'thread-id': 'int',
> + 'holders': ['IOThreadHolder'],
> 'poll-max-ns': 'int',
> 'poll-grow': 'int',
> 'poll-shrink': 'int',
> @@ -185,6 +193,8 @@
> # {
> # "id":"iothread0",
> # "thread-id":3134,
> +# "holders":[{"qom-path": "/machine/peripheral/blk1/virtio-backend", "type": "qom-object"},
> +# {"qom-path": "/machine/peripheral/blk0/virtio-backend", "type": "qom-object"}],
> # "poll-max-ns":32768,
> # "poll-grow":0,
> # "poll-shrink":0,
> @@ -193,6 +203,7 @@
> # {
> # "id":"iothread1",
> # "thread-id":3135,
> +# "holders":[{"qom-path": "/machine/peripheral/blk2/virtio-backend", "type": "qom-object"}],
> # "poll-max-ns":32768,
> # "poll-grow":0,
> # "poll-shrink":0,
Would it be useful if one of these examples was a block node?
next prev parent reply other threads:[~2026-06-02 17:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 21:33 [PATCH V8 00/15] iothread: Support tracking and querying IOThread holders Zhang Chen
2026-05-29 21:33 ` [PATCH V8 01/15] qapi/misc: Fix missed query-iothreads items Zhang Chen
2026-05-29 21:33 ` [PATCH V8 02/15] iothread: introduce iothread_ref/unref to track attached devices Zhang Chen
2026-06-02 11:29 ` Markus Armbruster
2026-05-29 21:33 ` [PATCH V8 03/15] iothread: tracking iothread users with holder name Zhang Chen
2026-05-29 21:33 ` [PATCH V8 04/15] iothread: introduce iothread_unsafe_get_aio_context() Zhang Chen
2026-05-29 21:33 ` [PATCH V8 05/15] block/export: track IOThread reference in BlockExport Zhang Chen
2026-05-29 21:33 ` [PATCH V8 06/15] monitor: assign unique default ID to anonymous monitors Zhang Chen
2026-06-02 17:02 ` Markus Armbruster
2026-06-04 9:57 ` Zhang Chen
2026-05-29 21:33 ` [PATCH V8 07/15] monitor: Update tracking iothread users with holder Zhang Chen
2026-06-02 17:20 ` Markus Armbruster
2026-06-04 10:16 ` Zhang Chen
2026-05-29 21:33 ` [PATCH V8 08/15] virtio-vq-mapping: track iothread-vq-mapping references using device path Zhang Chen
2026-05-29 21:33 ` [PATCH V8 09/15] virtio: use iothread_get/put_aio_context for thread pinning Zhang Chen
2026-05-29 21:33 ` [PATCH V8 10/15] net/colo: track IOThread references using path-based holder Zhang Chen
2026-05-29 21:33 ` [PATCH V8 11/15] virtio-balloon: Update tracking iothread users with holder Zhang Chen
2026-05-29 21:33 ` [PATCH V8 12/15] vfio-user/proxy: Update tracking iothread users with holder name Zhang Chen
2026-05-29 21:33 ` [PATCH V8 13/15] xen-block: " Zhang Chen
2026-05-29 21:33 ` [PATCH V8 14/15] qapi: examine IOThread attachment status via query-iothreads Zhang Chen
2026-06-02 17:34 ` Markus Armbruster [this message]
2026-06-04 11:49 ` Zhang Chen
2026-05-29 21:33 ` [PATCH V8 15/15] iothread: simplify API by merging iothread_get_aio_context variants Zhang Chen
2026-06-02 17:41 ` Markus Armbruster
2026-06-04 11:53 ` Zhang Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87jysgrgm7.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=zhangckid@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.