Skip to contentSkip to conversation

_csched_cpu_pick(): don't write idle bias more than once

PATCH New Jan Beulich 1 participant 1 message Mar 14, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 _csched_cpu_pick(): don't write idle bias more than once

For the bias to be really meaningful, it should be updated onbly when the CPU selected will indeed be returned (and hence used for placing the vCPU in question).

xen/common/sched_credit.c +6 -3
@@ -464,6 +464,7 @@ _csched_cpu_pick(const struct scheduler 
     cpumask_t cpus;
     cpumask_t idlers;
     cpumask_t *online;
+    struct csched_pcpu *spc = NULL;
     int cpu;
 
     /*
@@ -531,9 +532,8 @@ _csched_cpu_pick(const struct scheduler 
                   && (weight_cpu * migrate_factor < weight_nxt) ) )
         {
             cpus_and(nxt_idlers, cpus, nxt_idlers);
-            cpu = cycle_cpu(CSCHED_PCPU(nxt)->idle_bias, nxt_idlers);
-            if ( commit )
-               CSCHED_PCPU(nxt)->idle_bias = cpu;
+            spc = CSCHED_PCPU(nxt);
+            cpu = cycle_cpu(spc->idle_bias, nxt_idlers);
             cpus_andnot(cpus, cpus, per_cpu(cpu_sibling_map, cpu));
         }
         else
@@ -542,6 +542,9 @@ _csched_cpu_pick(const struct scheduler 
         }
     }
 
+    if ( commit && spc )
+       spc->idle_bias = cpu;
+
     return cpu;
 }
 

For the bias to be really meaningful, it should be updated onbly when the CPU selected will indeed be returned (and hence used for placing the vCPU in question).

xen/common/sched_credit.c +6 -3
@@ -464,6 +464,7 @@ _csched_cpu_pick(const struct scheduler 
     cpumask_t cpus;
     cpumask_t idlers;
     cpumask_t *online;
+    struct csched_pcpu *spc = NULL;
     int cpu;
 
     /*
@@ -531,9 +532,8 @@ _csched_cpu_pick(const struct scheduler 
                   && (weight_cpu * migrate_factor < weight_nxt) ) )
         {
             cpus_and(nxt_idlers, cpus, nxt_idlers);
-            cpu = cycle_cpu(CSCHED_PCPU(nxt)->idle_bias, nxt_idlers);
-            if ( commit )
-               CSCHED_PCPU(nxt)->idle_bias = cpu;
+            spc = CSCHED_PCPU(nxt);
+            cpu = cycle_cpu(spc->idle_bias, nxt_idlers);
             cpus_andnot(cpus, cpus, per_cpu(cpu_sibling_map, cpu));
         }
         else
@@ -542,6 +542,9 @@ _csched_cpu_pick(const struct scheduler 
         }
     }
 
+    if ( commit && spc )
+       spc->idle_bias = cpu;
+
     return cpu;
 }
 

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