Peter Maydell <peter.mayd...@linaro.org> writes:

> On Fri, 17 Jan 2025 at 06:19, Akihiko Odaki <akihiko.od...@daynix.com> wrote:
>> Let me explain my and Peter Xu's solutions by listing object references.
>> It will abstract the details away and allow applying the analogy of
>> other reference counting systems like Objective-C.
>>
<snip>
>> "Weak" references
>> -----------------
>>
>> Next, I'll impose the restriction that prevents circular references. To
>> avoid circular references, we'll stop counting references for one
>> direction. In other words, we'll make some references "weak". Weak
>> references are prone to be dangling (in Objective-C or other platforms,
>> such references will be usually replaced with nil-like values).
>
> I'm not sure this is really how we think about the lifetimes
> of these objects, though. In particular, we definitely don't
> ever expect, for instance, the link from a memory region to
> its owner to be dangling.
>
> I think what we actually have is:
>  * the thing which really has a reference count is the
>    device object
>  * this device owns various things (irqs, child objects,
>    memory regions, etc)
>  * we expect that when we destroy the device that all these
>    other things it owns also should be destroyed
>  * some parts of the system have free-floating memory regions
>    which don't have an owner
>  * parts of the code have to deal with both the "MR belonging
>    to a device" and the "MR not belonging to a device" case

The virtio-gpu blobs are a special MR which we handle clumsily at the
moment as they are backed by separate thread (virglrenderer) and we need
to jump through hoops (c.f. virtio_gpu_virgl_hostmem_region_free) to
make sure it is done with the memory before we can free the container.

<snip>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro

Reply via email to