Re: [RESEND PATCH V10 06/15] monitor: Update tracking iothread users with holder

Markus Armbruster <[email protected]> Mon, 03 Aug 2026 06:39:26 +0200
Newsgroups org.nongnu.qemu-devel
Message-ID <[email protected]>
Zhang Chen <[email protected]> writes:

> On Fri, Jul 31, 2026, 3:23 PM Markus Armbruster <[email protected]> wrote:
>
>> Zhang Chen <[email protected]> writes:
>>
>> > On Tue, Jul 21, 2026 at 8:33 PM Markus Armbruster <[email protected]>
>> wrote:
>> >>
>> >> Zhang Chen <[email protected]> writes:
>> >>
>> >> > Based on monitor QOM path tracking iothread users with holder.
>> >> > Introduce the AioContext in the Monitor struct to avoid repeated calls to
>> >> > iothread_get_aio_context() and ensure symmetrical ref/unref during
>> >> > monitor lifecycle.
>> >> >
>> >> > Signed-off-by: Zhang Chen <[email protected]>
>> >>
>> >> Why are repeated calls bad?
>> >>
>> >> How would symmetry be lost?
>> >>
>> >
>> > OK, will add detailed comments like this in the next version:
>> >
>> > Avoid repeated calls: Under the holder tracking model, fetching the
>> > AioContext increments the IOThread refcount and registers holder metadata.
>> > Dynamically querying it in helper functions (e.g., suspend, BH scheduling)
>> > leads to redundant refcount churn.
>>
>> Right here, we still have
>>
>>     AioContext *iothread_get_aio_context(IOThread *iothread)
>>     {
>>         return iothread->ctx;
>>     }
>>
>> and complicating code to avoid additional calls feels dubious.
>>
>> PATCH 14 changes it to
>>
>>     AioContext *iothread_get_aio_context(IOThread *iothread,
>>                                          const IOThreadHolder *holder)
>>     {
>>         /* Add IOThreadHolder to the list */
>>         iothread_ref(iothread, holder);
>>
>>         return iothread->ctx;
>>      }
>>
>> Are you making this change in preparation of PATCH 14?
>>
>
>
> Yes, following Stefan's earlier suggestion allows for lifecycle management
> to be completed with minimal disruption.

The commit message is problematic, because it's written as if PATCH 14
was already applied.  Please adjust it.  Something like "A subsequent
patch will make repeated calls ... undesirable."  Same for symmetry.

[...]