[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 1/2] memory: Update inline documentation
From: |
Peter Xu |
Subject: |
Re: [PATCH v7 1/2] memory: Update inline documentation |
Date: |
Thu, 16 Jan 2025 11:40:53 -0500 |
On Thu, Jan 16, 2025 at 02:50:26PM +0000, Peter Maydell wrote:
> On Tue, 14 Jan 2025 at 19:12, Peter Xu <peterx@redhat.com> wrote:
> >
> > On Tue, Jan 14, 2025 at 05:42:57PM +0000, Peter Maydell wrote:
> > > There's at least one test in the arm qtests that will hit this.
> > > I suspect that you'll find that most architectures except x86
> > > (where we don't have models of complex SoCs and the few
> > > machines we do have tend to be old code that is less QOMified)
> > > will hit similar issues. I think there's a general issue here,
> > > this isn't just "some particular ppc device is wrongly coded".
> >
> > I see. Do you know how many of them would be important memory leaks that
> > we should fix immediately?
>
> None of these are important memory leaks, because the device is
> almost always present for the lifetime of the simulation. The
> only case you'd actually get a visible leak would be if you
> could hot-unplug the device, and even then you'd have to
> deliberately sit there doing hot-plug-then-unplug cycles to
> leak an interesting amount of memory.
>
> The main reason to want to fix them is that it lets us run
> "make check" under the sanitizer and catch other, more
> interesting leaks.
Right.
>
> > I mean, we have known memory leaks in QEMU in many places I assume. I am
> > curious how important this problem is, and whether such would justify a
> > memory API change that is not reaching a quorum state (and, imho, add
> > complexity to memory core and of course that spreads to x86 too even if it
> > was not affected) to be merged. Or perhaps we can fix the important ones
> > first from the device model directly instead.
>
> The problem is generic, and the problem is that we have not actually
> nailed down how this is supposed to work, i.e:
> * what are the reference counts counting?
I think we know how it works before this patch. And with that, I suppose
Akihiko managed to figure out how it was not freed properly now for those
due to the circular reference issue that this series is tracking. That's
definitely one step forward to me.
Said that, this is also the major controversial point so far on this patch
on how we should implement such object-internal auto-detach mechanism for
MRs even within the same object.
My suggestion is sticking with the current simple model as much as possible
on always using owner refcounts for MRs, while resolving the issue we're
facing with that. I have a complete patch (which, I would say, should
still be under authorship of Akihiko; what I provided is a fixup on top of
his, and I slightly touched up some comments to provide the best
readability):
https://lore.kernel.org/qemu-devel/Z4e7gFSqdhcmJPYb@x1n
So it's more of a preference that I prefer his older patch with the fixup,
rather than this patch.
Akihiko would prefer start using two refcounts, one almost dedicated for
object internal MR refcounts so that we'll finalize internal MRs in order
(which I questioned on the necessary), but not completely.
> * if a device has this kind of memory region inside another,
> how is it supposed to be coded so as to not leak memory?
Is this question about one MR being struct field of one object, or
specific to something else?
>
> If we can figure out how the lifecycle and memory management
> is supposed to work, then yes, we can fix the relevant device
> models so that they follow whatever the rules are. But it seems
> to me that at the moment we have not got a consensus on how
> this is supposed to work. Until we have that, there's no way to
> fix this at the device model level, because we don't know what
> changes we need to make.
Yes, I think I understand slightly better on the issue we're facing now,
thanks.
--
Peter Xu
- Re: [PATCH v7 1/2] memory: Update inline documentation, (continued)
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Xu, 2025/01/10
- Re: [PATCH v7 1/2] memory: Update inline documentation, Akihiko Odaki, 2025/01/10
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Xu, 2025/01/13
- Re: [PATCH v7 1/2] memory: Update inline documentation, Akihiko Odaki, 2025/01/14
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Xu, 2025/01/14
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Maydell, 2025/01/14
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Xu, 2025/01/14
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Maydell, 2025/01/16
- Re: [PATCH v7 1/2] memory: Update inline documentation, BALATON Zoltan, 2025/01/16
- Re: [PATCH v7 1/2] memory: Update inline documentation, Akihiko Odaki, 2025/01/17
- Re: [PATCH v7 1/2] memory: Update inline documentation,
Peter Xu <=
- Re: [PATCH v7 1/2] memory: Update inline documentation, Akihiko Odaki, 2025/01/14
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Xu, 2025/01/15
- Re: [PATCH v7 1/2] memory: Update inline documentation, Akihiko Odaki, 2025/01/15
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Xu, 2025/01/15
- Re: [PATCH v7 1/2] memory: Update inline documentation, Akihiko Odaki, 2025/01/15
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Xu, 2025/01/15
- Re: [PATCH v7 1/2] memory: Update inline documentation, Akihiko Odaki, 2025/01/16
- Re: [PATCH v7 1/2] memory: Update inline documentation, Peter Xu, 2025/01/16
- Re: [PATCH v7 1/2] memory: Update inline documentation, Akihiko Odaki, 2025/01/17
[PATCH v7 2/2] memory: Do not create circular reference with subregion, Akihiko Odaki, 2025/01/09