All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <srostedt@redhat.com>
To: xen-devel@lists.xensource.com
Cc: quintela@redhat.com
Subject: [PATCH] wrong accounting in direct_remap_pfn_range
Date: Tue, 29 Aug 2006 12:25:34 -0400	[thread overview]
Message-ID: <44F46A7E.9010906@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1048 bytes --]

Looking into the code in linux-2.6-xen-sparse/arch/i386/mm/ioremap-xen.c

I found some logic that did not make sense.  We have a loop than updates 
the page tables in __direct_remap_pfn_range, and in the beginning of 
that loop, there is a test that if we finished the page
(v-u == PAGE_SIZE/sizeof(mmu_update_t)) we call the hypervisor to do our 
update.  This is all fine and dandy but, but the code right after the 
loop seems to be wrong.

There is a check if (v != u) then do some more work.  I'm assuming that 
this code is there in case we didn't reach the if statement at the top 
of the loop.  But what is wrong is that this check is invalid.  Although 
the loop if statement sets v = u, the following if statement ignores the 
fact that v++ is done at the bottom of the loop.  So if we really want 
to do this extra work if we didn't finish the loop, then the test really 
needs to be.

if ((v - u) != 1) { .... }


Unless I'm missing something here, I've attached a patch.

-- Steve

Signed-off-by: Steven Rostedt <srostedt@redhat.com>


[-- Attachment #2: ioredirect.patch --]
[-- Type: text/x-patch, Size: 710 bytes --]

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
@@ -91,7 +91,13 @@ static int __direct_remap_pfn_range(stru
 		v++;
 	}
 
-	if (v != u) {
+	/*
+	 * If we didn't finish the page in the previous loop then we
+	 * need to process it now.  We take into account the v++
+	 * at the end of the loop, so the test to know if we finished
+	 * or not is really a +1 difference and not an equal.
+	 */
+	if ((v - u) != 1) {
 		/* get the ptep's filled in */
 		rc = apply_to_page_range(mm, start_address,
 					 address - start_address,

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2006-08-29 16:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-29 16:25 Steven Rostedt [this message]
2006-08-29 18:22 ` [PATCH] wrong accounting in direct_remap_pfn_range Steven Rostedt
2006-08-30 21:29   ` Keir Fraser
2006-08-31  0:17     ` Steven Rostedt
2006-08-31  0:37       ` Steven Rostedt
2006-08-31  0:42         ` Keir Fraser
2006-08-31  0:47           ` Steven Rostedt
2006-08-31  1:03           ` Steven Rostedt
2006-08-31  1:05             ` Keir Fraser
2006-08-31  1:35               ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44F46A7E.9010906@redhat.com \
    --to=srostedt@redhat.com \
    --cc=quintela@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.