From patchwork Tue Nov 20 12:30:35 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: 200317 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 429662C0097 for ; Tue, 20 Nov 2012 23:31:02 +1100 (EST) Received: from localhost ([::1]:46140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tamyh-0000jC-PT for incoming@patchwork.ozlabs.org; Tue, 20 Nov 2012 07:30:59 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TamyV-0000iu-Nr for qemu-devel@nongnu.org; Tue, 20 Nov 2012 07:30:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TamyQ-0006jt-Hc for qemu-devel@nongnu.org; Tue, 20 Nov 2012 07:30:47 -0500 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:27220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TamyP-0006jI-Vv for qemu-devel@nongnu.org; Tue, 20 Nov 2012 07:30:42 -0500 Received: from csmailer.cs.nctu.edu.tw (localhost [127.0.0.1]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id CBB3838B; Tue, 20 Nov 2012 20:30:38 +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; s= rsa1024; bh=GYKBeZBWTeWSXgHGLCw76ViZvbY=; b=KjNjguuC6ya8SjYsbicx tV9FXYjjFXs6qDGxxsuBJMArbkefE9rRkWN2cpi8PHRUaQJ33EtAZaHgpJTjBG7Z tnSYeLhGshr892c/AY4F6G3iSoESTTPNDiMw7p+46tvFpyEH4jV0J3Tnb1nauBOr MgxPQSlttQVn7nEvylAXSsg= 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 B51DC38A; Tue, 20 Nov 2012 20:30:38 +0800 (CST) Received: (from chenwj@localhost) by alumni.cs.nctu.edu.tw (8.14.5/8.14.5/Submit) id qAKCUZri010146; Tue, 20 Nov 2012 20:30:35 +0800 (CST) (envelope-from chenwj) Date: Tue, 20 Nov 2012 20:30:35 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= To: qemu-devel@nongnu.org Message-ID: <20121120123035.GA9929@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] 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 --- exec.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index 8435de0..e54fce2 100644 --- a/exec.c +++ b/exec.c @@ -863,17 +863,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); } } @@ -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) {