From patchwork Wed Apr 28 07:13:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jun Koi X-Patchwork-Id: 51149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B5A16B7D41 for ; Wed, 28 Apr 2010 17:23:47 +1000 (EST) Received: from localhost ([127.0.0.1]:50448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O71W1-0000tW-Sq for incoming@patchwork.ozlabs.org; Wed, 28 Apr 2010 03:17:01 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=RfFPV0CcMNkl8a4JHq8O0VOpZfHqTah29jykuwx4Hqo=; b=UURlyuDqeVSc4np7mOTpJizX7p/3mMFuJ5AoEvR8V/yi1eNjy7idZe1LkF35pZYMGb 1uQmLTXxjCO1GLfZIKQjODSkmq6OuSB4/syGYx4abQwsMh/qjRDXE0QQFrbjQhbVU2tY GR38+tCiAg98cBZkZ6dRz7yfdbSfV5vGzN3p4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=wNsymHAV8GNbFYcQ4aBKPYI7ZrqMJqoUqlTgTbAGZHpiBhZ9HB+DixC1q9Sx0Jl5uQ 5v2TEEXR3T8eaBKDyRERIwiOtS74ZKJppI/YzcMoRPf1yCo34YTqc1ijdNuCdMlaNZuH OhYac9F2BJjsSHG+hc3Z6LvZ7u/iFPPPpnZAs= Received: by 10.231.182.140 with SMTP id cc12mr2272834ibb.18.1272438930912; Wed, 28 Apr 2010 00:15:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.148.208 with HTTP; Wed, 28 Apr 2010 00:13:57 -0700 (PDT) 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: To: Jan Kiszka X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] Re: [PATCH] A bit optimization for tlb_set_page() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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 vaddr, >>>>>              /* TODO: The memory case can be optimized by not trapping >>>>>                 reads of pages with a write breakpoint.  */ >>>> 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 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 == 0) && (wp->flags & >> BP_MEM_WRITE != 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 == (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; + } } }