From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNcDZ-0004cM-90 for qemu-devel@nongnu.org; Thu, 14 Jul 2016 04:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNcDV-0000FH-T6 for qemu-devel@nongnu.org; Thu, 14 Jul 2016 04:42:01 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:35663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNcDV-0000FD-Jb for qemu-devel@nongnu.org; Thu, 14 Jul 2016 04:41:57 -0400 Received: by mail-wm0-x236.google.com with SMTP id f65so58520958wmi.0 for ; Thu, 14 Jul 2016 01:41:56 -0700 (PDT) References: <1467839703-11733-1-git-send-email-sergey.fedorov@linaro.org> <1467839703-11733-12-git-send-email-sergey.fedorov@linaro.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1467839703-11733-12-git-send-email-sergey.fedorov@linaro.org> Date: Thu, 14 Jul 2016 09:41:58 +0100 Message-ID: <8737nc627d.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC v2 11/11] 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, MTTCG Devel , KONRAD =?utf-8?B?RnLDqWTDqXJpYw==?= , Alvise Rigo , "Emilio G. Cota" , Paolo Bonzini , Richard Henderson , Peter Maydell , Sergey Fedorov , Peter Crosthwaite 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 > --- > > Changes in v2: > - stale comment about unsafe tb_flush() removed > --- > translate-all.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/translate-all.c b/translate-all.c > index eaa95e4cd7dc..e69b5d4e889e 100644 > --- a/translate-all.c > +++ b/translate-all.c > @@ -831,8 +831,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 +860,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 +1167,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); Given our other discussions about lock resetting I wonder if this is another case where mmap_reset() could be called on cpu_loop_exit? > } > > gen_code_buf = tcg_ctx.code_gen_ptr; Otherwise so far the testing is looking pretty positive in linux-user: Tested-by: Alex Bennée Reviewed-by: Alex Bennée -- Alex Bennée