From patchwork Thu Mar 17 13:46:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: sergey.fedorov@linaro.org X-Patchwork-Id: 8611971 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2E7DEC0554 for ; Thu, 17 Mar 2016 14:48:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EA6920377 for ; Thu, 17 Mar 2016 14:48:56 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id C8CD320373 for ; Thu, 17 Mar 2016 14:48:55 +0000 (UTC) Received: from localhost ([::1]:35454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agZEN-0004lr-8V for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Mar 2016 10:48:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agYHv-00033f-It for qemu-devel@nongnu.org; Thu, 17 Mar 2016 09:48:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agYHp-0008Hg-SO for qemu-devel@nongnu.org; Thu, 17 Mar 2016 09:48:31 -0400 Received: from mail-lb0-x234.google.com ([2a00:1450:4010:c04::234]:35814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agYHp-0008HV-L9 for qemu-devel@nongnu.org; Thu, 17 Mar 2016 09:48:25 -0400 Received: by mail-lb0-x234.google.com with SMTP id bc4so68919054lbc.2 for ; Thu, 17 Mar 2016 06:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AdXgb3t4K0VsZtyiUE/553DioTAgLZWU4aAd1aP1gxk=; b=DykHj8O4rjvgChkM1HGdBy3xROdK27tg+dqp5+JCH3jB1hp2COi7HASBrxx1O0zeK8 svtr+LYMw8/gvCx8QeStlZ3z3f2Z3CDexZlzlMbZX8TgnLCUJmVq5vJY5Nnt56p0f3fm 2OnTLGm3nQgVI4Ol5YCYi63zbJc/I+vqdgCWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AdXgb3t4K0VsZtyiUE/553DioTAgLZWU4aAd1aP1gxk=; b=YIA0jp/YFIFwDkVoV2GXrxvapr54vKh71xmOk86YP5E6h+Ezrcn1O+8eObV7OJcwZ6 jLHywg6LrkcPemFtouRYvavwPXCu2L5rYxIUN60C+DxBS1ZCH+Vg8Znn5Lcuglz7z1rP o6coEeWzswgKE/rx1e3X8hinV40OWSI0T/BAffi69PYaS+e+1NRZRkBFoeSjHGVmZCT0 wX5+gzdZABFyBTvbg+YVNZCkiXfCOqARltegUc431L2Ewh0xUEllv8yg9Hb1lb+KdQoZ TkiU77nqFqtFr0J3dRp+hGXYdDeEgt+91pkY/L/DW1IGZjuUeZguC9La19iQR6q0WzkP Zk5w== X-Gm-Message-State: AD7BkJKtAYQ1U9QALlD5GLdsmi27uuaU88C7XpLju2qpu9x0sc7aCVVjotivK1pUs5MHUkwr X-Received: by 10.112.172.100 with SMTP id bb4mr3659631lbc.44.1458222504684; Thu, 17 Mar 2016 06:48:24 -0700 (PDT) Received: from localhost.localdomain ([89.208.20.115]) by smtp.gmail.com with ESMTPSA id wj2sm1371399lbb.5.2016.03.17.06.48.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Mar 2016 06:48:23 -0700 (PDT) From: sergey.fedorov@linaro.org To: qemu-devel@nongnu.org Date: Thu, 17 Mar 2016 16:46:19 +0300 Message-Id: <1458222382-6498-3-git-send-email-sergey.fedorov@linaro.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458222382-6498-1-git-send-email-sergey.fedorov@linaro.org> References: <1458222382-6498-1-git-send-email-sergey.fedorov@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::234 X-Mailman-Approved-At: Thu, 17 Mar 2016 10:44:16 -0400 Cc: Sergey Fedorov , Richard Henderson , Peter Crosthwaite , Sergey Fedorov , Paolo Bonzini Subject: [Qemu-devel] [PATCH 2/5] tcg: reorganize tb_find_physical loop X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paolo Bonzini Use a continue statement. Signed-off-by: Paolo Bonzini [Sergey Fedorov: Fix moving to list head in case of no TB] Signed-off-by: Sergey Fedorov Reviewed-by: Peter Maydell Signed-off-by: Alex Bennée --- cpu-exec.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index fd92452f16f6..f90482eff778 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -225,37 +225,37 @@ static TranslationBlock *tb_find_physical(CPUState *cpu, phys_pc = get_page_addr_code(env, pc); phys_page1 = phys_pc & TARGET_PAGE_MASK; h = tb_phys_hash_func(phys_pc); - ptb1 = &tcg_ctx.tb_ctx.tb_phys_hash[h]; - for(;;) { - tb = *ptb1; - if (!tb) { - return NULL; + for (ptb1 = &tcg_ctx.tb_ctx.tb_phys_hash[h]; + (tb = *ptb1) != NULL; + ptb1 = &tb->phys_hash_next) { + if (tb->pc != pc || + tb->page_addr[0] != phys_page1 || + tb->cs_base != cs_base || + tb->flags != flags) { + continue; } - if (tb->pc == pc && - tb->page_addr[0] == phys_page1 && - tb->cs_base == cs_base && - tb->flags == flags) { - /* check next page if needed */ - if (tb->page_addr[1] != -1) { - tb_page_addr_t phys_page2; - - virt_page2 = (pc & TARGET_PAGE_MASK) + - TARGET_PAGE_SIZE; - phys_page2 = get_page_addr_code(env, virt_page2); - if (tb->page_addr[1] == phys_page2) { - break; - } - } else { + + /* check next page if needed */ + if (tb->page_addr[1] != -1) { + tb_page_addr_t phys_page2; + + virt_page2 = (pc & TARGET_PAGE_MASK) + + TARGET_PAGE_SIZE; + phys_page2 = get_page_addr_code(env, virt_page2); + if (tb->page_addr[1] == phys_page2) { break; } + } else { + break; } - ptb1 = &tb->phys_hash_next; } - /* Move the TB to the head of the list */ - *ptb1 = tb->phys_hash_next; - tb->phys_hash_next = tcg_ctx.tb_ctx.tb_phys_hash[h]; - tcg_ctx.tb_ctx.tb_phys_hash[h] = tb; + if (tb) { + /* Move the TB to the head of the list */ + *ptb1 = tb->phys_hash_next; + tb->phys_hash_next = tcg_ctx.tb_ctx.tb_phys_hash[h]; + tcg_ctx.tb_ctx.tb_phys_hash[h] = tb; + } return tb; }