PERFORCE change 90911 for review

Kip Macy kmacy at FreeBSD.org
Wed Feb 1 19:24:55 PST 2006


http://perforce.freebsd.org/chv.cgi?CH=90911

Change 90911 by kmacy at 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);


More information about the p4-projects mailing list