Skip to contentSkip to conversation

xenalyze: Raise MAX_CPUS to 256 cpus

PATCH New George Dunlap 1 participant 1 message Jul 20, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xenalyze: Raise MAX_CPUS to 256 cpus

Some systems actually have that many now. (And XenServer builds with MAX_PHYS_CPUS set to 256.)

Also, check if a CPU is out of range before using, warn and exit, instead of segfaulting.

To-do: Make the size dynamically adjustable.

xenalyze.c +9 -1
diff -r 405fc96c0ec2 -r e11e13e66c62 xenalyze.c
@@ -1621,7 +1621,7 @@ struct cr3_value_struct {
 };
 
 #ifndef MAX_CPUS
-#define MAX_CPUS 128
+#define MAX_CPUS 256
 #endif
 typedef uint32_t cpu_mask_t;
 
@@ -7968,6 +7968,14 @@ loff_t scan_for_new_pcpu(loff_t offset) 
     }
 
     cd = (typeof(cd))rec.u.notsc.data;
+
+    if ( cd->cpu > MAX_CPUS )
+    {
+        fprintf(stderr, "%s: cpu %d exceeds MAX_CPU %d!\n",
+                __func__, cd->cpu, MAX_CPUS);
+        /* FIXME: Figure out if we could handle this more gracefully */
+        error(ERR_ASSERT, NULL);
+    }
         
     if(cd->cpu > P.max_active_pcpu || !P.pcpu[cd->cpu].active) {
         struct pcpu_info *p = P.pcpu + cd->cpu;