Skip to contentSkip to conversation

fix page size assumptions in tools

PATCH New Matt Chapman 1 participant 1 message Jun 14, 2005 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix page size assumptions in tools

This patch defines XC_PAGE_SIZE in libxc and removes assumptions about the page size being 4096 bytes, in preparation for the userspace tools supporting ia64 Xen (which currently uses a 16KB page size).

Matt

===== tools/libxc/xc.h 1.88 vs edited =====

tools/libxc/xc.h +8 -0
@@ -26,6 +26,14 @@
 #include <xen/event_channel.h>
 #include <xen/sched_ctl.h>
 
+#ifdef __ia64__
+#define XC_PAGE_SHIFT           14
+#else
+#define XC_PAGE_SHIFT           12
+#endif
+#define XC_PAGE_SIZE            (1UL << XC_PAGE_SHIFT)
+#define XC_PAGE_MASK            (~(XC_PAGE_SIZE-1))
+
 /*
  *  DEFINITIONS FOR CPU BARRIERS
  */ 

===== tools/libxc/xc_domain.c 1.64 vs edited =====

tools/libxc/xc_domain.c +3 -2
@@ -236,10 +236,11 @@
                                           unsigned int mem_kb)
 {
     int err;
+    unsigned int npages = mem_kb / (PAGE_SIZE/1024);
 
     err = do_dom_mem_op(xc_handle, MEMOP_increase_reservation, NULL,
-                        mem_kb / 4, 0, domid);
-    if (err == mem_kb / 4)
+                        npages, 0, domid);
+    if (err == npages)
         return 0;
 
     if (err > 0) {

===== tools/libxc/xc_private.h 1.52 vs edited =====

tools/libxc/xc_private.h +1 -1
@@ -49,7 +49,7 @@
 #define L4_PAGETABLE_ENTRIES    512
 #endif
  
-#define PAGE_SHIFT              L1_PAGETABLE_SHIFT
+#define PAGE_SHIFT              XC_PAGE_SHIFT
 #define PAGE_SIZE               (1UL << PAGE_SHIFT)
 #define PAGE_MASK               (~(PAGE_SIZE-1))
 

===== tools/python/xen/lowlevel/xc/xc.c 1.92 vs edited =====

tools/python/xen/lowlevel/xc/xc.c +1 -1
@@ -239,7 +239,7 @@
                                   "paused",    info[i].paused,
                                   "blocked",   info[i].blocked,
                                   "running",   info[i].running,
-                                  "mem_kb",    info[i].nr_pages*4,
+                                  "mem_kb",    info[i].nr_pages*(XC_PAGE_SIZE/1024),
                                   "cpu_time",  info[i].cpu_time,
                                   "maxmem_kb", info[i].max_memkb,
                                   "shutdown_reason", info[i].shutdown_reason);

===== tools/python/xen/lowlevel/xu/xu.c 1.36 vs edited =====

tools/python/xen/lowlevel/xu/xu.c +0 -3
@@ -46,9 +46,6 @@
 /* EVTCHN_UNBIND: Unbind from the specified event-channel port. */
 #define EVTCHN_UNBIND _IO('E', 3)
 
-/* Size of a machine page frame. */
-#define PAGE_SIZE 4096
-
 /* Set the close-on-exec flag on a file descriptor.  Doesn't currently bother
  * to check for errors. */
 /*

===== tools/python/xen/xend/XendCheckpoint.py 1.6 vs edited =====

tools/python/xen/xend/XendCheckpoint.py +0 -1
@@ -17,7 +17,6 @@
 from XendLogging import log
 
 SIGNATURE = "LinuxGuestRecord"
-PAGE_SIZE = 4096
 PATH_XC_SAVE = "/usr/libexec/xen/xc_save"
 PATH_XC_RESTORE = "/usr/libexec/xen/xc_restore"
 

===== tools/xcs/xcs.h 1.2 vs edited =====

tools/xcs/xcs.h +1 -1
@@ -37,7 +37,7 @@
 /* ------[ Other required defines ]----------------------------------------*/
 
 /* Size of a machine page frame. */
-#define PAGE_SIZE 4096
+#define PAGE_SIZE XC_PAGE_SIZE
 
 #ifndef timersub /* XOPEN and __BSD don't cooperate well... */
 #define timersub(a, b, result)                                                \

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel