cpupool: assigning a CPU to a pool can fail
authorDario Faggioli <dario.faggioli@citrix.com>
Thu, 7 May 2015 13:15:53 +0000 (15:15 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 7 May 2015 13:15:53 +0000 (15:15 +0200)
which means such an event must be handled at the call sites
of cpupool_assign_cpu_locked(), and the error, if occurring,
properly propagated.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
xen/common/cpupool.c

index a947c245f0f2e65cd97e641563f056e0935be003..cabaccd4be6e7d8462c36cbe9645391b4ffc20a6 100644 (file)
@@ -458,8 +458,10 @@ void cpupool_rm_domain(struct domain *d)
  * unless we are resuming from S3, in which case we put the cpu back
  * in the cpupool it was in prior to suspend.
  */
-static void cpupool_cpu_add(unsigned int cpu)
+static int cpupool_cpu_add(unsigned int cpu)
 {
+    int ret = -EINVAL;
+
     spin_lock(&cpupool_lock);
     cpumask_clear_cpu(cpu, &cpupool_locked_cpus);
     cpumask_set_cpu(cpu, &cpupool_free_cpus);
@@ -472,15 +474,20 @@ static void cpupool_cpu_add(unsigned int cpu)
         {
             if ( cpumask_test_cpu(cpu, (*c)->cpu_suspended ) )
             {
-                cpupool_assign_cpu_locked(*c, cpu);
+                ret = cpupool_assign_cpu_locked(*c, cpu);
+                if ( ret )
+                    goto out;
                 cpumask_clear_cpu(cpu, (*c)->cpu_suspended);
             }
         }
     }
 
     if ( cpumask_test_cpu(cpu, &cpupool_free_cpus) )
-        cpupool_assign_cpu_locked(cpupool0, cpu);
+        ret = cpupool_assign_cpu_locked(cpupool0, cpu);
+ out:
     spin_unlock(&cpupool_lock);
+
+    return ret;
 }
 
 /*
@@ -715,7 +722,7 @@ static int cpu_callback(
     {
     case CPU_DOWN_FAILED:
     case CPU_ONLINE:
-        cpupool_cpu_add(cpu);
+        rc = cpupool_cpu_add(cpu);
         break;
     case CPU_DOWN_PREPARE:
         rc = cpupool_cpu_remove(cpu);