[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] credit: allocate CPU masks dynamically



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1319183043 -7200
# Node ID 8269826353d8b9e5bb6248f22e85f6d4280ad9c9
# Parent  53528bab2eb423c352d6d43963b9bb7ee16abf18
credit: allocate CPU masks dynamically

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 53528bab2eb4 -r 8269826353d8 xen/common/sched_credit.c
--- a/xen/common/sched_credit.c Fri Oct 21 09:43:35 2011 +0200
+++ b/xen/common/sched_credit.c Fri Oct 21 09:44:03 2011 +0200
@@ -166,8 +166,8 @@
     uint32_t ncpus;
     struct timer  master_ticker;
     unsigned int master;
-    cpumask_t idlers;
-    cpumask_t cpus;
+    cpumask_var_t idlers;
+    cpumask_var_t cpus;
     uint32_t weight;
     uint32_t credit;
     int credit_balance;
@@ -283,7 +283,7 @@
      */
     if ( cur->pri > CSCHED_PRI_IDLE )
     {
-        if ( cpumask_empty(&prv->idlers) )
+        if ( cpumask_empty(prv->idlers) )
         {
             CSCHED_STAT_CRANK(tickle_idlers_none);
         }
@@ -291,7 +291,7 @@
         {
             cpumask_t idle_mask;
 
-            cpumask_and(&idle_mask, &prv->idlers, new->vcpu->cpu_affinity);
+            cpumask_and(&idle_mask, prv->idlers, new->vcpu->cpu_affinity);
             if ( !cpumask_empty(&idle_mask) )
             {
                 CSCHED_STAT_CRANK(tickle_idlers_some);
@@ -327,11 +327,11 @@
 
     prv->credit -= prv->credits_per_tslice;
     prv->ncpus--;
-    cpu_clear(cpu, prv->idlers);
-    cpu_clear(cpu, prv->cpus);
+    cpumask_clear_cpu(cpu, prv->idlers);
+    cpumask_clear_cpu(cpu, prv->cpus);
     if ( (prv->master == cpu) && (prv->ncpus > 0) )
     {
-        prv->master = first_cpu(prv->cpus);
+        prv->master = cpumask_first(prv->cpus);
         migrate_timer(&prv->master_ticker, prv->master);
     }
     kill_timer(&spc->ticker);
@@ -360,7 +360,7 @@
     /* Initialize/update system-wide config */
     prv->credit += prv->credits_per_tslice;
     prv->ncpus++;
-    cpu_set(cpu, prv->cpus);
+    cpumask_set_cpu(cpu, prv->cpus);
     if ( prv->ncpus == 1 )
     {
         prv->master = cpu;
@@ -380,7 +380,7 @@
 
     /* Start off idling... */
     BUG_ON(!is_idle_vcpu(per_cpu(schedule_data, cpu).curr));
-    cpu_set(cpu, prv->idlers);
+    cpumask_set_cpu(cpu, prv->idlers);
 
     spin_unlock_irqrestore(&prv->lock, flags);
 
@@ -488,7 +488,7 @@
      * like run two VCPUs on co-hyperthreads while there are idle cores
      * or sockets.
      */
-    cpumask_and(&idlers, &cpu_online_map, &CSCHED_PRIV(ops)->idlers);
+    cpumask_and(&idlers, &cpu_online_map, CSCHED_PRIV(ops)->idlers);
     cpumask_set_cpu(cpu, &idlers);
     cpumask_and(&cpus, &cpus, &idlers);
     cpumask_clear_cpu(cpu, &cpus);
@@ -1242,7 +1242,7 @@
      * Peek at non-idling CPUs in the system, starting with our
      * immediate neighbour.
      */
-    cpumask_andnot(&workers, online, &prv->idlers);
+    cpumask_andnot(&workers, online, prv->idlers);
     cpumask_clear_cpu(cpu, &workers);
     peer_cpu = cpu;
 
@@ -1356,12 +1356,12 @@
      */
     if ( snext->pri == CSCHED_PRI_IDLE )
     {
-        if ( !cpu_isset(cpu, prv->idlers) )
-            cpu_set(cpu, prv->idlers);
+        if ( !cpumask_test_cpu(cpu, prv->idlers) )
+            cpumask_set_cpu(cpu, prv->idlers);
     }
-    else if ( cpu_isset(cpu, prv->idlers) )
+    else if ( cpumask_test_cpu(cpu, prv->idlers) )
     {
-        cpu_clear(cpu, prv->idlers);
+        cpumask_clear_cpu(cpu, prv->idlers);
     }
 
     if ( !is_idle_vcpu(snext->vcpu) )
@@ -1481,7 +1481,7 @@
            prv->ticks_per_tslice,
            vcpu_migration_delay);
 
-    cpumask_scnprintf(idlers_buf, sizeof(idlers_buf), &prv->idlers);
+    cpumask_scnprintf(idlers_buf, sizeof(idlers_buf), prv->idlers);
     printk("idlers: %s\n", idlers_buf);
 
     printk("active vcpus:\n");
@@ -1513,6 +1513,13 @@
     prv = xzalloc(struct csched_private);
     if ( prv == NULL )
         return -ENOMEM;
+    if ( !zalloc_cpumask_var(&prv->cpus) ||
+         !zalloc_cpumask_var(&prv->idlers) )
+    {
+        free_cpumask_var(prv->cpus);
+        xfree(prv);
+        return -ENOMEM;
+    }
 
     ops->sched_data = prv;
     spin_lock_init(&prv->lock);
@@ -1536,7 +1543,11 @@
 
     prv = CSCHED_PRIV(ops);
     if ( prv != NULL )
+    {
+        free_cpumask_var(prv->cpus);
+        free_cpumask_var(prv->idlers);
         xfree(prv);
+    }
 }
 
 static void csched_tick_suspend(const struct scheduler *ops, unsigned int cpu)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.