RFR(XXS): JDK-8007069 VM_Version_x86 cores per cpu is wrong for cpuid 0xb topology case

Mikael Vidstedt mikael.vidstedt at oracle.com
Wed Jan 30 12:56:07 PST 2013


For completeness, I was looking at the instruction set reference (from 
January 2013), page 3-152 and 3-153, and specifically the double star 
("**") note for the EBX value.

http://download.intel.com/products/processor/manual/253666.pdf

Cheers,
Mikael

On 2013-01-30 11:26, Vladimir Kozlov wrote:
> You are welcome.
>
> Yes, you have to read "small print" not only on financial documents 
> but also in hw architecture manuals :(
>
> Regards,
> Vladimir
>
> On 1/30/13 11:09 AM, Markus Grönlund wrote:
>> Vladimir,
>>
>> many thanks giving me a good example, I have only had 
>> _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus = 1, so far.
>>
>> You are right, thank you for showing me this, I did not read the 
>> details on the Note2 on Core level well enough:
>>
>> "2. The number of factory-configured logical processors at this level 
>> is equal to the number of factory-configured cores * the number of 
>> factory-configured logical processors per core."
>>
>> It was my (mis)understanding that Core level did not multiply up to 
>> the SMT level(but id does as the note gives as well as your example 
>> explains).
>>
>> Many thanks Vladimir
>>
>> Cheers
>> Markus
>>
>>
>>
>> -----Original Message-----
>> From: Vladimir Kozlov
>> Sent: den 30 januari 2013 19:58
>> To: Markus Grönlund
>> Cc: Mikael Vidstedt; hotspot-dev at openjdk.java.net
>> Subject: Re: RFR(XXS): JDK-8007069 VM_Version_x86 cores per cpu is 
>> wrong for cpuid 0xb topology case
>>
>> No, the example I showed has HT and VM gives correct results:
>>
>> tpl_cpuidB0_ebx.bits.logical_cpus = 2
>> tpl_cpuidB1_ebx.bits.logical_cpus = 16
>>
>> (8 cores per cpu, 2 threads per core)
>>
>> Vladimir
>>
>> On 1/30/13 10:47 AM, Markus Grönlund wrote:
>>> Hi Vladimir,
>>>
>>> Yes I have noticed that it will give ok results (so far). For 
>>> example, on my Intel(R) Xeon(R) CPU E5-2690 0 @ 2.90GHz, 
>>> (Sandybridge-EP).
>>>
>>> I have 8 hw threads (from os::processor_count())
>>>
>>> Also, it's using CPUID 0xb (supports topology, 2xAPICID)
>>>
>>> My values are:
>>>
>>> _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus = 1 <<-- threads per
>>> core _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus = 8 <<-- cores per
>>> cpu package
>>>
>>> Current (wrong) logic does:
>>>
>>> No of cores per cpu:
>>>
>>> Returns : _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus = 8 / 
>>> _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus = 1 == no of cores == 
>>> 8 (correct).
>>>
>>> However,
>>>
>>> This does not account for CPUs that have HT enabled, i.e  if HT is 
>>> enabled, you will get this:
>>>
>>> _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus = 2 <<-- threads per
>>> core _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus = 8 <<-- cores per
>>> cpu package
>>>
>>>
>>> Returns : _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus = 8 / 
>>> _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus = 2 == no of cores is 
>>> now 4, but the real number of cores is 8.
>>>
>>> So, avoid doing the unnecessary divide operation 
>>> (no_of_cores_per_pkg) / (no_of_threads_per_core). The correct info 
>>> is already there. Just return it.
>>>
>>> Return: _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus // 8 correct
>>>
>>>
>>> Cheers
>>> Markus
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: Vladimir Kozlov
>>> Sent: den 30 januari 2013 19:33
>>> To: Markus Grönlund
>>> Cc: Mikael Vidstedt; hotspot-dev at openjdk.java.net
>>> Subject: Re: RFR(XXS): JDK-8007069 VM_Version_x86 cores per cpu is
>>> wrong for cpuid 0xb topology case
>>>
>>> Markus,
>>>
>>> Current code is correct. In what case it is not correct?
>>>
>>> bash-4.1$ psrinfo -pv
>>> The physical processor has 8 cores and 16 virtual processors (0-7 
>>> 16-23)
>>>      The core has 2 virtual processors (0 16)
>>>      The core has 2 virtual processors (1 17)
>>>      The core has 2 virtual processors (2 18)
>>>      The core has 2 virtual processors (3 19)
>>>      The core has 2 virtual processors (4 20)
>>>      The core has 2 virtual processors (5 21)
>>>      The core has 2 virtual processors (6 22)
>>>      The core has 2 virtual processors (7 23)
>>>        x86 (GenuineIntel 206D6 family 6 model 45 step 6 clock 2693 MHz)
>>>          Intel(r) Xeon(r) CPU E5-2680 0 @ 2.70GHz
>>>
>>> ash-4.1$ java -XX:+PrintMiscellaneous -XX:+Verbose -version [SafePoint
>>> Polling address: 0xfffffd7fff1e0000] [Memory Serialize  Page address:
>>> 0xfffffd7fff1d0000] Logical CPUs per core: 2
>>> UseSSE=4  UseAVX=1  UseAES=1
>>> Allocation prefetching: PREFETCHNTA at distance 192, 4 lines of 64
>>> bytes PrefetchCopyIntervalInBytes 576 PrefetchScanIntervalInBytes 576
>>> PrefetchFieldsAhead 1 ContendedPaddingWidth 128 CPU:total 32 (8 cores
>>> per cpu, 2 threads per core) family 6 model 45 stepping 6, cmov, cx8,
>>> fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, aes,
>>> ht, tsc, tscinvbit, tscinv
>>>
>>> Thanks,
>>> Vladimir
>>>
>>>
>>> On 1/30/13 9:45 AM, Markus Grönlund wrote:
>>>> Hi Mikael,
>>>>
>>>> I wonder if you are looking at the right section in the manual (and 
>>>> which manual?) here?
>>>>
>>>> I am using information in Intel Application note 485:
>>>>
>>>> http://www.intel.com/content/www/us/en/processors/processor-identific
>>>> a
>>>> tion-cpuid-instruction-note.html
>>>>
>>>> Section 5.1.12 page 41 describes CPUID 0xb. Essentially, together 
>>>> with EAX=0xb, you pass in subleafs (0, 1, 2...) in ECX for the 
>>>> different levels in the cpu topology you are interested in. Results 
>>>> are given in EBX[15:0] [31:16] == reserved.
>>>>
>>>>
>>>> "There's also a cores_per_cpu in CPUID 04h EAX[31:26] (aka. 
>>>> dcp_cpuid4_eax.bits.cores_per_cpu), do you happen to know what the 
>>>> difference is? Is that maybe a better candidate for this?"
>>>>
>>>> CPUID04 EAX[31:26] is giving you the number of cores [per cpu 
>>>> package] using the legacy "initial APICID (8-bits)" systems. This 
>>>> combined with CPUID 01[logical threads per cpu package] is the 
>>>> legacy way of cpu identification. It is cannot give you as much 
>>>> info as topology however.
>>>>
>>>> Processors supporting CPUID 0xb is using 3-level 2xAPICID (32-bit) 
>>>> for identification (SMT, Core, Pkg), and does not use "initial 
>>>> APICID".
>>>>
>>>> So:
>>>>
>>>> EAX=0xb, ECX=0 == EBX[15:0] == no_of_logical_threads_per_core ==
>>>> (stored in _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus)
>>>> EAX=0xb, ECX=1 == EBX[15:0] == no_of_cores_per_pkg == (stored in
>>>> _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus)
>>>> ...
>>>>
>>>> Hope this clarifies
>>>>
>>>> Cheers
>>>> Markus
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Mikael Vidstedt
>>>> Sent: den 30 januari 2013 17:30
>>>> To: Markus Grönlund
>>>> Cc: hotspot-dev at openjdk.java.net
>>>> Subject: Re: RFR(XXS): JDK-8007069 VM_Version_x86 cores per cpu is
>>>> wrong for cpuid 0xb topology case
>>>>
>>>>
>>>> Looking at the Intel manual for CPUID 0Bh it basically says that 
>>>> one should not use the value in EBX[15:0] for anything other than 
>>>> "...display/diagnostic purposes". There's also a cores_per_cpu in 
>>>> CPUID 04h EAX[31:26] (aka. dcp_cpuid4_eax.bits.cores_per_cpu), do 
>>>> you happen to know what the difference is? Is that maybe a better 
>>>> candidate for this?
>>>>
>>>> Cheers,
>>>> Mikael
>>>>
>>>> On 1/29/2013 2:10 AM, Markus Grönlund wrote:
>>>>> Hi again,
>>>>>
>>>>> Apologies for posting the wrong webrev link, this is the one I 
>>>>> wanted to submit:
>>>>>
>>>>> Bug: https://jbs.oracle.com/bugs/browse/JDK-8007069
>>>>> Webrev: http://cr.openjdk.java.net/~mgronlun/8007069/webrev01/
>>>>>
>>>>>
>>>>> Thanks Mikael for the heads up
>>>>>
>>>>> Cheers
>>>>> Markus
>>>>>
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: Mikael Gerdin
>>>>> Sent: den 29 januari 2013 10:59
>>>>> To: Markus Grönlund
>>>>> Cc: hotspot-dev at openjdk.java.net
>>>>> Subject: Re: RFR(XXS): JDK-8007069 VM_Version_x86 cores per cpu is
>>>>> wrong for cpuid 0xb topology case
>>>>>
>>>>> Markus,
>>>>>
>>>>> On 2013-01-29 10:54, Markus Grönlund wrote:
>>>>>> Hi all,
>>>>>>
>>>>>>
>>>>>>
>>>>>> Kindly asking for review for the following very simple change in 
>>>>>> the logic for number of cores for CPUID 0xb topology.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Bug: https://jbs.oracle.com/bugs/browse/JDK-8007069
>>>>>>
>>>>>> Webrev:
>>>>>> http://wikifiles.se.oracle.com/dev/mgronlun/webrevs/8007069/webrev0
>>>>>> 1
>>>>>> /
>>>>> This URL is not available from outside Oracle.
>>>>>
>>>>> /Mikael
>>>>>
>>>>>>
>>>>>>
>>>>>> Also need someone to sponsor this putback.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thanks in advance
>>>>>>
>>>>>> Markus
>>>>>>
>>>>



More information about the hotspot-dev mailing list