Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Mar 2017 09:45:28 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r316017 - head/sys/x86/x86
Message-ID:  <201703270945.v2R9jSov001041@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Mon Mar 27 09:45:27 2017
New Revision: 316017
URL: https://svnweb.freebsd.org/changeset/base/316017

Log:
  add SMT detection for newer AMD processors
  
  The change seems to be more in the nomenclature than in the way the
  topology is advertised by the hardware.
  
  Tested by:	truckman (earlier version of the change)
  MFC after:	2 weeks

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==============================================================================
--- head/sys/x86/x86/mp_x86.c	Mon Mar 27 08:29:46 2017	(r316016)
+++ head/sys/x86/x86/mp_x86.c	Mon Mar 27 09:45:27 2017	(r316017)
@@ -255,6 +255,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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703270945.v2R9jSov001041>