[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 02/11] x86/vPMU: avoid effectively open-coding xzalloc_flex_struct()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 8 Apr 2021 13:25:51 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gu2WN9nGdMp7kCNhADIYEuQCY6LUzH07WnhwEhOWnBk=; b=iHFFMxaZPqEEWEEBkYA0evQs0GwB/ykdPMq+OPwObVgx8FFDJC1ksvXN3343g+1xUGB5fxtWiFaLyQnNK7hWP4l5OC7SX7I/8mTLP7vjIiCbFDgCPdqXZ+D2e2sWKTRit6fuvPkt9Y6Bt7OWM9sZxuz5RjD1FsiHJ2fuu+i7K9G68E4hHD6w/AcHrEUfZAD5gmKvDcobY5XOOK6I3dollousL1dX0ENdIXQ+sno2PjnBB+xdEZv2V6zaRm4zHSZ4qUn71HhNxwgJrzRo3ahDmqRz/08cAv/nSAhQLnox/Ts6UgyqYgQrNC1j29o0Zkm5PA9EwUYzpwqQpcopEjPpxA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E+IIhNh3SX+j+RDQ6KxLHzGDHCIpAoG0N+FfGA6xGr8ZUV02C783xJO4bUN4B1OajUpKAorLnKCCi5TcN/JauEH0UuybVTH1w+eyvpDngu0syEfuo6KRavg3pXfSpl4Y7RMBVw4aGvU4dWL4tpHfEZfxQ7tpb9sZttuLOBdUhXoiQE03gXuwPiPvS9425O3ejFmq4uxDT936ROWOz6jkwxBok34qY9BoGKGyctE36GGCw8k7BJ+y8dFToh7urzBSaIl0IbjEspk/Lvebk+EnWMSIE7zWkE04cgQ5sFGpuMF8glKkss2o3fu4LJQm/luMI2o2TiQgmZjOg1A8aBAFDQ==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Delivery-date: Thu, 08 Apr 2021 12:26:05 +0000
  • Ironport-hdrordr: A9a23:7EPNoat5xizjPoKI0rqk01/n7skC2YYji2hD6mlwRA09T+WxrO rrtOgH1BPylTYaUGwhn9fFA6WbXXbA7/dOj7U5FYyJGC3ronGhIo0n14vtxDX8Bzbzn9Qz6Y 5JSII7MtH5CDFB4frSyBWkEtom3dmM+L2pg+Cb9Ht2UQR2cchbjztRICzzKDwQeCBtA50lGJ 2Aou9OoDS9cXoaB/7LeEUtde7FutHNidbaehYAHREq802jijmv5b78HXGjr2gjehlIxqov9n WArhzh6syYwo2G4zL/90uW1ZRZn9P91sBObfbstuE5Iijh4zzYH7hJdKaFuFkO0ZiSwXYs1O LBuhIxe/l0gkmhA12dhTvI903e3C0163nkoGXo80fLhcDiXjo1B45gqOtiA2PkwnEttt19z6 5Htljx3/E8YGKi7UaNk+TgbB1kmlG5pnAvi4co/hpieLATdaNLqsgn9F5Vea1wbx7S0pwtE+ VlEajnlZNrWG6dBkqp2lVH/MahRTAaEBuAXyE5y7ao+gkTtnV4w0wE/dcYj3cN+bksIqM0l9 jsA+BGkqpDQdQRar84LOAdQdGvAmiIeh7UNnmOSG6XWp0vCjbokdra8b817OaldNghy4Yzoo 3IVBd9uXQpc0zjJMWS1PRwg1HwaVT4eQ6o5tBV5pB/tLG5bqHsKze/RFcnlNbli+kD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TdNPtG+NKl8VcH7ZeQULK2uR3/chCe80RVpS30rHIWhTcFShNW6qKMX6D tTKpeRv0NTSomeJby86CPpywQrL2FAxvnyV3dsnmfttIomx5L4ONSsnKDHf2/44cemM+6wHzkR XUP3hrzR3eX+o9U7LqH+JQ25Fz/pYym0o4DgkOeEU56e/2RFvGh6g9K0zXnwvcn7f0Wc2uRM41 Hs5acvQJZhufTR/FFyYM1MxMGAnaR1abhIjg+/cSv34hIXGWS63uXlec3mKIpPIlweWWf8kSY+ B30=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 08/04/2021 13:17, Jan Beulich wrote:
> 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@xxxxxxxx>

Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

>
> --- a/xen/arch/x86/cpu/vpmu_intel.c
> +++ b/xen/arch/x86/cpu/vpmu_intel.c
> @@ -461,10 +461,10 @@ static int core2_vpmu_alloc_resource(str
>              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);

However, this is very wtf, and clearly wants reworking.  I'll see if I
can find some time, unless anyone else beats me to it.

~Andrew

>      if ( !core2_vpmu_cxt || !p )
>          goto out_err;
>




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.