From: "Jan Beulich" Subject: Re: [PATCH v16 13/23] x86/VPMU: Interface for setting PMU mode and flags Date: Thu, 18 Dec 2014 14:45:11 +0000 Message-ID: <5492F6870200007800050B2F@mail.emea.novell.com> References: <1418830734-1558-1-git-send-email-boris.ostrovsky@oracle.com> <1418830734-1558-14-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: <1418830734-1558-14-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: kevin.tian@intel.com, suravee.suthikulpanit@amd.com, andrew.cooper3@citrix.com, tim@xen.org, dietmar.hahn@ts.fujitsu.com, xen-devel@lists.xen.org, Aravind.Gopalakrishnan@amd.com, jun.nakajima@intel.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org >>> On 17.12.14 at 16:38, wrote: > Acked-by: Kevin Tian > Reviewed-by: Konrad Rzeszutek Wilk > Reviewed-by: Dietmar Hahn > Tested-by: Dietmar Hahn I don't see these being valid anymore, and I think this isn't the first time I'm pointing out that you should drop such tags when making more than really benign changes. > @@ -277,3 +289,163 @@ void vpmu_dump(struct vcpu *v) > vpmu->arch_vpmu_ops->arch_vpmu_dump(v); > } > > +void vpmu_unload(struct vpmu_struct *vpmu) > +{ > + if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_LOADED | VPMU_RUNNING) ) > + return; > + > + if (vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->arch_vpmu_unload) > + vpmu->arch_vpmu_ops->arch_vpmu_unload(vpmu); > + > + vpmu_reset(vpmu, VPMU_RUNNING | VPMU_RUNNING); ??? > +static long vpmu_unload_next(void *arg) > +{ > + struct vcpu *last; > + > + local_irq_disable(); /* so that last_vcpu doesn't change under us. */ > + > + last = this_cpu(last_vcpu); > + if ( last ) > + { > + vpmu_unload(vcpu_vpmu(last)); > + this_cpu(last_vcpu) = NULL; > + } > + > + local_irq_enable(); > + > + cpumask_and(&vpmu_cpumask_unload, &vpmu_cpumask_unload, &cpu_online_map); > + if ( cpumask_weight(&vpmu_cpumask_unload) > 1 ) > + { > + int ret; > + int cpu = cpumask_cycle(smp_processor_id(), &vpmu_cpumask_unload); CPU numbers are unsigned. > +static int vpmu_unload_all(unsigned long old_mode) > +{ > + int ret = 0; > + > + vpmu_unload(vcpu_vpmu(current)); > + > + if ( nr_cpu_ids > 1 ) > + { > + unsigned int cpu; > + > + cpumask_or(&vpmu_cpumask_unload, &vpmu_cpumask_unload, &cpu_online_map); Why do you want to re-use old state here? I.e. don't you mean cpumask_copy()? I don't see why you need a static mask anyway - just store the CPU number you started only in a static, and cycle through cpu_online_map until you reach it again. > + cpu = cpumask_cycle(smp_processor_id(), &vpmu_cpumask_unload); Nothing guarantees cpu < nr_cpus_ids here, as nr_cpu_ids > 1 doesn't mean there's more than one CPU online. Jan