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

Re: [Xen-devel] [PATCH v2 04/23] x86: Don't use potentially incorrect CPUID values for topology information


  • To: Simon Gaiser <simon@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 7 Aug 2023 10:39:45 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=2BetuNzSp2Y+3FGO/V6r0vGB3agsN6xV6iitkX9zLS0=; b=SNVjSR2hatfA1shlhFG6Qv4VcRI0ZsVJB+xJkwJE6lWseJpvNAD2WLo30ZMigxZZTvOeG0eW3rfvGPxdEnV0zrqYpIMjzZtkNXRp7z0Ho2+jTmKQyS+5jqHA/1o+GXtgTYig66rfQnWNAq3WxAQaZ7tpBjhcnqJQzpy/2OWgDGBTCP48mUCGkJOg5V/9mUSizZebtGMDH/ITxn3Q5pihUubqyHA0CFjr/x5hpHZQJ2W2uY+iJbAdVjCEoZ6/V8ssacxn492j0IOWITOUVFaPh7UZxzBkUllK2P071nMclbVow2oOq+dTo4cIFLPe20S8Ch5Q1vS14PCYATgodXSM0w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n8sX5dJS+8hSYFNu+XjJihwHzTwsxP6PX2i9vobsi+3BbWoSbY481VtvEf10SqqlNL5fG4isgzCrTyqfwn+P6wlcFiCsZyYx82Ub4oeQnmt0IBl3Q+VX0V1WR+z371oOd11zY9qjTSEzeLVFD8J+R09N8siYD3iIXFrktynBgPf02LQ8rP6OPC8OhFVxB3E+RA4LOyB4yagpgWvWRS9uWl8G1HlkGW8Xt9LnpAu+4PuRk4OfCDWQyjFvhUd7EKKFRCoDHQNHpbzOO1ppLtlhdndpbhaY+abdrDAxPjbFjydZFy7ZLVIp3LoL9EOETLaB76J4tfPn05UaUGfHrqkDtA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wei.liu2@xxxxxxxxxx>, KarimAllah Ahmed <karahmed@xxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan H. Schönherr <jschoenh@xxxxxxxxx>, Matt Wilson <msw@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Anthony Liguori <aliguori@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 07 Aug 2023 08:40:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.08.2023 10:18, Simon Gaiser wrote:
> Anthony Liguori:
>> From: Jan H. Schönherr <jschoenh@xxxxxxxxx>
>>
>> Intel says for CPUID leaf 0Bh:
>>
>>   "Software must not use EBX[15:0] to enumerate processor
>>    topology of the system. This value in this field
>>    (EBX[15:0]) is only intended for display/diagnostic
>>    purposes. The actual number of logical processors
>>    available to BIOS/OS/Applications may be different from
>>    the value of EBX[15:0], depending on software and platform
>>    hardware configurations."
>>
>> And yet, we're using them to derive the number cores in a package
>> and the number of siblings in a core.
>>
>> Derive the number of siblings and cores from EAX instead, which is
>> intended for that.
>>
>> Signed-off-by: Jan H. Schönherr <jschoenh@xxxxxxxxx>
>> ---
>>  xen/arch/x86/cpu/common.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
>> index e9588b3..22f392f 100644
>> --- a/xen/arch/x86/cpu/common.c
>> +++ b/xen/arch/x86/cpu/common.c
>> @@ -479,8 +479,8 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
>>      initial_apicid = edx;
>>  
>>      /* Populate HT related information from sub-leaf level 0 */
>> -    core_level_siblings = c->x86_num_siblings = LEVEL_MAX_SIBLINGS(ebx);
>>      core_plus_mask_width = ht_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
>> +    core_level_siblings = c->x86_num_siblings = 1 << ht_mask_width;
>>  
>>      sub_index = 1;
>>      do {
>> @@ -488,8 +488,8 @@ void detect_extended_topology(struct cpuinfo_x86 *c)
>>  
>>              /* Check for the Core type in the implemented sub leaves */
>>              if ( LEAFB_SUBTYPE(ecx) == CORE_TYPE ) {
>> -                    core_level_siblings = LEVEL_MAX_SIBLINGS(ebx);
>>                      core_plus_mask_width = BITS_SHIFT_NEXT_LEVEL(eax);
>> +                    core_level_siblings = 1 << core_plus_mask_width;
> 
> 
> On the i5-1135G7 (4 cores with each 2 threads) I'm currently testing on
> I noticed that this changes leads to core_level_siblings == 16 and
> therefore x86_max_cores == 8. If read from ebx like before this change
> and what Linux is still doing [1] it reads core_level_siblings == 8 (as
> expected?).
> 
> What's the expected semantic here? If it's to derive the actual number
> of siblings (and therefore cores) in a package as the commit message
> suggest, the new code can't work even ignoring the example from my test
> system. It will always produce powers of 2, so can't get it right on a
> system with, say, 6 cores.

The only use of the variable in question is in this statement:

        c->x86_max_cores = (core_level_siblings / c->x86_num_siblings);

Note the "max" in the name. This is how many _could_ be there, not how
many _are_ there, aiui.

Jan



 


Rackspace

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