qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: Peter Xu <peterx@redhat.com>
Cc: "BALATON Zoltan" <balaton@eik.bme.hu>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Yanan Wang" <wangyanan55@huawei.com>,
	"John Snow" <jsnow@redhat.com>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Alexey Kardashevskiy" <aik@ozlabs.ru>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org,
	qemu-ppc@nongnu.org, devel@daynix.com
Subject: Re: [PATCH v7 1/2] memory: Update inline documentation
Date: Wed, 15 Jan 2025 13:46:29 +0900	[thread overview]
Message-ID: <00a220df-b256-4b70-9974-f4c1fe018201@daynix.com> (raw)
In-Reply-To: <Z4aYpo0VEgaQedKp@x1n>

On 2025/01/15 2:02, Peter Xu wrote:
> On Tue, Jan 14, 2025 at 05:43:09PM +0900, Akihiko Odaki wrote:
>> memory_region_finalize() is not a function to tell the owner is leaving, but
>> the memory region itself is being destroyed.
> 
> It is when the lifecycle of the MR is the same as the owner.  That holds
> true I suppose if without this patch, and that's why I don't prefer this
> patch because it makes that part more complicated.

The lifecycle of the MR is not the same as the owner. The MR gets 
finalized during the finalization of the owner, and the owner is still 
alive at the moment. It is something you should always care when having 
a child object.

> 
>> It should not happen when a container is still referencing it. That is
>> also why it has memory_region_ref(subregion) in
>> memory_region_update_container_subregions() and assert(!mr->container) in
>> memory_region_finalize().
> 
> Again, the line I added was sololy for what you said "automation" elsewhere
> and only should work within MR-links within the same owner.  Otherwise
> anyone referencing the MR would hold the owner ref then this finalize()
> will never happen.
> 
> Now, if I could go back to your original purpose of this work, quotting
> from your cover letter:
> 
>> I saw various sanitizer errors when running check-qtest-ppc64. While
>> I could just turn off sanitizers, I decided to tackle them this time.
>>
>> Unfortunately, GLib versions older than 2.81.0 do not free test data in
>> some cases so some sanitizer errors remain. All sanitizer errors will be
>> gone with this patch series combined with the following change for GLib:
>> https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4120
> 
> Is check-qtest-ppc64 the only one that will trigger this issue?  Does it
> mean that most of the devices will do proper removal of device-owned
> subregions (hence, not prone to circular reference of owner refcount)
> except some devices in ppc64?
> 

Searching for memory_region_add_subregion() gives 1078 instances where 
there are 142 instances of memory_region_del_subregion(). This is a 
rough estimate but there are potentially 936 instances of subregions 
without explicit deletion.

For example, hw/audio/intel-hda.c adds subregions immediately after 
their containers never deletes the subregions. I think that's fine 
because their lifetimes are obvious with reference counters.


  parent reply	other threads:[~2025-01-15  4:47 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09  5:50 [PATCH v7 0/2] Fix check-qtest-ppc64 sanitizer errors Akihiko Odaki
2025-01-09  5:50 ` [PATCH v7 1/2] memory: Update inline documentation Akihiko Odaki
2025-01-09 12:30   ` BALATON Zoltan
2025-01-09 19:29     ` Peter Xu
2025-01-09 19:37       ` Peter Xu
2025-01-10  8:43         ` Akihiko Odaki
2025-01-10 15:18           ` Peter Xu
2025-01-11  4:15             ` Akihiko Odaki
2025-01-13 15:57               ` Peter Xu
2025-01-14  8:43                 ` Akihiko Odaki
2025-01-14 17:02                   ` Peter Xu
2025-01-14 17:42                     ` Peter Maydell
2025-01-14 19:12                       ` Peter Xu
2025-01-16 14:50                         ` Peter Maydell
2025-01-16 16:13                           ` BALATON Zoltan
2025-01-17  6:19                             ` Akihiko Odaki
2025-08-28 10:11                               ` Peter Maydell
2025-08-28 13:17                                 ` Alex Bennée
2025-08-28 16:10                                   ` Peter Xu
2025-01-16 16:40                           ` Peter Xu
2025-01-15  4:46                     ` Akihiko Odaki [this message]
2025-01-15 13:43                       ` Peter Xu
2025-01-15 14:54                         ` Akihiko Odaki
2025-01-15 15:40                           ` Peter Xu
2025-01-15 15:52                             ` Akihiko Odaki
2025-01-15 16:14                               ` Peter Xu
2025-01-16  5:37                                 ` Akihiko Odaki
2025-01-16 14:33                                   ` Peter Xu
2025-01-17  6:24                                     ` Akihiko Odaki
2025-01-17 17:46                                       ` Peter Xu
2025-01-18 10:15                                         ` Akihiko Odaki
2025-01-18 12:49                                           ` Peter Xu
2025-01-09  5:50 ` [PATCH v7 2/2] memory: Do not create circular reference with subregion Akihiko Odaki
2025-01-09 15:55   ` Peter Xu

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=00a220df-b256-4b70-9974-f4c1fe018201@daynix.com \
    --to=akihiko.odaki@daynix.com \
    --cc=aik@ozlabs.ru \
    --cc=alex.bennee@linaro.org \
    --cc=balaton@eik.bme.hu \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=david@redhat.com \
    --cc=devel@daynix.com \
    --cc=eduardo@habkost.net \
    --cc=farosas@suse.de \
    --cc=harshpb@linux.ibm.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=wangyanan55@huawei.com \
    /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).