diff mbox series

[RFC,v2,04/38] translate-all: use cpu_in_exclusive_work_context() in tb_flush

Message ID 20181209193749.12277-5-cota@braap.org
State New
Headers show
Series Plugin support | expand

Commit Message

Emilio Cota Dec. 9, 2018, 7:37 p.m. UTC
tb_flush will be called by the plugin module from a safe
work environment. Prepare for that.

Suggested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
 accel/tcg/translate-all.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Alex Bennée Jan. 24, 2019, 2:44 p.m. UTC | #1
Emilio G. Cota <cota@braap.org> writes:

> tb_flush will be called by the plugin module from a safe
> work environment. Prepare for that.
>
> Suggested-by: Alex Bennée <alex.bennee@linaro.org>
> Signed-off-by: Emilio G. Cota <cota@braap.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  accel/tcg/translate-all.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
> index 038d82fdb5..62d5e13185 100644
> --- a/accel/tcg/translate-all.c
> +++ b/accel/tcg/translate-all.c
> @@ -1269,8 +1269,13 @@ void tb_flush(CPUState *cpu)
>  {
>      if (tcg_enabled()) {
>          unsigned tb_flush_count = atomic_mb_read(&tb_ctx.tb_flush_count);
> -        async_safe_run_on_cpu(cpu, do_tb_flush,
> -                              RUN_ON_CPU_HOST_INT(tb_flush_count));
> +
> +        if (cpu_in_exclusive_work_context(cpu)) {
> +            do_tb_flush(cpu, RUN_ON_CPU_HOST_INT(tb_flush_count));
> +        } else {
> +            async_safe_run_on_cpu(cpu, do_tb_flush,
> +                                  RUN_ON_CPU_HOST_INT(tb_flush_count));
> +        }
>      }
>  }


--
Alex Bennée
diff mbox series

Patch

diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index 038d82fdb5..62d5e13185 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -1269,8 +1269,13 @@  void tb_flush(CPUState *cpu)
 {
     if (tcg_enabled()) {
         unsigned tb_flush_count = atomic_mb_read(&tb_ctx.tb_flush_count);
-        async_safe_run_on_cpu(cpu, do_tb_flush,
-                              RUN_ON_CPU_HOST_INT(tb_flush_count));
+
+        if (cpu_in_exclusive_work_context(cpu)) {
+            do_tb_flush(cpu, RUN_ON_CPU_HOST_INT(tb_flush_count));
+        } else {
+            async_safe_run_on_cpu(cpu, do_tb_flush,
+                                  RUN_ON_CPU_HOST_INT(tb_flush_count));
+        }
     }
 }