From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhzNS-0004bO-Ij for qemu-devel@nongnu.org; Thu, 08 Sep 2016 09:28:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhzNM-0004Qw-KR for qemu-devel@nongnu.org; Thu, 08 Sep 2016 09:28:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhzNM-0004Qj-CM for qemu-devel@nongnu.org; Thu, 08 Sep 2016 09:28:20 -0400 References: <1468917141-8155-1-git-send-email-pbonzini@redhat.com> <1468917141-8155-3-git-send-email-pbonzini@redhat.com> <87wpimy31h.fsf@linaro.org> From: Paolo Bonzini Message-ID: <5f69179b-c88b-dd6e-e262-1bca6834d2a2@redhat.com> Date: Thu, 8 Sep 2016 15:28:15 +0200 MIME-Version: 1.0 In-Reply-To: <87wpimy31h.fsf@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 02/10] tcg: Pass last_tb by value to tb_find_fast() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= Cc: qemu-devel@nongnu.org, serge.fdrv@gmail.com, sergey.fedorov@linaro.org On 08/09/2016 14:44, Alex Benn=C3=A9e wrote: >> > cpu->tb_flushed =3D false; /* reset before first TB loo= kup */ >> > for(;;) { >> > cpu_handle_interrupt(cpu, &last_tb); >> > - tb =3D tb_find_fast(cpu, &last_tb, tb_exit); >> > + tb =3D tb_find_fast(cpu, last_tb, tb_exit); > Maybe a comment here for those that missed the subtly in the commit > message? >=20 > /* cpu_loop_exec_tb updates a to a new last_tb */ >=20 >> > cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); > You could even make it explicit and change cpu_loop_exec_tb to return > last_tb instead of passing by reference. Then it would be even clearer > when reading the code. >=20 I gave it a quick shot and it's not that simple... One simpler possibilit= y is to take this patch one step further and merge "tb" and "last_tb", but I've not tested it yet: diff --git a/cpu-exec.c b/cpu-exec.c index cf511f1..80e6ff5 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -515,11 +515,11 @@ static inline void cpu_handle_interrupt(CPUState *c= pu, } } =20 -static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, - TranslationBlock **last_tb, int *tb_= exit, - SyncClocks *sc) +static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock **la= st_tb, + int *tb_exit, SyncClocks *sc) { uintptr_t ret; + TranslationBlock *tb =3D *last_tb; =20 if (unlikely(cpu->exit_request)) { return; @@ -609,7 +609,7 @@ int cpu_exec(CPUState *cpu) for(;;) { /* prepare setjmp context for exception handling */ if (sigsetjmp(cpu->jmp_env, 0) =3D=3D 0) { - TranslationBlock *tb, *last_tb =3D NULL; + TranslationBlock *tb =3D NULL; int tb_exit =3D 0; =20 /* if an exception is pending, we execute it here */ @@ -619,9 +619,9 @@ int cpu_exec(CPUState *cpu) =20 cpu->tb_flushed =3D false; /* reset before first TB lookup *= / for(;;) { - cpu_handle_interrupt(cpu, &last_tb); - tb =3D tb_find_fast(cpu, last_tb, tb_exit); - cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); + cpu_handle_interrupt(cpu, &tb); + tb =3D tb_find_fast(cpu, tb, tb_exit); + cpu_loop_exec_tb(cpu, &tb, &tb_exit, &sc); /* Try to align the host and virtual clocks if the guest is in advance */ align_clocks(&sc, cpu); It seems better to me to do it as a follow-up step. Paolo