From patchwork Thu Sep 8 13:28:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 9321869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 535D9607D3 for ; Thu, 8 Sep 2016 17:57:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 430F7299A4 for ; Thu, 8 Sep 2016 17:57:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36E3B299A6; Thu, 8 Sep 2016 17:57:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BDE4A299A4 for ; Thu, 8 Sep 2016 17:57:25 +0000 (UTC) Received: from localhost ([::1]:50115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi3Zk-0005hz-Si for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Sep 2016 13:57:24 -0400 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 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59AB07F74D; Thu, 8 Sep 2016 13:28:19 +0000 (UTC) Received: from [10.36.112.47] (ovpn-112-47.ams2.redhat.com [10.36.112.47]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u88DSGmT017888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Sep 2016 09:28:17 -0400 To: =?UTF-8?Q?Alex_Benn=c3=a9e?= 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 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <87wpimy31h.fsf@linaro.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 08 Sep 2016 13:28:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH 02/10] tcg: Pass last_tb by value to tb_find_fast() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: serge.fdrv@gmail.com, qemu-devel@nongnu.org, sergey.fedorov@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 08/09/2016 14:44, Alex Bennée wrote: >> > cpu->tb_flushed = false; /* reset before first TB lookup */ >> > for(;;) { >> > cpu_handle_interrupt(cpu, &last_tb); >> > - tb = tb_find_fast(cpu, &last_tb, tb_exit); >> > + tb = tb_find_fast(cpu, last_tb, tb_exit); > Maybe a comment here for those that missed the subtly in the commit > message? > > /* cpu_loop_exec_tb updates a to a new last_tb */ > >> > 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. > I gave it a quick shot and it's not that simple... One simpler possibility is to take this patch one step further and merge "tb" and "last_tb", but I've not tested it yet: It seems better to me to do it as a follow-up step. Paolo 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 *cpu, } } -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 **last_tb, + int *tb_exit, SyncClocks *sc) { uintptr_t ret; + TranslationBlock *tb = *last_tb; 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) == 0) { - TranslationBlock *tb, *last_tb = NULL; + TranslationBlock *tb = NULL; int tb_exit = 0; /* if an exception is pending, we execute it here */ @@ -619,9 +619,9 @@ int cpu_exec(CPUState *cpu) cpu->tb_flushed = false; /* reset before first TB lookup */ for(;;) { - cpu_handle_interrupt(cpu, &last_tb); - tb = 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 = 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);