From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
<qemu-devel@nongnu.org>
Cc: philmd@linaro.org, "Stefan Hajnoczi" <stefanha@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Phil Dennis-Jordan" <phil@philjordan.eu>
Subject: Re: [PATCH 1/2] system/main: transfer replay mutex ownership from main thread to main loop thread
Date: Sat, 12 Apr 2025 15:30:54 +1000 [thread overview]
Message-ID: <D94EWG4QRMFP.123EPDW889YVC@gmail.com> (raw)
In-Reply-To: <20250410225550.46807-2-pierrick.bouvier@linaro.org>
On Fri Apr 11, 2025 at 8:55 AM AEST, Pierrick Bouvier wrote:
> On MacOS, UI event loop has to be ran in the main thread of a process.
> Because of that restriction, on this platform, qemu main event loop is
> ran on another thread [1].
>
> This breaks record/replay feature, which expects thread running qemu_init
> to initialize hold this lock, breaking associated functional tests on
> MacOS.
>
> Thus, as a generalization, and similar to how BQL is handled, we release
> it after init, and reacquire the lock before entering main event loop,
> avoiding a special case if a separate thread is used.
>
> Tested on MacOS with:
> $ meson test -C build --setup thorough --print-errorlogs \
> func-x86_64-x86_64_replay func-arm-arm_replay func-aarch64-aarch64_replay
> $ ./build/qemu-system-x86_64 -nographic -icount shift=auto,rr=record,rrfile=replay.log
> $ ./build/qemu-system-x86_64 -nographic -icount shift=auto,rr=replay,rrfile=replay.log
>
> [1] https://gitlab.com/qemu-project/qemu/-/commit/f5ab12caba4f1656479c1feb5248beac1c833243
>
> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2907
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> system/main.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/system/main.c b/system/main.c
> index ecb12fd397c..1c022067349 100644
> --- a/system/main.c
> +++ b/system/main.c
> @@ -25,6 +25,7 @@
> #include "qemu/osdep.h"
> #include "qemu-main.h"
> #include "qemu/main-loop.h"
> +#include "system/replay.h"
> #include "system/system.h"
>
> #ifdef CONFIG_SDL
> @@ -44,10 +45,12 @@ static void *qemu_default_main(void *opaque)
> {
> int status;
>
> + replay_mutex_lock();
> bql_lock();
> status = qemu_main_loop();
> qemu_cleanup(status);
> bql_unlock();
> + replay_mutex_unlock();
>
> exit(status);
> }
> @@ -67,6 +70,7 @@ int main(int argc, char **argv)
> {
> qemu_init(argc, argv);
> bql_unlock();
> + replay_mutex_unlock();
> if (qemu_main) {
> QemuThread main_loop_thread;
> qemu_thread_create(&main_loop_thread, "qemu_main",
Do we actually need to hold replay mutex (or even bql) over qemu_init()?
Both should get dropped before we return here. But as a simple fix, I
guess this is okay.
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
next prev parent reply other threads:[~2025-04-12 5:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 22:55 [PATCH 0/2] fix record/replay on MacOS Pierrick Bouvier
2025-04-10 22:55 ` [PATCH 1/2] system/main: transfer replay mutex ownership from main thread to main loop thread Pierrick Bouvier
2025-04-12 5:30 ` Nicholas Piggin [this message]
2025-04-12 17:24 ` Pierrick Bouvier
2025-04-14 10:25 ` Philippe Mathieu-Daudé
2025-04-14 15:24 ` Pierrick Bouvier
2025-04-15 2:41 ` Nicholas Piggin
2025-04-15 18:31 ` Pierrick Bouvier
2025-04-16 3:16 ` Nicholas Piggin
2025-04-16 18:54 ` Pierrick Bouvier
2025-04-14 10:57 ` Paolo Bonzini
2025-04-10 22:55 ` [PATCH 2/2] tests/functional/test_aarch64_replay: reenable on macos Pierrick Bouvier
2025-04-11 13:42 ` [PATCH 0/2] fix record/replay on MacOS Philippe Mathieu-Daudé
2025-04-14 15:14 ` Stefan Hajnoczi
2025-04-14 15:25 ` Pierrick Bouvier
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=D94EWG4QRMFP.123EPDW889YVC@gmail.com \
--to=npiggin@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=pbonzini@redhat.com \
--cc=phil@philjordan.eu \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).