From: "Jan Beulich" Subject: Re: [PATCH for 4.5] x86/VPMU: Clear last_vcpu when destroying VPMU Date: Mon, 15 Dec 2014 10:07:46 +0000 Message-ID: <548EC102020000780004F810@mail.emea.novell.com> References: <1418419248-2863-1-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1418419248-2863-1-git-send-email-boris.ostrovsky@oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Boris Ostrovsky Cc: keir@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 12.12.14 at 22:20, wrote: > --- a/xen/arch/x86/hvm/vpmu.c > +++ b/xen/arch/x86/hvm/vpmu.c > @@ -247,10 +247,32 @@ void vpmu_initialise(struct vcpu *v) > } > } > > +static void vpmu_clear_last(void *arg) > +{ > + struct vcpu *v = (struct vcpu *)arg; Please drop this pointless cast, or perhaps the entire variable, as ... > + > + if ( this_cpu(last_vcpu) == v ) ... you don't really need it to be of "struct vcpu *" type - "void *" is quite fine for a comparison. > + this_cpu(last_vcpu) = NULL; > +} > + > void vpmu_destroy(struct vcpu *v) > { > struct vpmu_struct *vpmu = vcpu_vpmu(v); > > + if ( vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) ) > + { > + /* Need to clear last_vcpu in case it points to v */ > + if ( vpmu->last_pcpu != smp_processor_id() ) > + on_selected_cpus(cpumask_of(vpmu->last_pcpu), > + vpmu_clear_last, (void *)v, 1); The cast here is pointless too. But considering your subsequent reply this code may go away altogether anyway; if it doesn't, explaining (in the commit message) why you need to use an IPI here would seem necessary. > + else > + { > + local_irq_disable(); > + vpmu_clear_last((void *)v); And another pointless cast. Jan