From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHviH-0000Qs-NE for qemu-devel@nongnu.org; Tue, 28 Jun 2016 12:18:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHviA-00055h-JW for qemu-devel@nongnu.org; Tue, 28 Jun 2016 12:18:12 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:38218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHviA-00055d-CO for qemu-devel@nongnu.org; Tue, 28 Jun 2016 12:18:06 -0400 Received: by mail-wm0-x236.google.com with SMTP id r201so35372140wme.1 for ; Tue, 28 Jun 2016 09:18:06 -0700 (PDT) From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1466375313-7562-9-git-send-email-sergey.fedorov@linaro.org> Date: Tue, 28 Jun 2016 17:18:10 +0100 Message-ID: <87a8i5e18d.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC 8/8] tcg: Make tb_flush() thread safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: qemu-devel@nongnu.org, Peter Crosthwaite , patches@linaro.org, Paolo Bonzini , Sergey Fedorov , Richard Henderson Sergey Fedorov writes: > 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 */ ^^^ The comment belies a lack of confidence ;-) > -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; -- Alex Bennée