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 Date: Wed, 21 Nov 2012 07:52:48 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= Message-ID: <20121120235248.GA24638@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2] exec.c: Use tb1->phys_hash_next directly in tb_remove List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Evgeny Voevodin When tb_remove was first commited at fd6ce8f6, there were three differe= nt calls pass different names to offsetof. In current codebase, the other tw= o calls are replaced with tb_page_remove. There is no need to have a genera= l tb_remove. Omit passing the third parameter and using tb1->phys_hash_next directly. Signed-off-by: Chen Wei-Ren --- 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) =20 #endif =20 -/* invalidate one TB */ -static inline void tb_remove(TranslationBlock **ptb, TranslationBlock *t= b, - int next_offset) +static inline void tb_hash_remove(TranslationBlock **ptb, TranslationBlo= ck *tb) { TranslationBlock *tb1; for(;;) { tb1 =3D *ptb; if (tb1 =3D=3D tb) { - *ptb =3D *(TranslationBlock **)((char *)tb1 + next_offset); + *ptb =3D tb1->phys_hash_next; break; } - ptb =3D (TranslationBlock **)((char *)tb1 + next_offset); + ptb =3D &tb1->phys_hash_next; } } =20 @@ -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])); } =20 +/* 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 =3D tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK); h =3D 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); =20 /* remove the TB from the page list */ if (tb->page_addr[0] !=3D page_addr) { --=20 1.7.3.4 --=20 Wei-Ren Chen (=E9=99=B3=E9=9F=8B=E4=BB=BB) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj