diff options
author | avg <avg@FreeBSD.org> | 2017-04-14 14:48:55 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2017-04-14 14:48:55 +0000 |
commit | 48da4debb3f0c6d155cb6ddc2fb1cdbb04f924cf (patch) | |
tree | b9ba298bb23a43d3625a898286f897b7791a9569 | |
parent | 9d1a30867b750d1c56228c6311c0f84f0d11555d (diff) | |
download | FreeBSD-src-48da4debb3f0c6d155cb6ddc2fb1cdbb04f924cf.zip FreeBSD-src-48da4debb3f0c6d155cb6ddc2fb1cdbb04f924cf.tar.gz |
MFC r316017,r316020: add SMT detection for newer AMD processors
-rw-r--r-- | sys/x86/x86/mp_x86.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 9de5339..cd66eea 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -226,11 +226,10 @@ add_deterministic_cache(int type, int level, int share_count) * Determine topology of processing units and caches for AMD CPUs. * See: * - AMD CPUID Specification (Publication # 25481) - * - BKDG For AMD Family 10h Processors (Publication # 31116), section 2.15 * - BKDG for AMD NPT Family 0Fh Processors (Publication # 32559) - * XXX At the moment the code does not recognize grouping of AMD CMT threads, - * if supported, into cores, so each thread is treated as being in its own - * core. In other words, each logical CPU is considered to be a core. + * - BKDG For AMD Family 10h Processors (Publication # 31116) + * - BKDG For AMD Family 15h Models 00h-0Fh Processors (Publication # 42301) + * - BKDG For AMD Family 16h Models 00h-0Fh Processors (Publication # 48751) */ static void topo_probe_amd(void) @@ -254,6 +253,22 @@ topo_probe_amd(void) pkg_id_shift = mask_width((cpu_procinfo2 & AMDID_CMP_CORES) + 1); + /* + * Families prior to 16h define the following value as + * cores per compute unit and we don't really care about the AMD + * compute units at the moment. Perhaps we should treat them as + * cores and cores within the compute units as hardware threads, + * but that's up for debate. + * Later families define the value as threads per compute unit, + * so we are following AMD's nomenclature here. + */ + if ((amd_feature2 & AMDID2_TOPOLOGY) != 0 && + CPUID_TO_FAMILY(cpu_id) >= 0x16) { + cpuid_count(0x8000001e, 0, p); + share_count = ((p[1] >> 8) & 0xff) + 1; + core_id_shift = mask_width(share_count); + } + if ((amd_feature2 & AMDID2_TOPOLOGY) != 0) { for (i = 0; ; i++) { cpuid_count(0x8000001d, i, p); |