Skip to content

Commit 1aca920

Browse files
committed
8365673: Incorrect number of cores are reported on Ryzen CPU
Reviewed-by: dholmes, kvn
1 parent 82289f6 commit 1aca920

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/hotspot/cpu/x86/vm_version_x86.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3148,7 +3148,10 @@ uint VM_Version::cores_per_cpu() {
31483148
result = (_cpuid_info.dcp_cpuid4_eax.bits.cores_per_cpu + 1);
31493149
}
31503150
} else if (is_amd_family()) {
3151-
result = (_cpuid_info.ext_cpuid8_ecx.bits.cores_per_cpu + 1);
3151+
result = _cpuid_info.ext_cpuid8_ecx.bits.threads_per_cpu + 1;
3152+
if (cpu_family() >= 0x17) { // Zen or later
3153+
result /= _cpuid_info.ext_cpuid1E_ebx.bits.threads_per_core + 1;
3154+
}
31523155
} else if (is_zx()) {
31533156
bool supports_topology = supports_processor_topology();
31543157
if (supports_topology) {

src/hotspot/cpu/x86/vm_version_x86.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ class VM_Version : public Abstract_VM_Version {
199199
union ExtCpuid8Ecx {
200200
uint32_t value;
201201
struct {
202-
uint32_t cores_per_cpu : 8,
203-
: 24;
202+
uint32_t threads_per_cpu : 8,
203+
: 24;
204204
} bits;
205205
};
206206

0 commit comments

Comments
 (0)