[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 07/12] libs/guest: introduce helper set cpu topology in cpu policy
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Tue, 11 Jan 2022 12:54:48 +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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CZ0Cbvz926NTgRTrvdLHHHZ+5J7ACoMO4n/b9B0ZPp4=; b=dDW40jvJpnJOxaBo9wmnS3GOtBRM9k0WpAmwSBRlPQa/DfG1YFfbvz07CwhxFS+t+qxfUTEi95ffrUMS2uD2cOT/Ri0piRGdIZ8cda4cJ5PpAa8cTpGW9ltSpO9f9DV+XCZWfbti37aYZn3ltWPg9RrpkoScRRPw1ahVI5/6KoDI3UJ1w7F3g5YtXC3EeGbflTSrTcm5BMxIV54ctmIXQ6BYstMp51Wby7s45J1I6z+hQN+o8zQgK72LzGwWEyjQDyG2wrA79wEl08gHnUVQmItnpDDVH6YdNf3qDeFFH0ehI0eprc032Y9y7MVBxBP2aapwRcZfLNquwy272Rykew==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N+sEabg0ie+/ehbdkUp2MkQEieZOPoSL7qiGJjajctkwx8PwgfCg99F+gNYcvcmu0z8xM9TCNXNVM8uYeorOiygK7sisy5gARawrWY+D29+UrCqHAqRWx8WKRJigMpzssP8B1STjYXaV69M3xWUOxYn1rOuJLztTedLKvz8Y5W27KJvsG6QNzX0DTpxAvH1sIVLhJu0ryADnTfueBCT4TBGAica60ZT4RCj0CaI4wrsFKUCHyVvR6DhXWw7VZwDm+kEVad8Hs8Gf0pYDf61Z91PvUVH5DQ0keDvr8QPcbKFFVMWMpteGWgIY9amkBw1+iBFOlmhxQv3hgDLXvArLZQ==
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Tue, 11 Jan 2022 11:55:08 +0000
- Ironport-data: A9a23:zKXm36lDaMt48MBjlwvA8pPo5gwMIURdPkR7XQ2eYbSJt1+Wr1Gzt xJNXzqAP//bZjfxKNt2bo2z/UgCucPXzNdjSwFu/i9nFyMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA180IMsdoUg7wbRh29cx2YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 Phm5aKhSzUkArPjhuoBaCYbTihMGpQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBNPsM44F/Glp0BnSDOo8QICFSKLPjTNd9Glp2J0XR66FD yYfQQdCMi2QbEMXAV5UOLNisNqFh3jVcgQN/Tp5ooJoujOOnWSdyoPFMtXPfceRbd5IhUver WXDl0zpDxdfONGBxD6t9nO3mvSJjS79QJgVFrCz6rhtmlL77nMXIA0bUx28u/bRoky0Vs9bK kcU0jEztqV0/0uuJvH8QB+QsHOCpgQbWddbD6s98g7l90bPy1/HXC5eFGcHMYF48p9tLdA36 rOXt/7CVQJ+so+YdWyy6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AtRD4b7LfClHZKTBkXGF+r8bqbHtms3Y5pa9854ud3AQV0gJ1XYGNu/xKDwOeOApP+tfKH LKjfA32AZINE5nJfiTNz0gZazuttfLnJXpbVovAAMm0hCHiXeN5KThGxaV8x8CW3cXqI1SvF Ttokjc3OGOovu7whjT2yv66IlXosLozp9mCNaXgsYYBz3wgkKDZZhnWZeFoDcpydvfomoCoZ 3pmVMNLs5z43TeciWcpgbs4RDp1HIU53rr2Taj8A3eiP28YAh/J9tKhIpffBecwVEnpstA3K VC2H/cn4ZLDDvb9R6NqeTgZlVPrA6ZsHAimekcgzh0So0FcoJcqoQZ4Qd8DIoAJiTn84oqed MeQ/003MwmMW9yUkqp/VWGmLeXLzYO91a9MwQ/U/WuonlrdCsT9Tpc+CQd9k1wg67VBaM0o9 gsCZ4Y542mePVmGZ6VNN1xMfdfNVa9My4kEFjiaGgPR5t3c04klfbMkcAIDaeRCds18Kc=
- Ironport-sdr: 5etvdTkrEgQG4yk4DFN8gvPJy08tiNvAEDMfEsLnIoZJe+f3W8Pla3QCqqlzD8IDzcKUgKGofz 0xSxBEQA9XiPPA9wa5H1BajBE9XzxQU2rmPieD4x3B2Dznjw94MJqPkOUW9zolfeXcJMPC8rz0 0Ri6srSdWWwVB7bedxEljbsAH+hjX3lbw8K8uobaZk+OzxuI06W5GOHVo7ECmnLdEcJHNed6th QXaCIFmJtRscdOztIbMru5WAmPI0fMHjU8TEn/nvUIkpHtOXLRrwrgE56ZlaovVbgLdKf0jxn/ F+Lse3XHFw9YMvnYEJi2omii
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Mon, Dec 06, 2021 at 05:09:42PM +0100, Jan Beulich wrote:
> On 29.11.2021 16:33, Roger Pau Monne wrote:
> > @@ -458,22 +456,6 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t
> > domid, bool restore,
> > (p = calloc(1, sizeof(*p))) == NULL )
> > goto out;
> >
> > - /* Get the host policy. */
> > - rc = xc_get_cpu_featureset(xch, XEN_SYSCTL_cpu_featureset_host,
> > - &len, host_featureset);
>
> You go from retrieving the host featureset to ...
>
> > @@ -944,3 +865,98 @@ int xc_cpu_policy_make_compat_4_12(xc_interface *xch,
> > xc_cpu_policy_t *policy,
> > xc_cpu_policy_destroy(host);
> > return rc;
> > }
> > +
> > +int xc_cpu_policy_legacy_topology(xc_interface *xch, xc_cpu_policy_t
> > *policy,
> > + bool hvm)
> > +{
> > + if ( !hvm )
> > + {
> > + xc_cpu_policy_t *host;
> > + int rc;
> > +
> > + host = xc_cpu_policy_init();
> > + if ( !host )
> > + {
> > + errno = ENOMEM;
> > + return -1;
> > + }
> > +
> > + rc = xc_cpu_policy_get_system(xch, XEN_SYSCTL_cpu_policy_host,
> > host);
>
> ... retrieving the host policy, which afaict is a larger blob of data.
> Is there a particular reason for doing so?
I did that so I could assign from one CPUID policy to another, but
will revert back to using a featureset since it's indeed smaller.
> > + if ( rc )
> > + {
> > + ERROR("Failed to get host policy");
> > + xc_cpu_policy_destroy(host);
> > + return rc;
> > + }
> > +
> > +
> > + /*
> > + * On hardware without CPUID Faulting, PV guests see real topology.
> > + * As a consequence, they also need to see the host htt/cmp fields.
> > + */
> > + policy->cpuid.basic.htt = host->cpuid.basic.htt;
> > + policy->cpuid.extd.cmp_legacy = host->cpuid.extd.cmp_legacy;
> > + }
> > + else
> > + {
> > + unsigned int i;
> > +
> > + /*
> > + * Topology for HVM guests is entirely controlled by Xen. For
> > now, we
> > + * hardcode APIC_ID = vcpu_id * 2 to give the illusion of no SMT.
> > + */
> > + policy->cpuid.basic.htt = true;
> > + policy->cpuid.extd.cmp_legacy = false;
> > +
> > + /*
> > + * Leaf 1 EBX[23:16] is Maximum Logical Processors Per Package.
> > + * Update to reflect vLAPIC_ID = vCPU_ID * 2, but make sure to
> > avoid
> > + * overflow.
> > + */
> > + if ( !policy->cpuid.basic.lppp )
> > + policy->cpuid.basic.lppp = 2;
> > + else if ( !(policy->cpuid.basic.lppp & 0x80) )
> > + policy->cpuid.basic.lppp *= 2;
> > +
> > + switch ( policy->cpuid.x86_vendor )
> > + {
> > + case X86_VENDOR_INTEL:
> > + for ( i = 0; (policy->cpuid.cache.subleaf[i].type &&
> > + i < ARRAY_SIZE(policy->cpuid.cache.raw)); ++i )
> > + {
> > + policy->cpuid.cache.subleaf[i].cores_per_package =
> > + (policy->cpuid.cache.subleaf[i].cores_per_package << 1)
> > | 1;
> > + policy->cpuid.cache.subleaf[i].threads_per_cache = 0;
> > + }
> > + break;
> > +
> > + case X86_VENDOR_AMD:
> > + case X86_VENDOR_HYGON:
> > + /*
> > + * Leaf 0x80000008 ECX[15:12] is ApicIdCoreSize.
> > + * Leaf 0x80000008 ECX[7:0] is NumberOfCores (minus one).
> > + * Update to reflect vLAPIC_ID = vCPU_ID * 2. But avoid
> > + * - overflow,
> > + * - going out of sync with leaf 1 EBX[23:16],
> > + * - incrementing ApicIdCoreSize when it's zero (which changes
> > the
> > + * meaning of bits 7:0).
> > + *
> > + * UPDATE: I addition to avoiding overflow, some
>
> Nit: Would you mind switching "I" to "In" at this occasion?
Will do.
Thanks, Roger.
|