From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A45BDC32750 for ; Fri, 2 Aug 2019 09:47:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C8EA2184D for ; Fri, 2 Aug 2019 09:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739268; bh=+WUMdsBTBGurwTRfQbddsebWWDW3fHpFQ8g9jEtC8wY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dkvb1mlWhTjKkaP1y1yRtyoohekm17XRLXGJBTy4d5RDL9iongN35MpkgDz0LW89Z tKjKce5stWoI3xfTSwhmkfevKKZFtf/wY+yfMYJdyV1iO49NrFpHtkG/m59Q9lElEu Qv4bdnzg7mXnf1KfyJX+EmhIuTZZ1nJGmczmvT68= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405727AbfHBJrq (ORCPT ); Fri, 2 Aug 2019 05:47:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:52678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405716AbfHBJro (ORCPT ); Fri, 2 Aug 2019 05:47:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B618820880; Fri, 2 Aug 2019 09:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739264; bh=+WUMdsBTBGurwTRfQbddsebWWDW3fHpFQ8g9jEtC8wY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T8ga7047pUwMMcWgVaSsqZayHAhlbqkijzFw0gdU+lkOT5izywcpch4hCWBrRafmJ /vG/RemtVhapwHt95KOyRHskEJx1x9tcN/eSCEp97IkjIh70ZlKg1gYqLE43MtpJe9 fRJQMMF4ZChcoAB0SxWzr+/y7VmvU12Kt+7eIhgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janakarajan Natarajan , "Peter Zijlstra (Intel)" , Borislav Petkov , Alexander Shishkin , Arnaldo Carvalho de Melo , Linus Torvalds , Suravee Suthikulpanit , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.9 152/223] perf/x86/amd/uncore: Get correct number of cores sharing last level cache Date: Fri, 2 Aug 2019 11:36:17 +0200 Message-Id: <20190802092248.283719085@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In Family 17h, the number of cores sharing a cache level is obtained from the Cache Properties CPUID leaf (0x8000001d) by passing in the cache level in ECX. In prior families, a cache level of 2 was used to determine this information. To get the right information, irrespective of Family, iterate over the cache levels using CPUID 0x8000001d. The last level cache is the last value to return a non-zero value in EAX. Signed-off-by: Janakarajan Natarajan Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Borislav Petkov Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Suravee Suthikulpanit Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/5ab569025b39cdfaeca55b571d78c0fc800bdb69.1497452002.git.Janakarajan.Natarajan@amd.com Signed-off-by: Ingo Molnar --- arch/x86/events/amd/uncore.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 094973313037..10f023799f11 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -378,11 +378,24 @@ static int amd_uncore_cpu_starting(unsigned int cpu) if (amd_uncore_llc) { unsigned int apicid = cpu_data(cpu).apicid; - unsigned int nshared; + unsigned int nshared, subleaf, prev_eax = 0; uncore = *per_cpu_ptr(amd_uncore_llc, cpu); - cpuid_count(0x8000001d, 2, &eax, &ebx, &ecx, &edx); - nshared = ((eax >> 14) & 0xfff) + 1; + /* + * Iterate over Cache Topology Definition leaves until no + * more cache descriptions are available. + */ + for (subleaf = 0; subleaf < 5; subleaf++) { + cpuid_count(0x8000001d, subleaf, &eax, &ebx, &ecx, &edx); + + /* EAX[0:4] gives type of cache */ + if (!(eax & 0x1f)) + break; + + prev_eax = eax; + } + nshared = ((prev_eax >> 14) & 0xfff) + 1; + uncore->id = apicid - (apicid % nshared); uncore = amd_uncore_find_online_sibling(uncore, amd_uncore_llc); -- 2.20.1