All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Akihiko Odaki <akihiko.odaki@daynix.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: Sat, 18 Jan 2025 07:49:51 -0500	[thread overview]
Message-ID: <Z4ujbzFJbRWTmOPK@x1n> (raw)
In-Reply-To: <d8ab7a88-cf34-4989-909a-bf5fad502f15@daynix.com>

On Sat, Jan 18, 2025 at 07:15:56PM +0900, Akihiko Odaki wrote:
> On 2025/01/18 2:46, Peter Xu wrote:
> > On Fri, Jan 17, 2025 at 03:24:34PM +0900, Akihiko Odaki wrote:
> > > On 2025/01/16 23:33, Peter Xu wrote:
> > > > On Thu, Jan 16, 2025 at 02:37:38PM +0900, Akihiko Odaki wrote:
> > > > > On 2025/01/16 1:14, Peter Xu wrote:
> > > > > > On Thu, Jan 16, 2025 at 12:52:56AM +0900, Akihiko Odaki wrote:
> > > > > > > Functionally, the ordering of container/subregion finalization matters if
> > > > > > > some device tries to a container during finalization. In such a case,
> > > > > >                          |
> > > > > >                          ^ something is missing here, feel free to complete this.
> > > > > 
> > > > > Oops, I meant: functionally, the ordering of container/subregion
> > > > > finalization matters if some device tries to use a container during
> > > > > finalization.
> > > > 
> > > > This is true, though if we keep the concept of "all the MRs share the same
> > > > lifecycle of the owner" idea, another fix of such is simply moving the
> > > > container access before any detachment of MRs.
> > > > 
> > > > > 
> > > > > > 
> > > > > > > removing subregions from the container at random timing can result in an
> > > > > > > unexpected behavior. There is little chance to have such a scenario but we
> > > > > > > should stay the safe side if possible.
> > > > > > 
> > > > > > It sounds like a future feature, and I'm not sure we'll get there, so I
> > > > > > don't worry that much.  Keeping refcount core idea simple is still very
> > > > > > attractive to me.  I still prefer we have complete MR refcounting iff when
> > > > > > necessary.  It's also possible it'll never happen to QEMU.
> > > > > > 
> > > > > 
> > > > > It's not just about the future but also about compatibility with the current
> > > > > device implementations. I will not be surprised even if the random ordering
> > > > > of subregion finalization breaks one of dozens of devices we already have.
> > > > > We should pay attention the details as we are touching the core
> > > > > infrastructure.
> > > > 
> > > > Yes, if we can find any such example that we must follow the order of MR
> > > > destruction, I think that could justify your approach will be required but
> > > > not optional.  It's just that per my understanding there should be none,
> > > > and even if there're very few outliers, it can still be trivially fixed as
> > > > mentioned above.
> > > 
> > > It can be fixed but that means we need auditing the code of devices or wait
> > > until we get a bug report.
> > 
> > We'd better have a solid example.
> > 
> > And for this specific question, IIUC we can have such problem even if
> > internal-ref start to use MR refcounts.
> > 
> > It's because we have a not very straightforward way of finalize() an
> > object, which is freeing all properties before its own finalize()..
> > 
> > static void object_finalize(void *data)
> > {
> >      ...
> >      object_property_del_all(obj);
> >      object_deinit(obj, ti);
> >      ...
> > }
> > 
> > I think it used to be the other way round (which will be easier to
> > understand to me..), but changed after 76a6e1cc7cc.  It could boil down to
> > two dependencies: (1) children's unparent() callback wanting to have the
> > parent being present and valid, and (2) parent's finalize() callback
> > wanting to have all children being present and valid.  I guess we chose (1)
> > as of now.
> > 
> > So I suppose it means even with your patch, it won't help either as long as
> > MRs are properties, and they can already all be gone in a device finalize()
> > even with your new patch.
> 
> The owner can object_ref() to keep the memory region alive.

Do you mean explicitly (rather by the add_subregion)?  Why an owner need to
do it at all, if it knows the MR is part of itself?

-- 
Peter Xu



  reply	other threads:[~2025-01-18 12:51 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
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 [this message]
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=Z4ujbzFJbRWTmOPK@x1n \
    --to=peterx@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=akihiko.odaki@daynix.com \
    --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=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 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.