cpupool: fix removing cpu from a cpupool
authorJuergen Gross <jgross@suse.com>
Fri, 8 May 2020 08:44:22 +0000 (10:44 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 8 May 2020 08:44:22 +0000 (10:44 +0200)
Commit cb563d7665f2 ("xen/sched: support core scheduling for moving
cpus to/from cpupools") introduced a regression when trying to remove
an offline cpu from a cpupool, as the system would crash in this
situation.

Fix that by testing the cpu to be online.

Fixes: cb563d7665f2 ("xen/sched: support core scheduling for moving cpus to/from cpupools")
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Dario Faggioli <dfaggioli@suse.com>
xen/common/sched/cpupool.c

index 97c2d5b3c13eada36a8f20557069dc24b20b3855..0664f7fa3d130886027dc3365ada9d1b692370d5 100644 (file)
@@ -552,6 +552,9 @@ static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu)
     debugtrace_printk("cpupool_unassign_cpu(pool=%d,cpu=%d)\n",
                       c->cpupool_id, cpu);
 
+    if ( !cpu_online(cpu) )
+        return -EINVAL;
+
     master_cpu = sched_get_resource_cpu(cpu);
     ret = cpupool_unassign_cpu_start(c, master_cpu);
     if ( ret )