From 3c83d63d987ece03545210ac23ff7a723e4f0243 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 6 May 2010 11:14:17 +0100 Subject: [PATCH] cpupools: Fix cpupool sysctl locking. Signed-off-by: Juergen Gross --- xen/common/cpupool.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index 6cb99773ba..c1af188bc3 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -37,6 +37,7 @@ static cpumask_t cpupool_locked_cpus = CPU_MASK_NONE; * as it was obtained! */ static DEFINE_SPINLOCK(cpupool_lock); +static DEFINE_SPINLOCK(cpupool_ctl_lock); DEFINE_PER_CPU(struct cpupool *, cpupool); @@ -401,6 +402,8 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) int ret; struct cpupool *c; + spin_lock(&cpupool_ctl_lock); + switch ( op->op ) { @@ -426,9 +429,7 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) case XEN_SYSCTL_CPUPOOL_OP_DESTROY: { - spin_lock(&cpupool_lock); c = cpupool_find_by_id(op->cpupool_id, 1); - spin_unlock(&cpupool_lock); ret = -ENOENT; if ( c == NULL ) break; @@ -438,9 +439,7 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) case XEN_SYSCTL_CPUPOOL_OP_INFO: { - spin_lock(&cpupool_lock); c = cpupool_find_by_id(op->cpupool_id, 0); - spin_unlock(&cpupool_lock); ret = -ENOENT; if ( c == NULL ) break; @@ -484,9 +483,7 @@ addcpu_out: { unsigned cpu; - spin_lock(&cpupool_lock); c = cpupool_find_by_id(op->cpupool_id, 0); - spin_unlock(&cpupool_lock); ret = -ENOENT; if ( c == NULL ) break; @@ -560,6 +557,8 @@ addcpu_out: } + spin_unlock(&cpupool_ctl_lock); + return ret; } -- 2.39.5