]> xenbits.xensource.com Git - xen.git/commitdiff
x86/vPMU: avoid effectively open-coding xzalloc_flex_struct()
authorJan Beulich <jbeulich@suse.com>
Fri, 9 Apr 2021 07:25:17 +0000 (09:25 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 9 Apr 2021 07:25:17 +0000 (09:25 +0200)
There is a difference in generated code: xzalloc_bytes() forces
SMP_CACHE_BYTES alignment. I think we not only don't need this here, but
actually don't want it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/cpu/vpmu_intel.c

index 6e97ce790037a1170121b3ac919ae9d582bfd24a..64334c5fabcba25e034b038482bce637222db189 100644 (file)
@@ -461,10 +461,10 @@ static int core2_vpmu_alloc_resource(struct vcpu *v)
             goto out_err;
     }
 
-    core2_vpmu_cxt = xzalloc_bytes(sizeof(*core2_vpmu_cxt) +
-                                   sizeof(uint64_t) * fixed_pmc_cnt +
-                                   sizeof(struct xen_pmu_cntr_pair) *
-                                   arch_pmc_cnt);
+    core2_vpmu_cxt = xzalloc_flex_struct(struct xen_pmu_intel_ctxt, regs,
+                                         fixed_pmc_cnt + arch_pmc_cnt *
+                                         (sizeof(struct xen_pmu_cntr_pair) /
+                                          sizeof(*core2_vpmu_cxt->regs)));
     p = xzalloc(uint64_t);
     if ( !core2_vpmu_cxt || !p )
         goto out_err;