From patchwork Thu Mar 24 21:56:46 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: 8665031 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 476329F44D for ; Thu, 24 Mar 2016 21:59:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91A242022A for ; Thu, 24 Mar 2016 21:59:49 +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 D935D2021F for ; Thu, 24 Mar 2016 21:59:48 +0000 (UTC) Received: from localhost ([::1]:52976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajDIC-00040i-2T for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Mar 2016 17:59:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajDGH-0000Je-9S for qemu-devel@nongnu.org; Thu, 24 Mar 2016 17:57:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ajDGF-0008Tz-Qy for qemu-devel@nongnu.org; Thu, 24 Mar 2016 17:57:49 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:34014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ajDGF-0008Tv-JW for qemu-devel@nongnu.org; Thu, 24 Mar 2016 17:57:47 -0400 Received: by mail-lf0-x229.google.com with SMTP id c62so41542260lfc.1 for ; Thu, 24 Mar 2016 14:57:47 -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 :mime-version:content-transfer-encoding; bh=BJ4OOXy7UN/ZRyds0s0nEzCx1pREh1geCM2WuOli5OI=; b=gQjQPDVoo9fysy7ZschJZk6HcKxyMpTwxU26etW2/MhBav1rCwfPFOBcje62vDeCfs hqCy+wiBEhU3giC3sTlhhTDOoMo18xodoDHPLdVNYwrcjYuxEUo9KRYUEJ69LE9GhQPH fvH0tO3JPgO1TxzpL2fj1VNx22kFWneJVCFPU= 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:mime-version:content-transfer-encoding; bh=BJ4OOXy7UN/ZRyds0s0nEzCx1pREh1geCM2WuOli5OI=; b=TYp6T37c72ZP/SAWPdCXuht6/056QsspMrye6G/8Sl/YzKdwBY87AMDsfW9Ju0VERo MjDn6w2L9fCsGNaYB02BWbF8iK/5FxrYzi32+YcZNrqwo1IoF4nb2LRksoA2Wi9dD10u Kp3eJq/I9AzQb+9ZRVCcqgeMDZtUhUh4RNJkhbZ2J1alV4mTOyQ2cNYm540xUuceXXzc wK6qL7991ODZpCawW0ziqUZ6zPXam9bL0j1xKcHGghnL+/yECFvNYxgyVfU4FqK3JsVF wYcRF+cBZBGi+leND9D06ajYmUnsSyrXdmBnYspmFttMmg6dBBh29EhVOe+6W/KDcQ68 Dksw== X-Gm-Message-State: AD7BkJKmzRWpjjaNxN3jtLHWNkD9JYtQUaIvroRZLxKadi/O9x1qumn16PH2zTqG7ITA+/Jg X-Received: by 10.25.154.193 with SMTP id c184mr4495847lfe.69.1458856666879; Thu, 24 Mar 2016 14:57:46 -0700 (PDT) Received: from sergey-laptop.Dlink (broadband-46-188-121-115.2com.net. [46.188.121.115]) by smtp.gmail.com with ESMTPSA id a14sm1547144lfe.7.2016.03.24.14.57.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Mar 2016 14:57:46 -0700 (PDT) From: sergey.fedorov@linaro.org To: qemu-devel@nongnu.org Date: Fri, 25 Mar 2016 00:56:46 +0300 Message-Id: <1458856607-3275-8-git-send-email-sergey.fedorov@linaro.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458856607-3275-1-git-send-email-sergey.fedorov@linaro.org> References: <1458856607-3275-1-git-send-email-sergey.fedorov@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::229 Cc: Sergey Fedorov , Peter Crosthwaite , Paolo Bonzini , Sergey Fedorov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Subject: [Qemu-devel] [PATCH v2 7/8] tcg: Extract removing of jumps to TB from tb_phys_invalidate() 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: 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 --- translate-all.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/translate-all.c b/translate-all.c index c89480e7e28b..80f0714fbb84 100644 --- a/translate-all.c +++ b/translate-all.c @@ -960,14 +960,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); @@ -1001,22 +1024,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++; }