RFR: 8366847: JFR reports incorrect number of cores on hybrid CPU [v3]
David Holmes
dholmes at openjdk.org
Tue Oct 7 01:08:47 UTC 2025
On Fri, 3 Oct 2025 12:39:55 GMT, Yasumasa Suenaga <ysuenaga 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.
>>
>> Let me walk through an example to see if I have it right:
>>
>> We have a hybrid system with two sockets, each of which has 6P and 2E cores. Only the P cores have hyper-threading even though the HT bit is set. So the current code would do:
>>
>> _no_of_threads = 28 // I hope that is what the OS reports: 2 * (6*2 + 2)
>> threads_per_core() = 2 // because of HT bit
>> cores_per_cpu() = 8
>> threads_per_package = 2 * 8 = 16
>> _no_of_sockets = 28 / 16 = 1 // integer division -> gives wrong answer
>>
>> with new code:
>>
>> threads_per_package = 14 // direct from CPUID logical processors
>> _no_of_sockets = 28 / 14 = 12
>
>> 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.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27080#discussion_r2409066160
More information about the hotspot-dev
mailing list