From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bElDn-0005H0-T5 for qemu-devel@nongnu.org; Sun, 19 Jun 2016 18:29:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bElDl-0002O4-TL for qemu-devel@nongnu.org; Sun, 19 Jun 2016 18:29:38 -0400 Received: from mail-lf0-x233.google.com ([2a00:1450:4010:c07::233]:33118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bElDl-0002Nx-Ll for qemu-devel@nongnu.org; Sun, 19 Jun 2016 18:29:37 -0400 Received: by mail-lf0-x233.google.com with SMTP id f6so27240742lfg.0 for ; Sun, 19 Jun 2016 15:29:37 -0700 (PDT) From: Sergey Fedorov Date: Mon, 20 Jun 2016 01:28:33 +0300 Message-Id: <1466375313-7562-9-git-send-email-sergey.fedorov@linaro.org> In-Reply-To: <1466375313-7562-1-git-send-email-sergey.fedorov@linaro.org> References: <1466375313-7562-1-git-send-email-sergey.fedorov@linaro.org> Subject: [Qemu-devel] [RFC 8/8] tcg: Make tb_flush() thread safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: patches@linaro.org, Sergey Fedorov , Sergey Fedorov , Paolo Bonzini , Peter Crosthwaite , Richard Henderson From: Sergey Fedorov Use async_safe_run_on_cpu() to make tb_flush() thread safe. Signed-off-by: Sergey Fedorov Signed-off-by: Sergey Fedorov --- translate-all.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/translate-all.c b/translate-all.c index 3f402dfe04f5..09b1d0b0efc3 100644 --- a/translate-all.c +++ b/translate-all.c @@ -832,7 +832,7 @@ static void page_flush_tb(void) /* flush all the translation blocks */ /* XXX: tb_flush is currently not thread safe */ -void tb_flush(CPUState *cpu) +static void do_tb_flush(CPUState *cpu, void *data) { #if defined(DEBUG_FLUSH) printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n", @@ -861,6 +861,11 @@ void tb_flush(CPUState *cpu) tcg_ctx.tb_ctx.tb_flush_count++; } +void tb_flush(CPUState *cpu) +{ + async_safe_run_on_cpu(cpu, do_tb_flush, NULL); +} + #ifdef DEBUG_TB_CHECK static void @@ -1163,9 +1168,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, buffer_overflow: /* flush must be done */ tb_flush(cpu); - /* cannot fail at this point */ - tb = tb_alloc(pc); - assert(tb != NULL); + mmap_unlock(); + cpu_loop_exit(cpu); } gen_code_buf = tcg_ctx.code_gen_ptr; -- 1.9.1