From owner-svn-src-all@freebsd.org Sat Apr 8 14:16:43 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6BECBD334AE; Sat, 8 Apr 2017 14:16:43 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3E31E85; Sat, 8 Apr 2017 14:16:43 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v38EGgl3088252; Sat, 8 Apr 2017 14:16:42 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v38EGglS088251; Sat, 8 Apr 2017 14:16:42 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201704081416.v38EGglS088251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Sat, 8 Apr 2017 14:16:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316643 - head/sys/x86/x86 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Apr 2017 14:16:43 -0000 Author: avg Date: Sat Apr 8 14:16:42 2017 New Revision: 316643 URL: https://svnweb.freebsd.org/changeset/base/316643 Log: use msr 0xc001100c to discover multi-node AMD processors This is applicable only to the older processors that do not have the AMD Topology extension. Opteron 6100-series "Magny-Cours" processors had multiple nodes within a package and didn't have the Topology extension. Without this change FreeBSD would assume that those processors have a single L3 cache shared by all cores while, in fact, each node has its own L3 cache. Many thanks to Freddie Cash for providing valuable hardware information. 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 Sat Apr 8 10:00:39 2017 (r316642) +++ head/sys/x86/x86/mp_x86.c Sat Apr 8 14:16:42 2017 (r316643) @@ -236,7 +236,9 @@ static void topo_probe_amd(void) { u_int p[4]; + uint64_t v; int level; + int nodes_per_socket; int share_count; int type; int i; @@ -295,13 +297,18 @@ topo_probe_amd(void) caches[1].present = 1; } if (((p[3] >> 18) & 0x3fff) != 0) { - - /* - * TODO: Account for dual-node processors - * where each node within a package has its own - * L3 cache. - */ - caches[2].id_shift = pkg_id_shift; + nodes_per_socket = 1; + if ((amd_feature2 & AMDID2_NODE_ID) != 0) { + /* + * Handle multi-node processors that + * have multiple chips, each with its + * own L3 cache, on the same die. + */ + v = rdmsr(0xc001100c); + nodes_per_socket = 1 + ((v >> 3) & 0x7); + } + caches[2].id_shift = + pkg_id_shift - mask_width(nodes_per_socket); caches[2].present = 1; } }