From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Rostedt Subject: Re: [PATCH] wrong accounting in direct_remap_pfn_range Date: Wed, 30 Aug 2006 21:03:07 -0400 Message-ID: <44F6354B.2020806@redhat.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020305040200000104080103" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com, quintela@redhat.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------020305040200000104080103 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Keir Fraser wrote: > On 31/8/06 1:37 am, "Steven Rostedt" wrote: > >> grr, I take it back, I am the one that's confused :P >> >> OK, this all happens because this whole blob of code is crazy because it >> is missing a "if (size == 0)" check! > > It's not really missing. We could have a size==0 check *or* we can have the > v!=u check. We don't need both and I think the latter is more obviously > correct, as the test is closer to the code that it 'protects'. Also it's a > fairly idiomatic way of generating and flushing batches of work. > So what is really wrong with this code? Or is the flushes need even on size == 0? -- Steve Signed-off-by: Steven Rostedt --------------020305040200000104080103 Content-Type: text/x-patch; name="ioredirect.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ioredirect.patch" Index: linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c =================================================================== --- linux-2.6-xen-sparse.orig/arch/i386/mm/ioremap-xen.c +++ linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c @@ -56,6 +56,9 @@ static int __direct_remap_pfn_range(stru unsigned long i, start_address; mmu_update_t *u, *v, *w; + if (unlikely(!size)) + return 0; + u = v = w = (mmu_update_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT); if (u == NULL) return -ENOMEM; @@ -91,17 +94,15 @@ static int __direct_remap_pfn_range(stru v++; } - if (v != u) { - /* get the ptep's filled in */ - rc = apply_to_page_range(mm, start_address, - address - start_address, - direct_remap_area_pte_fn, &w); - if (rc) - goto out; - rc = -EFAULT; - if (unlikely(HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)) - goto out; - } + /* get the ptep's filled in */ + rc = apply_to_page_range(mm, start_address, + address - start_address, + direct_remap_area_pte_fn, &w); + if (rc) + goto out; + rc = -EFAULT; + if (unlikely(HYPERVISOR_mmu_update(u, v - u, NULL, domid) < 0)) + goto out; rc = 0; --------------020305040200000104080103 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------020305040200000104080103--