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

Zhang Chen <[email protected]>
Newsgroups gmane.comp.emulators.qemu
Message-ID <CAK3tnv+g_m27CEj_PRUyHVsViZv74H+dtHmxw9yjEQqSVVuN-Q@mail.gmail.com>
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.

Thanks
Chen


> > Ensure lifecycle symmetry: Storing AioContext in mon->ctx establishes a
> > strict 1-to-1 lifecycle pairing: a single
> iothread_ref_and_get_aio_context()
> > in monitor_complete() matched by a single iothread_put_aio_context()
> > in monitor_cleanup().
> >
> > Thanks
> > Chen
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.