All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: QEMU device refcounting when device creates a container MR
Date: Wed, 9 Mar 2022 16:53:27 +0000	[thread overview]
Message-ID: <CAFEAcA-Wg5LKVRQ4dKX6Hsyb=1VVxfGBDB_=Q6iCxycJzLPRhg@mail.gmail.com> (raw)
In-Reply-To: <4eb4bb05-814b-c28c-c2f4-0f5f5582301b@redhat.com>

On Wed, 9 Mar 2022 at 16:21, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 3/9/22 11:33, Peter Maydell wrote:
> > Hi; does anybody know how device reference counting is supposed
> > to work when the device creates a "container" MemoryRegion which
> > it then puts some of its own subregions in to?
> >
> > As far as I can see when you do memory_region_add_subregion it
> > increases the refcount on the owner of the subregion. So if a
> > device creates a container MR in its own init or realize method
> > and adds sub-MRs that it owns to that container, this increases
> > the refcount on the device permanently, and so the device won't
> > ever be deinited.
>
> The unparent method is supposed to break reference cycles.
>
> In the case of QOM, unparent calls unrealize, so unrealize should remove
> the subregions it created.

It seems asymmetric for unrealize to undo something that was
done in instance_init, though. I would expect unrealize to
undo the effects of realize, and instance_finalize to undo
the effects of instance_init.

-- PMM


  reply	other threads:[~2022-03-09 17:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09 10:33 QEMU device refcounting when device creates a container MR Peter Maydell
2022-03-09 10:40 ` Philippe Mathieu-Daudé
2022-03-10 13:19   ` Peter Xu
2022-03-10 13:45     ` Peter Maydell
2022-03-11  2:19       ` Peter Xu
2022-03-09 16:21 ` Paolo Bonzini
2022-03-09 16:53   ` Peter Maydell [this message]
2022-03-09 16:56     ` Peter Maydell
2022-03-10 15:36       ` Igor Mammedov
2022-03-10 16:05         ` Peter Maydell
2022-03-10 16:30           ` Igor Mammedov
2022-03-10 17:11             ` Peter Maydell
2022-03-18 17:13               ` Igor Mammedov

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='CAFEAcA-Wg5LKVRQ4dKX6Hsyb=1VVxfGBDB_=Q6iCxycJzLPRhg@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.