From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: "Akihiko Odaki" <akihiko.odaki@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Vladislav Yaroshchuk" <yaroshchuk2000@gmail.com>,
phillip.ennen@gmail.com, "Jason Wang" <jasowang@redhat.com>,
"Cameron Esfahani" <dirty@apple.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Roman Bolshakov" <r.bolshakov@yadro.com>,
"Alexander Graf" <agraf@csgraf.de>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Howard Spoelstra" <hsp.cat7@gmail.com>,
"Roman Bolshakov" <roman@roolebo.dev>,
"Alessio Dionisi" <hello@adns.io>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Eric Blake" <eblake@redhat.com>,
"Phillip Tennen" <phillip@axleos.com>
Subject: Re: [PATCH v13 2/7] net/vmnet: add vmnet backends to qapi/net
Date: Tue, 25 Jan 2022 18:30:35 +0100 [thread overview]
Message-ID: <11994994.S7o1fDX3Xt@silver> (raw)
In-Reply-To: <CAMVc7JVShGiPvwc4fWHfG2JjTX0QGOcs3ua3k58WFdo4fOLS6A@mail.gmail.com>
On Dienstag, 25. Januar 2022 12:08:21 CET Akihiko Odaki wrote:
> On Tue, Jan 25, 2022 at 7:32 PM Peter Maydell <peter.maydell@linaro.org>
wrote:
> > On Tue, 25 Jan 2022 at 04:14, Akihiko Odaki <akihiko.odaki@gmail.com>
wrote:
> > > I'm neutral about the decision. I think QEMU should avoid using
> > > Objective-C code except for interactions with Apple's APIs, and .c is
> > > superior in terms of that as it would prevent accidental introduction
> > > of Objective-C code. On the other hand, naming them .m will allow the
> > > introduction of Automatic Reference Counting to manage dispatch queue
> > > objects. In fact, I have found a few memory leaks in vmnet in the last
> > > review and ui/cocoa.m has a suspicious construction of the object
> > > management (Particularly it has asynchronous dispatches wrapped with
> > > NSAutoreleasePool, which does not make sense).
> >
> > I think those are probably my fault -- in commit 6e657e64cd (in 2013)
> > we added NSAutoReleasePools to fix leaks that happened because
> > we were calling into Cocoa APIs from threads other than the UI
> > thread that didn't have their own automatically created autorelease
> > pool. Much later in commit 5588840ff778 (in 2019) we put in the
> > dispatch_async stuff because newer macOS was stricter about
> > requiring Cocoa API calls to be only on the UI thread. So
> > I think that means the requirement for the autorelease pools
> > has now gone away in those functions and we could simply delete
> > them -- does that sound right? (I freely admit that I'm not a macOS
> > expert -- I just look stuff up in the documentation; historically
> > we haven't really had many expert macOS people around to work on
> > cocoa.m...)
>
> Removing them would be an improvement.
Yes, AFAICS those NSAutoReleasePools in ui/cocoa.m can safely be removed, as
they were apparently just fighting the symptoms of having called cocoa APIs
from non-main thread(s) in the past, which is not allowed.
There is actually a "main thread checker" for that. In Xcode it's just a
checkbox away, but I don't see a corresponding clang parameter. Maybe it's in
a separate toolchain by Apple.
However I don't think the NSAutoReleasePools were the cause of the memory leak
you saw.
> Enabling ARC is a long-term
> solution and would allow clang to analyze object management code and
> answer such a question semi-automatically.
Yeah, that's not trivial and would be a long way. Personally I would say, for
new targets, sure use ARC. But for already existing, large projects like QEMU,
I would not switch to ARC. Because it is not just refactoring, you have to
understand each component and make proper decisions for references (weak,
strong, copy, bridge transfers, adjust blocks, ... ) and avoid cyclic
references, otherwise you just replace existing issues with new ones,
including new leaks.
> Regards,
> Akihiko Odaki
>
> > On the subject of cocoa.m, while we have various macOS-interested
> > people in this thread, can I ask if anybody would like to
> > review a couple of patches that came in at the beginning of the
> > year?
> >
> > https://patchew.org/QEMU/20220102174153.70043-1-carwynellis@gmail.com/
> > ("ui/cocoa: Add option to disable left command and hide cursor on click")
> > and
> > https://patchew.org/QEMU/20220103114515.24020-1-carwynellis@gmail.com/
> > ("Show/hide the menu bar in fullscreen on mouse")
I didn't spot anything negative, but I can't test those patches ATM.
> > either from the point of view of "is this a sensible change to
> > the macOS UI experience" or for the actual code changes, or both.
> >
> > We've been very short on upstream macOS code reviewers so if people
> > interested in that host platform are able to chip in by
> > reviewing each others' code that helps a lot.
Which reminds me of the automated Xcode project discussion for QEMU. I still
think if there was a simple way to work on QEMU with Xcode there were plenty
of macOS reviewers and contributors, and I think it can be done with Meson.
Best regards,
Christian Schoenebeck
next prev parent reply other threads:[~2022-01-25 17:37 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 17:22 [PATCH v13 0/7] Add vmnet.framework based network backend Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 1/7] net/vmnet: add vmnet dependency and customizable option Vladislav Yaroshchuk
2022-01-20 7:14 ` Roman Bolshakov
2022-01-21 11:58 ` Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 2/7] net/vmnet: add vmnet backends to qapi/net Vladislav Yaroshchuk
2022-01-14 8:43 ` Akihiko Odaki
2022-01-15 13:00 ` Vladislav Yaroshchuk
2022-01-18 15:00 ` Markus Armbruster
2022-01-18 16:16 ` Vladislav Yaroshchuk
2022-01-18 16:26 ` Markus Armbruster
2022-01-18 16:46 ` Vladislav Yaroshchuk
2022-01-20 8:32 ` Roman Bolshakov
2022-01-21 12:19 ` Vladislav Yaroshchuk
2022-01-21 13:03 ` Akihiko Odaki
2022-01-28 14:29 ` Vladislav Yaroshchuk
2022-01-28 23:00 ` Akihiko Odaki
2022-01-24 9:56 ` Roman Bolshakov
2022-01-24 11:27 ` Christian Schoenebeck
2022-01-24 17:49 ` Roman Bolshakov
2022-01-24 20:00 ` Christian Schoenebeck
2022-01-24 20:14 ` Peter Maydell
2022-01-24 23:00 ` Roman Bolshakov
2022-01-25 4:14 ` Akihiko Odaki
2022-01-25 10:32 ` Peter Maydell
2022-01-25 11:08 ` Akihiko Odaki
2022-01-25 17:30 ` Christian Schoenebeck [this message]
2022-01-29 21:03 ` Roman Bolshakov
2022-01-13 17:22 ` [PATCH v13 3/7] net/vmnet: implement shared mode (vmnet-shared) Vladislav Yaroshchuk
2022-01-14 8:43 ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 4/7] net/vmnet: implement host mode (vmnet-host) Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 5/7] net/vmnet: implement bridged mode (vmnet-bridged) Vladislav Yaroshchuk
2022-01-14 8:43 ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 6/7] net/vmnet: update qemu-options.hx Vladislav Yaroshchuk
2022-01-14 8:43 ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 7/7] net/vmnet: update MAINTAINERS list Vladislav Yaroshchuk
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=11994994.S7o1fDX3Xt@silver \
--to=qemu_oss@crudebyte.com \
--cc=agraf@csgraf.de \
--cc=akihiko.odaki@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=dirty@apple.com \
--cc=eblake@redhat.com \
--cc=f4bug@amsat.org \
--cc=hello@adns.io \
--cc=hsp.cat7@gmail.com \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=phillip.ennen@gmail.com \
--cc=phillip@axleos.com \
--cc=qemu-devel@nongnu.org \
--cc=r.bolshakov@yadro.com \
--cc=roman@roolebo.dev \
--cc=yaroshchuk2000@gmail.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).