From: "Jan Beulich" Subject: Re: [PATCH v9 09/20] x86/VPMU: Add public xenpmu.h Date: Mon, 18 Aug 2014 21:23:28 +0100 Message-ID: <53F26ED002000078000BAB7F@mail.emea.novell.com> References: <1407516946-17833-1-git-send-email-boris.ostrovsky@oracle.com> <1407516946-17833-10-git-send-email-boris.ostrovsky@oracle.com> <53E8EA9A020000780002B35C@mail.emea.novell.com> <53E8EC0D.8080800@oracle.com> <53F223A0.7000906@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53F223A0.7000906@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@oracle.com Cc: kevin.tian@intel.com, keir@xen.org, suravee.suthikulpanit@amd.com, andrew.cooper3@citrix.com, tim@xen.org, xen-devel@lists.xen.org, jun.nakajima@intel.com List-Id: xen-devel@lists.xenproject.org >>> Boris Ostrovsky 08/18/14 6:02 PM >>> >On 08/11/2014 12:15 PM, Boris Ostrovsky wrote: >> On 08/11/2014 10:08 AM, Jan Beulich wrote: >>>> + ctxt = xzalloc_bytes(sizeof(struct xen_pmu_amd_ctxt) + >>>> + 2 * sizeof(uint64_t) * AMD_MAX_COUNTERS); >>> So I guess this is one of said sizeof()-s, and I continue to think this >>> would benefit from using a proper field. It is my understanding that >>> the real (non-C89 compliant) declaration of struct xen_pmu_amd_ctxt >>> would be >>> >>> struct xen_pmu_amd_ctxt { >>> /* Offsets to counter and control MSRs (relative to >>> xen_arch_pmu.c.amd) */ >>> uint32_t counters; >>> uint32_t ctrls; >>> uint64_t values[]; >>> }; >> >> OK, this should work. > >Actually, no, it won't: we decided early on that register banks should >be outside the fixed portion of the structure. Keeping values[] inside >xen_pmu_amd_ctxt doesn't necessarily preclude this *if* it is never >referred to by code and is only used for determining the type. But that >would be an unreasonable requirement IMO. > >I understand the dislike to sizeof(uint64_t). OTOH, your original >concern was that we may forget to update size calculation if value >changes type sometime later. But the type cannot be anything but >uint64_t since it is used in rd/wrmsr(). I see; stay with the explicit sizeof(uint64_t) here then, but please try to use sizeof(variable-or-field) elsewhere when possible. Jan