From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juergen Gross Subject: Re: [PATCH 2/3] xen: cpupool: assigning a CPU to a pool can fail Date: Thu, 07 May 2015 06:52:14 +0200 Message-ID: <554AEF7E.6060302@suse.com> References: <20150506143312.9537.1503.stgit@Solace.station> <20150506151033.9537.62100.stgit@Solace.station> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150506151033.9537.62100.stgit@Solace.station> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Dario Faggioli , xen-devel@lists.xen.org Cc: George Dunlap , Andrew Cooper , Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org On 05/06/2015 05:10 PM, Dario Faggioli wrote: > 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 > Cc: Juergen Gross > Cc: George Dunlap > Cc: Jan Beulich > Cc: Andrew Cooper > Cc: Keir Fraser Reviewed-by: Juergen Gross > --- > xen/common/cpupool.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c > index a947c24..cabaccd 100644 > --- a/xen/common/cpupool.c > +++ b/xen/common/cpupool.c > @@ -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); > >