From: Paolo Bonzini <pbonzini@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
qemu-devel <qemu-devel@nongnu.org>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: QOM address space handling
Date: Mon, 21 Dec 2020 20:16:00 +0100 [thread overview]
Message-ID: <caf04038-213b-a88e-0dd7-ee294c0459b7@redhat.com> (raw)
In-Reply-To: <20201221185420.GA6040@habkost.net>
On 21/12/20 19:54, Eduardo Habkost wrote:
> On Sun, Dec 20, 2020 at 10:25:25AM +0100, Paolo Bonzini wrote:
>> On 18/12/20 23:32, Eduardo Habkost wrote:
>>> Who owns the FlatView reference, exactly?
>>
>> The AddressSpace. The device creates the AddressSpace, which holds a
>> reference to the MemoryRegion through FlatView and AddressSpaceDispatch,
>> which holds a reference to the device.
>>
>> By destroying the address space that it created, the device can break the
>> reference loop.
>>
>>> If the FlatView reference is owned by the MemoryRegion, we have a
>>> reference loop: the device holds a reference to the MemoryRegion,
>>> which owns the FlatView, which holds a reference to the device.
>>> In this case, who owns the reference loop and is responsible for
>>> breaking it?
>>
>> The reference loop is owned by the device, which breaks it through unrealize
>> (called by unparent).
>>
>> instance_finalize by definition cannot break reference loops, so this means
>> that my suggestion of using address_space_init in instance_init was wrong.
>
> Once we fix that, I suggest we add an assertion to make it
> illegal to call object_ref() on an object during instance_init.
It's not necessarily illegal. You can for example call a function that
internally does
object_ref(obj);
oc->func(obj);
object_unref(obj);
But perhaps we could assert that refcount == 1 on exit.
> Do we know how many address_space_init() calls in instance_init
> we have today?
I can see them in raven_pcihost_initfn, in sun4?_iommu.c's iommu_init
and xtensa_cpu_initfn, I think that's all.
Paolo
next prev parent reply other threads:[~2020-12-21 19:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 11:14 QOM address space handling Mark Cave-Ayland
2020-11-10 11:40 ` Paolo Bonzini
2020-12-18 7:49 ` Mark Cave-Ayland
2020-12-18 22:32 ` Eduardo Habkost
2020-12-20 9:25 ` Paolo Bonzini
2020-12-21 18:54 ` Eduardo Habkost
2020-12-21 19:16 ` Paolo Bonzini [this message]
2020-12-21 19:28 ` Eduardo Habkost
2020-11-10 15:03 ` Eduardo Habkost
2020-11-10 15:08 ` Paolo Bonzini
2020-11-10 17:46 ` Eduardo Habkost
2020-11-10 18:36 ` Eduardo Habkost
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=caf04038-213b-a88e-0dd7-ee294c0459b7@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).