From patchwork Fri May 13 00:13:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9087151 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 69C50BF29F for ; Fri, 13 May 2016 00:26:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B2851201F2 for ; Fri, 13 May 2016 00:26:15 +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 03A22200DC for ; Fri, 13 May 2016 00:26:15 +0000 (UTC) Received: from localhost ([::1]:60403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10vm-0004BD-1e for patchwork-qemu-devel@patchwork.kernel.org; Thu, 12 May 2016 20:26:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10lF-0001mQ-N0 for qemu-devel@nongnu.org; Thu, 12 May 2016 20:15:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b10lC-0002yV-Bz for qemu-devel@nongnu.org; Thu, 12 May 2016 20:15:21 -0400 Received: from mail-qg0-x241.google.com ([2607:f8b0:400d:c04::241]:33316) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b10lC-0002yQ-6l for qemu-devel@nongnu.org; Thu, 12 May 2016 20:15:18 -0400 Received: by mail-qg0-x241.google.com with SMTP id 90so6866395qgz.0 for ; Thu, 12 May 2016 17:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZA/o7fOlsQwfTnNrgvp/YQMpJRjnEaaH2a37NXwr+RU=; b=E1XXqIXyn1v1pRFXzz2yNP72E5WlcFdIVXj9uhnj1rXYnwwpytHz7Gj66hkEo3AldA 4DBedmk8RIm5fqR1ZhVCb8m/SA/p+Y5G2WYnzoE25wML8HpLMUlFQRa7nCBcGF8X75XS vOOSj5uqPu0gLJt5mFDmvYWSloBt3ApUKib9Opb/UPAZQZk0mY1mipwHSbFlYzaw5m3A yml6WZeK575nyKS53QApJ/5UjPAkt7aBPqt4qlR9m1I+HdmVypBp4K/x8T696sy5M/3r dt/fibKQJDO07V0rEBxXg8DaAqMtVWGFmlyO0WgqRh3K/8/Xtbt0HEFjeP9hKjVlKECT OPsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ZA/o7fOlsQwfTnNrgvp/YQMpJRjnEaaH2a37NXwr+RU=; b=AaN3T7Xzmdm/JVstfNh2VkU0qjwausGgtTLwYUBZ/EIzeltQ02X0KT4xDpaWyKUWSB NRdCcrAeBQU/C9mcMzFHPFBntJuDj/KurMkiocyMD5130qHHjSkXFnBpxcYE/CfaGRUV gWInicoZrvDJMUifWhfWQhAidj27i0Pwm64Ekw37JF3DDNxKp92UsmBXVIO1wLWApydj TLc9JjjeOWDTsvL1rU+/0mQ2MWdHoQhej7HX7qOYCuVXZjiLSflBcsDEWmxCsQapAJus tBdr1+lFmxUlBrURq/yAGM4nLLXdtiawFr8ft/q8oswctXjpaVmR54fQTwp67Gf7qKth nJbA== X-Gm-Message-State: AOPr4FWY8ODhY+G07/vdqCXvo5+0m06pYC3+6Go7ih961v9L4Xkv4xYpxIMd2Id/U/c65w== X-Received: by 10.141.44.135 with SMTP id v129mr13421617qhe.46.1463098517987; Thu, 12 May 2016 17:15:17 -0700 (PDT) Received: from bigtime.com ([172.56.44.137]) by smtp.gmail.com with ESMTPSA id w16sm7171321qka.35.2016.05.12.17.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 May 2016 17:15:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 12 May 2016 14:13:23 -1000 Message-Id: <1463098420-29113-23-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463098420-29113-1-git-send-email-rth@twiddle.net> References: <1463098420-29113-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::241 Subject: [Qemu-devel] [PULL 22/39] tcg: Extract removing of jumps to TB from tb_phys_invalidate() 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: peter.maydell@linaro.org, Sergey Fedorov , Sergey Fedorov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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: Sergey Fedorov Move the code for removing jumps to a TB out of tb_phys_invalidate() to a separate static inline function tb_jmp_unlink(). This simplifies tb_phys_invalidate() and improves code structure. Signed-off-by: Sergey Fedorov Signed-off-by: Sergey Fedorov Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- translate-all.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/translate-all.c b/translate-all.c index 5e057ba..9a57aab 100644 --- a/translate-all.c +++ b/translate-all.c @@ -962,14 +962,37 @@ static inline void tb_reset_jump(TranslationBlock *tb, int n) tb_set_jmp_target(tb, n, addr); } +/* remove any jumps to the TB */ +static inline void tb_jmp_unlink(TranslationBlock *tb) +{ + uintptr_t tb1, tb2; + unsigned int n1; + + tb1 = tb->jmp_list_first; + for (;;) { + TranslationBlock *tmp_tb; + n1 = tb1 & 3; + if (n1 == 2) { + break; + } + tmp_tb = (TranslationBlock *)(tb1 & ~3); + tb2 = tmp_tb->jmp_list_next[n1]; + tb_reset_jump(tmp_tb, n1); + tmp_tb->jmp_list_next[n1] = (uintptr_t)NULL; + tb1 = tb2; + } + + assert(((uintptr_t)tb & 3) == 0); + tb->jmp_list_first = (uintptr_t)tb | 2; /* fail safe */ +} + /* invalidate one TB */ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) { CPUState *cpu; PageDesc *p; - unsigned int h, n1; + unsigned int h; tb_page_addr_t phys_pc; - uintptr_t tb1, tb2; /* remove the TB from the hash list */ phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); @@ -1003,22 +1026,7 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) tb_remove_from_jmp_list(tb, 1); /* suppress any remaining jumps to this TB */ - tb1 = tb->jmp_list_first; - for (;;) { - TranslationBlock *tmp_tb; - n1 = tb1 & 3; - if (n1 == 2) { - break; - } - tmp_tb = (TranslationBlock *)(tb1 & ~3); - tb2 = tmp_tb->jmp_list_next[n1]; - tb_reset_jump(tmp_tb, n1); - tmp_tb->jmp_list_next[n1] = (uintptr_t)NULL; - tb1 = tb2; - } - - assert(((uintptr_t)tb & 3) == 0); - tb->jmp_list_first = (uintptr_t)tb | 2; /* fail safe */ + tb_jmp_unlink(tb); tcg_ctx.tb_ctx.tb_phys_invalidate_count++; }