qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] system/main: comment lock rationale
@ 2025-04-16 18:52 Pierrick Bouvier
  2025-04-28 19:33 ` Pierrick Bouvier
  0 siblings, 1 reply; 6+ messages in thread
From: Pierrick Bouvier @ 2025-04-16 18:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: philmd, Phil Dennis-Jordan, Paolo Bonzini, Nicholas Piggin,
	Stefan Hajnoczi, Pierrick Bouvier

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 system/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/system/main.c b/system/main.c
index 1c022067349..b8f7157cc34 100644
--- a/system/main.c
+++ b/system/main.c
@@ -69,8 +69,21 @@ int (*qemu_main)(void) = os_darwin_cfrunloop_main;
 int main(int argc, char **argv)
 {
     qemu_init(argc, argv);
+
+    /*
+     * qemu_init acquires the BQL and replay mutex lock. BQL is acquired when
+     * initializing cpus, to block associated threads until initialization is
+     * complete. Replay_mutex lock is acquired on initialization, because it
+     * must be held when configuring icount_mode.
+     *
+     * On MacOS, qemu main event loop runs in a background thread, as main
+     * thread must be reserved for UI. Thus, we need to transfer lock ownership,
+     * and the simplest way to do that is to release them, and reacquire them
+     * from qemu_default_main.
+     */
     bql_unlock();
     replay_mutex_unlock();
+
     if (qemu_main) {
         QemuThread main_loop_thread;
         qemu_thread_create(&main_loop_thread, "qemu_main",
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] system/main: comment lock rationale
  2025-04-16 18:52 Pierrick Bouvier
@ 2025-04-28 19:33 ` Pierrick Bouvier
  0 siblings, 0 replies; 6+ messages in thread
From: Pierrick Bouvier @ 2025-04-28 19:33 UTC (permalink / raw)
  To: qemu-devel
  Cc: philmd, Phil Dennis-Jordan, Paolo Bonzini, Nicholas Piggin,
	Stefan Hajnoczi

On 4/16/25 11:52 AM, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   system/main.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/system/main.c b/system/main.c
> index 1c022067349..b8f7157cc34 100644
> --- a/system/main.c
> +++ b/system/main.c
> @@ -69,8 +69,21 @@ int (*qemu_main)(void) = os_darwin_cfrunloop_main;
>   int main(int argc, char **argv)
>   {
>       qemu_init(argc, argv);
> +
> +    /*
> +     * qemu_init acquires the BQL and replay mutex lock. BQL is acquired when
> +     * initializing cpus, to block associated threads until initialization is
> +     * complete. Replay_mutex lock is acquired on initialization, because it
> +     * must be held when configuring icount_mode.
> +     *
> +     * On MacOS, qemu main event loop runs in a background thread, as main
> +     * thread must be reserved for UI. Thus, we need to transfer lock ownership,
> +     * and the simplest way to do that is to release them, and reacquire them
> +     * from qemu_default_main.
> +     */
>       bql_unlock();
>       replay_mutex_unlock();
> +
>       if (qemu_main) {
>           QemuThread main_loop_thread;
>           qemu_thread_create(&main_loop_thread, "qemu_main",

Gentle ping on this patch.
@Nicholas: as you asked for this patch, would that be possible for you 
to review it?

Regards,
Pierrick


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] system/main: comment lock rationale
@ 2025-05-15 17:46 Pierrick Bouvier
  2025-05-15 17:48 ` Pierrick Bouvier
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pierrick Bouvier @ 2025-05-15 17:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, npiggin, Paolo Bonzini, Pierrick Bouvier

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 system/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/system/main.c b/system/main.c
index 1c022067349..b8f7157cc34 100644
--- a/system/main.c
+++ b/system/main.c
@@ -69,8 +69,21 @@ int (*qemu_main)(void) = os_darwin_cfrunloop_main;
 int main(int argc, char **argv)
 {
     qemu_init(argc, argv);
+
+    /*
+     * qemu_init acquires the BQL and replay mutex lock. BQL is acquired when
+     * initializing cpus, to block associated threads until initialization is
+     * complete. Replay_mutex lock is acquired on initialization, because it
+     * must be held when configuring icount_mode.
+     *
+     * On MacOS, qemu main event loop runs in a background thread, as main
+     * thread must be reserved for UI. Thus, we need to transfer lock ownership,
+     * and the simplest way to do that is to release them, and reacquire them
+     * from qemu_default_main.
+     */
     bql_unlock();
     replay_mutex_unlock();
+
     if (qemu_main) {
         QemuThread main_loop_thread;
         qemu_thread_create(&main_loop_thread, "qemu_main",
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] system/main: comment lock rationale
  2025-05-15 17:46 [PATCH] system/main: comment lock rationale Pierrick Bouvier
@ 2025-05-15 17:48 ` Pierrick Bouvier
  2025-05-24 12:45 ` Richard Henderson
  2025-05-27  8:55 ` Richard Henderson
  2 siblings, 0 replies; 6+ messages in thread
From: Pierrick Bouvier @ 2025-05-15 17:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, npiggin, Paolo Bonzini

On 5/15/25 10:46 AM, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   system/main.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/system/main.c b/system/main.c
> index 1c022067349..b8f7157cc34 100644
> --- a/system/main.c
> +++ b/system/main.c
> @@ -69,8 +69,21 @@ int (*qemu_main)(void) = os_darwin_cfrunloop_main;
>   int main(int argc, char **argv)
>   {
>       qemu_init(argc, argv);
> +
> +    /*
> +     * qemu_init acquires the BQL and replay mutex lock. BQL is acquired when
> +     * initializing cpus, to block associated threads until initialization is
> +     * complete. Replay_mutex lock is acquired on initialization, because it
> +     * must be held when configuring icount_mode.
> +     *
> +     * On MacOS, qemu main event loop runs in a background thread, as main
> +     * thread must be reserved for UI. Thus, we need to transfer lock ownership,
> +     * and the simplest way to do that is to release them, and reacquire them
> +     * from qemu_default_main.
> +     */
>       bql_unlock();
>       replay_mutex_unlock();
> +
>       if (qemu_main) {
>           QemuThread main_loop_thread;
>           qemu_thread_create(&main_loop_thread, "qemu_main",

This was requested previously by Nicholas:
https://lore.kernel.org/qemu-devel/D97QJO5Z909K.368VVIBFA17TA@gmail.com/

I sent this patch to qemu-devel some time ago, but it was never reviewed 
nor pulled, despite multiple pings, so I'm trying again with qemu-trivial.

Regards,
Pierrick


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] system/main: comment lock rationale
  2025-05-15 17:46 [PATCH] system/main: comment lock rationale Pierrick Bouvier
  2025-05-15 17:48 ` Pierrick Bouvier
@ 2025-05-24 12:45 ` Richard Henderson
  2025-05-27  8:55 ` Richard Henderson
  2 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2025-05-24 12:45 UTC (permalink / raw)
  To: qemu-devel

On 5/15/25 18:46, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   system/main.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/system/main.c b/system/main.c
> index 1c022067349..b8f7157cc34 100644
> --- a/system/main.c
> +++ b/system/main.c
> @@ -69,8 +69,21 @@ int (*qemu_main)(void) = os_darwin_cfrunloop_main;
>   int main(int argc, char **argv)
>   {
>       qemu_init(argc, argv);
> +
> +    /*
> +     * qemu_init acquires the BQL and replay mutex lock. BQL is acquired when
> +     * initializing cpus, to block associated threads until initialization is
> +     * complete. Replay_mutex lock is acquired on initialization, because it
> +     * must be held when configuring icount_mode.
> +     *
> +     * On MacOS, qemu main event loop runs in a background thread, as main
> +     * thread must be reserved for UI. Thus, we need to transfer lock ownership,
> +     * and the simplest way to do that is to release them, and reacquire them
> +     * from qemu_default_main.
> +     */
>       bql_unlock();
>       replay_mutex_unlock();
> +
>       if (qemu_main) {
>           QemuThread main_loop_thread;
>           qemu_thread_create(&main_loop_thread, "qemu_main",

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] system/main: comment lock rationale
  2025-05-15 17:46 [PATCH] system/main: comment lock rationale Pierrick Bouvier
  2025-05-15 17:48 ` Pierrick Bouvier
  2025-05-24 12:45 ` Richard Henderson
@ 2025-05-27  8:55 ` Richard Henderson
  2 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2025-05-27  8:55 UTC (permalink / raw)
  To: qemu-devel

On 5/15/25 18:46, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   system/main.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/system/main.c b/system/main.c
> index 1c022067349..b8f7157cc34 100644
> --- a/system/main.c
> +++ b/system/main.c
> @@ -69,8 +69,21 @@ int (*qemu_main)(void) = os_darwin_cfrunloop_main;
>   int main(int argc, char **argv)
>   {
>       qemu_init(argc, argv);
> +
> +    /*
> +     * qemu_init acquires the BQL and replay mutex lock. BQL is acquired when
> +     * initializing cpus, to block associated threads until initialization is
> +     * complete. Replay_mutex lock is acquired on initialization, because it
> +     * must be held when configuring icount_mode.
> +     *
> +     * On MacOS, qemu main event loop runs in a background thread, as main
> +     * thread must be reserved for UI. Thus, we need to transfer lock ownership,
> +     * and the simplest way to do that is to release them, and reacquire them
> +     * from qemu_default_main.
> +     */
>       bql_unlock();
>       replay_mutex_unlock();
> +
>       if (qemu_main) {
>           QemuThread main_loop_thread;
>           qemu_thread_create(&main_loop_thread, "qemu_main",

Queued, thanks.


r~


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-05-27  8:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15 17:46 [PATCH] system/main: comment lock rationale Pierrick Bouvier
2025-05-15 17:48 ` Pierrick Bouvier
2025-05-24 12:45 ` Richard Henderson
2025-05-27  8:55 ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2025-04-16 18:52 Pierrick Bouvier
2025-04-28 19:33 ` Pierrick Bouvier

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).