Patchwork A bit optimization for tlb_set_page() (resend)

login
register
mail settings
Submitter Jun Koi
Date May 6, 2010, 5:36 a.m.
Message ID <v2zfdaac4d51005052236o40c1cd47kf871bf7649915a62@mail.gmail.com>
Download mbox | patch
Permalink /patch/51835/
State New
Headers show

Comments

Jun Koi - May 6, 2010, 5:36 a.m.
This patch avoids handling write watchpoints on read-only memory access.
It also breaks the searching loop for watchpoint once the setup for
handling watchpoint later is done.

Signed-off-by: Jun Koi <junkoi2004@gmail.com>
Jan Kiszka - May 8, 2010, 6:53 p.m.
Jun Koi wrote:
> This patch avoids handling write watchpoints on read-only memory access.
> It also breaks the searching loop for watchpoint once the setup for
> handling watchpoint later is done.
> 
> Signed-off-by: Jun Koi <junkoi2004@gmail.com>
> 

Works fine.

Acked-by: Jan Kiszka <jan.kiszka@siemens.com>

> 
> 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 == (wp->vaddr & TARGET_PAGE_MASK)) {
> -            iotlb = io_mem_watch + paddr;
> -            /* TODO: The memory case can be optimized by not trapping
> -               reads of pages with a write breakpoint.  */
> -            address |= TLB_MMIO;
> +            /* Avoid trapping reads of pages with a write breakpoint. */
> +            if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) {
> +                iotlb = io_mem_watch + paddr;
> +                address |= TLB_MMIO;
> +                break;
> +            }
>          }
>      }
Aurelien Jarno - June 30, 2010, 6:31 p.m.
On Thu, May 06, 2010 at 02:36:59PM +0900, Jun Koi wrote:
> This patch avoids handling write watchpoints on read-only memory access.
> It also breaks the searching loop for watchpoint once the setup for
> handling watchpoint later is done.
> 
> Signed-off-by: Jun Koi <junkoi2004@gmail.com>

Thanks, applied.

> 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 == (wp->vaddr & TARGET_PAGE_MASK)) {
> -            iotlb = io_mem_watch + paddr;
> -            /* TODO: The memory case can be optimized by not trapping
> -               reads of pages with a write breakpoint.  */
> -            address |= TLB_MMIO;
> +            /* Avoid trapping reads of pages with a write breakpoint. */
> +            if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) {
> +                iotlb = io_mem_watch + paddr;
> +                address |= TLB_MMIO;
> +                break;
> +            }
>          }
>      }
> 
> 
>

Patch

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 == (wp->vaddr & TARGET_PAGE_MASK)) {
-            iotlb = io_mem_watch + paddr;
-            /* TODO: The memory case can be optimized by not trapping
-               reads of pages with a write breakpoint.  */
-            address |= TLB_MMIO;
+            /* Avoid trapping reads of pages with a write breakpoint. */
+            if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) {
+                iotlb = io_mem_watch + paddr;
+                address |= TLB_MMIO;
+                break;
+            }
         }
     }