From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O71Uf-0000rj-IX for qemu-devel@nongnu.org; Wed, 28 Apr 2010 03:15:37 -0400 Received: from [140.186.70.92] (port=44198 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O71Ud-0000pQ-P1 for qemu-devel@nongnu.org; Wed, 28 Apr 2010 03:15:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O71Ub-0001tR-88 for qemu-devel@nongnu.org; Wed, 28 Apr 2010 03:15:35 -0400 Received: from mail-iw0-f196.google.com ([209.85.223.196]:55922) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O71UZ-0001t5-LC for qemu-devel@nongnu.org; Wed, 28 Apr 2010 03:15:32 -0400 Received: by iwn34 with SMTP id 34so10431548iwn.23 for ; Wed, 28 Apr 2010 00:15:31 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4BD7DB82.2080809@web.de> References: <4BD72E96.8050406@web.de> <4BD7DB82.2080809@web.de> From: Jun Koi Date: Wed, 28 Apr 2010 16:13:57 +0900 Message-ID: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH] A bit optimization for tlb_set_page() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: qemu-devel@nongnu.org On Wed, Apr 28, 2010 at 3:53 PM, Jan Kiszka wrote: > Jun Koi wrote: >> On Wed, Apr 28, 2010 at 8:48 AM, Jun Koi wrote: >>> On Wed, Apr 28, 2010 at 3:36 AM, Jan Kiszka wrote: >>>> Jun Koi wrote: >>>>> It is not necessary to continue searching for watchpoint when we >>>>> already found one and setup for handling watchpoint in a search loop >>>>> in tlb_set_page(). >>>>> This patch breaks that search loop on then. >>>> Acked-by: Jan Kiszka >>>> >>>>> Signed-off-by: Jun Koi >>>>> >>>>> diff --git a/exec.c b/exec.c >>>>> index 14d1fd7..6329775 100644 >>>>> --- a/exec.c >>>>> +++ b/exec.c >>>>> @@ -2240,6 +2240,7 @@ void tlb_set_page(CPUState *env, target_ulong v= addr, >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0/* TODO: The memory case can be optimized = by not trapping >>>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 reads of pages with a write breakpoin= t. =A0*/ >>>> PS: Don't you also want to address this todo while you are at it? :) >>>> >> >> Do you have any comment on below patch? >> >> Thanks, >> J >> >> >> Dont handle write watchpoints on read-only memory access. >> This patch also breaks the searching loop for watchpoint once the >> setup facilities for handling watchpoint later is done. >> >> Signed-off-by: Jun Koi >> >> diff --git a/exec.c b/exec.c >> index 14d1fd7..3f2d9ed 100644 >> --- a/exec.c >> +++ b/exec.c >> @@ -2236,10 +2236,12 @@ void tlb_set_page(CPUState *env, target_ulong va= ddr, >> =A0 =A0 =A0 =A0 watchpoint trap routines. =A0*/ >> =A0 =A0 =A0QTAILQ_FOREACH(wp, &env->watchpoints, entry) { >> =A0 =A0 =A0 =A0 =A0if (vaddr =3D=3D (wp->vaddr & TARGET_PAGE_MASK)) { >> - =A0 =A0 =A0 =A0 =A0 =A0iotlb =3D io_mem_watch + paddr; >> - =A0 =A0 =A0 =A0 =A0 =A0/* TODO: The memory case can be optimized by no= t trapping >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 reads of pages with a write breakpoint. = =A0*/ >> - =A0 =A0 =A0 =A0 =A0 =A0address |=3D TLB_MMIO; >> + =A0 =A0 =A0 =A0 =A0 =A0/* Avoid trapping reads of pages with a write b= reakpoint. */ >> + =A0 =A0 =A0 =A0 =A0 =A0if (!((prot & PAGE_WRITE =3D=3D 0) && (wp->flag= s & >> BP_MEM_WRITE !=3D 0))) { > > Patch is line-wrapped. That is the fault of Gmail. > Besides that > > if ((wp->flags & BP_MEM_READ) || (prot & PAGE_WRITE)) > > is more readable IMHO. Agreed. Please see my updated patch. Thanks, Jun Dont handle write watchpoints on read-only memory access. This patch also breaks the searching loop for watchpoint once the setup for handling watchpoint later is done. Signed-off-by: Jun Koi diff --git a/exec.c b/exec.c index 14d1fd7..6fd859f 100644 --- a/exec.c +++ b/exec.c @@ -2236,10 +2236,12 @@ void tlb_set_page(CPUState *env, target_ulong vaddr= , watchpoint trap routines. */ QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if (vaddr =3D=3D (wp->vaddr & TARGET_PAGE_MASK)) { - iotlb =3D io_mem_watch + paddr; - /* TODO: The memory case can be optimized by not trapping - reads of pages with a write breakpoint. */ - address |=3D TLB_MMIO; + /* Avoid trapping reads of pages with a write breakpoint. */ + if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) { + iotlb =3D io_mem_watch + paddr; + address |=3D TLB_MMIO; + break; + } } }