Skip to content

Commit 16dc985

Browse files
committed
svm: adopt "JDK-8365673: Incorrect number of cores are reported on Ryzen CPU"
1 parent cf7b15c commit 16dc985

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64LibCHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* - substratevm/src/com.oracle.svm.native.libchelper/include/amd64hotspotcpuinfo.h
4444
* - substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c
4545
*/
46-
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/cpu/x86/vm_version_x86.hpp#L41-L348")
46+
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-26+13/src/hotspot/cpu/x86/vm_version_x86.hpp#L43-L351")
4747
@CLibrary(value = "libchelper", requireStatic = true)
4848
public class AMD64LibCHelper {
4949
@Platforms(Platform.AMD64.class)

substratevm/src/com.oracle.svm.native.libchelper/include/amd64hotspotcpuinfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ typedef union {
188188
typedef union {
189189
uint32_t value;
190190
struct {
191-
uint32_t cores_per_cpu : 8,
192-
: 24;
191+
uint32_t threads_per_cpu : 8,
192+
: 24;
193193
} bits;
194194
} ExtCpuid8Ecx;
195195

substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ static uint32_t cores_per_cpu(CpuidInfo *_cpuid_info) {
211211
}
212212
else if (is_amd_family(_cpuid_info))
213213
{
214-
result = (_cpuid_info->ext_cpuid8_ecx.bits.cores_per_cpu + 1);
214+
result = _cpuid_info->ext_cpuid8_ecx.bits.threads_per_cpu + 1;
215+
if (cpu_family(_cpuid_info) >= 0x17) { // Zen or later
216+
result /= _cpuid_info->ext_cpuid1E_ebx.bits.threads_per_core + 1;
217+
}
215218
}
216219
else if (is_zx(_cpuid_info))
217220
{

0 commit comments

Comments
 (0)