From patchwork Tue Nov 20 23:52:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6Zmz6Z+L5Lu7?= X-Patchwork-Id: 200531 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 568422C00A7 for ; Wed, 21 Nov 2012 10:53:10 +1100 (EST) Received: from localhost ([::1]:34454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Taxcq-0007de-FO for incoming@patchwork.ozlabs.org; Tue, 20 Nov 2012 18:53:08 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Taxcj-0007dW-3s for qemu-devel@nongnu.org; Tue, 20 Nov 2012 18:53:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Taxch-0001ok-EM for qemu-devel@nongnu.org; Tue, 20 Nov 2012 18:53:00 -0500 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:38455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Taxcg-0001oH-Tr for qemu-devel@nongnu.org; Tue, 20 Nov 2012 18:52:59 -0500 Received: from csmailer.cs.nctu.edu.tw (localhost [127.0.0.1]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id 971BFB63; Wed, 21 Nov 2012 07:52:51 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cs.nctu.edu.tw; h=date :from:to:cc:subject:message-id:mime-version:content-type :content-transfer-encoding; s=rsa1024; bh=tWRdlz4CJCYxdEN263l3w9 yn5iQ=; b=RkdFjmvvQgDiYvG7YhmbMXr4H2nsLDKneAyKOtHCWWZ0JNREducSM1 sdcsCpJAw8poE1EPEP8CIxaMuDSYy3s7+XcWrfeeTZdc/nWyLzTcydrC230omPxH +tNbAOrtBxSfxhFJ2z2fgdqNovXxE4A2vDKuIRr2C6VtczkKe5klY= Received: from alumni.cs.nctu.edu.tw (alumni.cs.nctu.edu.tw [140.113.235.116]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id 63650B62; Wed, 21 Nov 2012 07:52:51 +0800 (CST) Received: (from chenwj@localhost) by alumni.cs.nctu.edu.tw (8.14.5/8.14.5/Submit) id qAKNqm9O024719; Wed, 21 Nov 2012 07:52:48 +0800 (CST) (envelope-from chenwj) Date: Wed, 21 Nov 2012 07:52:48 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= To: qemu-devel@nongnu.org Message-ID: <20121120235248.GA24638@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 140.113.235.130 Cc: Peter Maydell , Evgeny Voevodin Subject: [Qemu-devel] [PATCH v2] exec.c: Use tb1->phys_hash_next directly in tb_remove 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When tb_remove was first commited at fd6ce8f6, there were three different calls pass different names to offsetof. In current codebase, the other two calls are replaced with tb_page_remove. There is no need to have a general tb_remove. Omit passing the third parameter and using tb1->phys_hash_next directly. Signed-off-by: Chen Wei-Ren Reviewed-by: Peter Maydell --- v2: Address Peter's comment. - place comment used belong tb_remove above tb_phys_invalidate. - remove unnecessary bracket. exec.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) diff --git a/exec.c b/exec.c index 8435de0..6343838 100644 --- a/exec.c +++ b/exec.c @@ -862,18 +862,16 @@ static void tb_page_check(void) #endif -/* invalidate one TB */ -static inline void tb_remove(TranslationBlock **ptb, TranslationBlock *tb, - int next_offset) +static inline void tb_hash_remove(TranslationBlock **ptb, TranslationBlock *tb) { TranslationBlock *tb1; for(;;) { tb1 = *ptb; if (tb1 == tb) { - *ptb = *(TranslationBlock **)((char *)tb1 + next_offset); + *ptb = tb1->phys_hash_next; break; } - ptb = (TranslationBlock **)((char *)tb1 + next_offset); + ptb = &tb1->phys_hash_next; } } @@ -929,6 +927,7 @@ static inline void tb_reset_jump(TranslationBlock *tb, int n) tb_set_jmp_target(tb, n, (uintptr_t)(tb->tc_ptr + tb->tb_next_offset[n])); } +/* invalidate one TB */ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) { CPUArchState *env; @@ -940,8 +939,7 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) /* remove the TB from the hash list */ phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); h = tb_phys_hash_func(phys_pc); - tb_remove(&tb_phys_hash[h], tb, - offsetof(TranslationBlock, phys_hash_next)); + tb_hash_remove(&tb_phys_hash[h], tb); /* remove the TB from the page list */ if (tb->page_addr[0] != page_addr) {