Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Feb 2006 03:24:54 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 90911 for review
Message-ID:  <200602020324.k123OsvR030379@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=90911

Change 90911 by kmacy@kmacy:freebsd7_xen3 on 2006/02/02 03:24:14

	bubble sort last 4MB phys page down to the beginning

Affected files ...

.. //depot/projects/xen3/src/sys/i386-xen/i386-xen/xen_machdep.c#10 edit

Differences ...

==== //depot/projects/xen3/src/sys/i386-xen/i386-xen/xen_machdep.c#10 (text+ko) ====

@@ -558,25 +558,32 @@
 static void
 shift_phys_machine(unsigned long *phys_machine, int nr_pages)
 {
+
         unsigned long *tmp_page, *current_page, *next_page;
 	int i;
 
 	tmp_page = bootmem_alloc(PAGE_SIZE);
-	current_page = phys_machine; 
-	next_page = phys_machine + (PAGE_SIZE/sizeof(unsigned long)); 
-	bcopy(current_page, tmp_page, PAGE_SIZE);
+	current_page = phys_machine + nr_pages - (PAGE_SIZE/sizeof(unsigned long));  
+	next_page = current_page - (PAGE_SIZE/sizeof(unsigned long));  
+	bcopy(phys_machine, tmp_page, PAGE_SIZE);
 
-	for (i = 0; i < (nr_pages - 1024); i++) {
-	        xen_machphys_update(phys_machine[i], i + 1024);
-	}
-	while (next_page < (phys_machine + nr_pages)) { 
+	while (current_page > phys_machine) { 
+	        /*  save next page */
+	        bcopy(next_page, tmp_page, PAGE_SIZE);
+	        /* shift down page */
+		bcopy(current_page, next_page, PAGE_SIZE);
+	        /*  finish swap */
 	        bcopy(tmp_page, current_page, PAGE_SIZE);
-		bcopy(next_page, tmp_page, PAGE_SIZE);
 	  
-		current_page += (PAGE_SIZE/sizeof(unsigned long));
-		next_page += (PAGE_SIZE/sizeof(unsigned long));
+		current_page -= (PAGE_SIZE/sizeof(unsigned long));
+		next_page -= (PAGE_SIZE/sizeof(unsigned long));
+	}
+	bootmem_free(tmp_page, PAGE_SIZE);	
+	
+	for (i = 0; i < nr_pages; i++) {
+	        xen_machphys_update(phys_machine[i], i);
 	}
-	bootmem_free(tmp_page, PAGE_SIZE);
+
 
 
 	memset(phys_machine, INVALID_P2M_ENTRY, PAGE_SIZE);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602020324.k123OsvR030379>