From: "Jan Beulich" Subject: Re: [PATCH v12 for-xen-4.5 12/20] x86/VPMU: Initialize PMU for PV(H) guests Date: Mon, 29 Sep 2014 17:10:10 +0100 Message-ID: <5429A082020000780003AB5D@mail.emea.novell.com> References: <1411673336-32736-1-git-send-email-boris.ostrovsky@oracle.com> <1411673336-32736-13-git-send-email-boris.ostrovsky@oracle.com> <54299627020000780003AA60@mail.emea.novell.com> <54297DA3.30200@oracle.com> <54299A1B020000780003AAB5@mail.emea.novell.com> <54298310.5050603@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <54298310.5050603@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, keir@xen.org, 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 29.09.14 at 18:04, wrote: > On 09/29/2014 11:42 AM, Jan Beulich wrote: >>>>> On 29.09.14 at 17:41, wrote: >>> On 09/29/2014 11:25 AM, Jan Beulich wrote: >>>>>>> On 25.09.14 at 21:28, wrote: >>>>> @@ -389,14 +390,26 @@ static int amd_vpmu_initialise(struct vcpu *v) >>>>> } >>>>> } >>>>> >>>>> - ctxt = xzalloc_bytes(sizeof(struct xen_pmu_amd_ctxt) + >>>>> - 2 * sizeof(uint64_t) * AMD_MAX_COUNTERS); >>>>> - if ( !ctxt ) >>>>> + regs_size = 2 * sizeof(uint64_t) * AMD_MAX_COUNTERS; >>>>> + if ( is_hvm_domain(v->domain) ) >>>>> { >>>>> - gdprintk(XENLOG_WARNING, "Insufficient memory for PMU, " >>>>> - " PMU feature is unavailable on domain %d vcpu %d.\n", >>>>> - v->vcpu_id, v->domain->domain_id); >>>>> - return -ENOMEM; >>>>> + ctxt = xzalloc_bytes(sizeof(struct xen_pmu_amd_ctxt) + regs_size); >>>>> + if ( !ctxt ) >>>>> + { >>>>> + gdprintk(XENLOG_WARNING, "Insufficient memory for PMU, " >>>>> + "PMU feature is unavailable\n"); >>>>> + return -ENOMEM; >>>>> + } >>>>> + } >>>>> + else >>>>> + { >>>>> + if ( sizeof(struct xen_pmu_data) + regs_size > PAGE_SIZE ) >>>> This is a compile time constant condition - no reason to issue a >>>> message and return failure at runtime, just BUILD_BUG_ON() instead. >>> It will not be if I replace AMD_MAX_COUNTERS with runtime register >>> count, as you asked in an earlier comment. >> For which case see the respective VMX side comment. > > Not sure I understand what you mean here. it will be almost exactly the > same. I said on the respective VMX code that issuing the message repeatedly at normal runtime is pointless - it suffices to issue it once during boot. Jan