Received: from eggs.gnu.org ([208.118.235.92]:38785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcWzN-0004TY-Gk for qemu-devel@nongnu.org; Sun, 25 Nov 2012 02:50:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TcWzL-0002c2-Et for qemu-devel@nongnu.org; Sun, 25 Nov 2012 02:50:53 -0500 Received: from csmailer.cs.nctu.edu.tw ([140.113.235.130]:28062) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TcWzK-0002bj-J3 for qemu-devel@nongnu.org; Sun, 25 Nov 2012 02:50:51 -0500 Received: from csmailer.cs.nctu.edu.tw (localhost [127.0.0.1]) by csmailer.cs.nctu.edu.tw (Postfix) with ESMTP id 897A4A6C for ; Sun, 25 Nov 2012 15:50:44 +0800 (CST) 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 8C3D6A6B for ; Sun, 25 Nov 2012 15:50:43 +0800 (CST) Received: (from chenwj@localhost) by alumni.cs.nctu.edu.tw (8.14.5/8.14.5/Submit) id qAP7ogC8003309 for qemu-devel@nongnu.org; Sun, 25 Nov 2012 15:50:42 +0800 (CST) (envelope-from chenwj) Date: Sun, 25 Nov 2012 15:50:42 +0800 From: =?utf-8?B?6Zmz6Z+L5Lu7IChXZWktUmVuIENoZW4p?= Message-ID: <20121125075042.GA76349@cs.nctu.edu.tw> References: <20121120123035.GA9929@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] 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 ping? On Tue, Nov 20, 2012 at 12:41:03PM +0000, Peter Maydell wrote: > On 20 November 2012 12:30, =E9=99=B3=E9=9F=8B=E4=BB=BB (Wei-Ren Chen) <= chenwj@iis.sinica.edu.tw> wrote: > > When tb_remove was first commited at fd6ce8f6, there were three dif= ferent > > calls pass different names to offsetof. In current codebase, the othe= r two > > calls are replaced with tb_page_remove. There is no need to have a ge= neral > > tb_remove. Omit passing the third parameter and using tb1->phys_hash_= next > > directly. >=20 > I like this, it makes the function less confusing to remove this > now-unneeded generality. >=20 > > 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 */ >=20 > This comment is now a bit out of date (and in fact it has been for > some time) and should probably be deleted. (The function that really > needs a comment is the top level tb_phys_invalidate(), rather than > the helpers tb_hash_remove/tb_page_remove/tb_jmp_remove.) >=20 > > -static inline void tb_remove(TranslationBlock **ptb, TranslationBloc= k *tb, > > - int next_offset) > > +static inline void tb_hash_remove(TranslationBlock **ptb, Translatio= nBlock *tb) > > { > > TranslationBlock *tb1; > > for(;;) { > > tb1 =3D *ptb; > > if (tb1 =3D=3D tb) { > > - *ptb =3D *(TranslationBlock **)((char *)tb1 + next_offse= t); > > + *ptb =3D tb1->phys_hash_next; > > break; > > } > > - ptb =3D (TranslationBlock **)((char *)tb1 + next_offset); > > + ptb =3D &(tb1->phys_hash_next); >=20 > You don't need these brackets. >=20 > > } > > } > > > > @@ -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); > > > > /* remove the TB from the page list */ > > if (tb->page_addr[0] !=3D page_addr) { > > -- > > 1.7.3.4 >=20 >=20 > -- PMM --=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