[PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread

Philippe Mathieu-Daudé posted 65 patches 7 months, 1 week ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Mads Ynddal <mads@ynddal.dk>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony PERARD <anthony@xenproject.org>, Paul Durrant <paul@xen.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Dr. David Alan Gilbert" <dave@treblig.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Reinoud Zandijk <reinoud@netbsd.org>, Sunil Muthuswamy <sunilmut@microsoft.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Michael Roth <michael.roth@amd.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Alexander Graf <agraf@csgraf.de>
There is a newer version of this series
[PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread
Posted by Philippe Mathieu-Daudé 7 months, 1 week ago
Although unreachable, still unregister the RCU before exiting
the thread, as documented in "qemu/rcu.h":

 /*
  * Important !
  *
  * Each thread containing read-side critical sections must be registered
  * with rcu_register_thread() before calling rcu_read_lock().
  * rcu_unregister_thread() should be called before the thread exits.
  */

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
---
 accel/tcg/tcg-accel-ops-rr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index d976daa7319..0aa4ba393a4 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -313,6 +313,8 @@ static void *rr_cpu_thread_fn(void *arg)
         rr_deal_with_unplugged_cpus();
     }
 
+    rcu_unregister_thread();
+
     g_assert_not_reached();
 }
 
-- 
2.49.0


Re: [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread
Posted by Zhao Liu 7 months, 1 week ago
On Wed, Jul 02, 2025 at 08:53:27PM +0200, Philippe Mathieu-Daudé wrote:
> Date: Wed,  2 Jul 2025 20:53:27 +0200
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Subject: [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR
>  thread
> X-Mailer: git-send-email 2.49.0
> 
> Although unreachable, still unregister the RCU before exiting
> the thread, as documented in "qemu/rcu.h":
> 
>  /*
>   * Important !
>   *
>   * Each thread containing read-side critical sections must be registered
>   * with rcu_register_thread() before calling rcu_read_lock().
>   * rcu_unregister_thread() should be called before the thread exits.
>   */
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  accel/tcg/tcg-accel-ops-rr.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Re: [PATCH v4 65/65] accel/tcg: Unregister the RCU before exiting RR thread
Posted by Pierrick Bouvier 7 months, 1 week ago
On 7/2/25 11:53 AM, Philippe Mathieu-Daudé wrote:
> Although unreachable, still unregister the RCU before exiting
> the thread, as documented in "qemu/rcu.h":
> 
>   /*
>    * Important !
>    *
>    * Each thread containing read-side critical sections must be registered
>    * with rcu_register_thread() before calling rcu_read_lock().
>    * rcu_unregister_thread() should be called before the thread exits.
>    */
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Acked-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   accel/tcg/tcg-accel-ops-rr.c | 2 ++
>   1 file changed, 2 insertions(+)

This is on par with what is done for other accelerators.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>