RFR: 8366847: JFR reports incorrect number of cores on hybrid CPU [v3]
Yasumasa Suenaga
ysuenaga at openjdk.org
Tue Oct 7 02:34:54 UTC 2025
On Tue, 7 Oct 2025 01:06:31 GMT, David Holmes <dholmes at openjdk.org> wrote:
>>> Okay but this is not a JFR specific change - you are changing these values for all clients of the VM version info.
>>
>> Yes, so I think this PR needs reviewer(s) from HotSpot folks.
>>
>>> So the current code would do:
>>
>> Unfortunately, no. It would derive wrong number of sockets as following:
>>
>>
>> _no_of_threads = 28 // 2 sockets * (6 P-cores * 2 threads + 2 E-cores)
>> threads_per_core() = 2 // HT enabled
>> cores_per_cpu() = 7 // ** different from your thought ** 14 threads per cpu / 2 logical processors
>> threads_per_package = 14 // 2 threads per core * 7 cores per cpu
>> _no_of_sockets = 2 // 28 threads / 14 threads per package
>>
>>
>> `cores_per_cpu()` would return `CPUID` leaf 0Bh for modern Intel CPU as following. According to Software Developer's Manual, leaf 0Bh returns number of "logical" processor in each domains (selected by subleaf (ECX)).
>>
>>
>> if (is_intel()) {
>> bool supports_topology = supports_processor_topology();
>> if (supports_topology) {
>> result = _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus /
>> _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus;
>> }
>>
>>
>> In this PR, all of variables are same with current implementation, thus we can calculate `_no_of_sockets` correctly. But only `threads_per_package` comes from `CPUID`.
>>
>>
>> _no_of_threads = 28 // 2 sockets * (6 P-cores * 2 threads + 2 E-cores)
>> threads_per_core() = 2 // HT enabled
>> cores_per_cpu() = 7 // incorrect, but it would be calculated by values from `CPUID`
>> threads_per_package = 14 // ** different from current implementation ** the value from `CPUID`
>> _no_of_sockets = 2 // 28 threads / 14 threads per package
>>
>>
>> I uploaded test code for `CPUID` leaf 0Bh: https://github.com/YaSuenag/garakuta/blob/master/check-hybrid-cores/hy-core-check.c
>
> Sorry I am very confused as to what is being calculated by what. IIUC (big IF!) we will always calculate `cores_per_cpu` incorrectly because we will assume all cores have the same HT setting - hence when we divide total-threads-per-cpu by threads-per-core, to get cores-per-cpu, the answer may be incorrect.
Agree! HT flag is set even though it is E-core (do not have HT), and also we cannot get number of physical cores, hence cores-per-cpu is always incorrect as you said.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27080#discussion_r2409166531
More information about the hotspot-dev
mailing list