Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3786930ybi; Mon, 29 Jul 2019 12:36:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2RReJD/LeKmPhL8OdRdeQYvDu9HF6+kQ8zgjrhRHe/G62LptT8dzfS4G+4IAVZ0EcbJLw X-Received: by 2002:a63:ee08:: with SMTP id e8mr52022764pgi.70.1564428994146; Mon, 29 Jul 2019 12:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428994; cv=none; d=google.com; s=arc-20160816; b=Xam4Bs6cW+WLMVOASjQowUZxVA3Gmu1yTa2LOGzk+AUdi2w8X2GE2svyzNi4akXvLw NhD4Vp7xooEjnl88a4I92PEz3EvyMPT1t70U2VU9lvfRs+8oBfPrXgPGGbMjHuMdC9al iwssuJt4BkaGKryToncZk8Kn8w3XUX9uekZgbo+6Yi8SiQ5LANuU2i4daoGWcgaYR5hC oxWWbhrkyJjfIW3rggRHO9B3Ahr3/ZCL48eVt4Pz5p5QF6umoJCsAlxjG9rdqR2aH6Sm Y5eilr6CgGtkJjqX+IsY7aXjuphwDoXYbHQQLC2y8yRhh2TzM6XTCZO5koMZr/xwdc1R mBfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ifZN5WEMdagTrfxbp7XqJW2bGj01S5KZBL70jyiFKhQ=; b=ILuqt2S44blcw3sYCovG3CQoaGUspa91nnpBPLLfRCORUSbS3TVeVrknZEXMeMkU81 ZclCuofGTlXtlaMmXNjeEedQbgKshveqSxXCBnqWPX2026ISer39rwqQ24HBMz8D9S7p JxHFRLBMVzTfyt1Ym8cbVavVb/zC+/DWoFe/SIiKBMtrkcvglR5+NnIY7PIPq9HTQnh/ zb44WTKt5xY7qQGKNxkVaX5M+od4+h5BF8d0gdzv5uzPkL36GL746rMy559lrTpUQr77 xoTgvmI41zF8yOpzsD5vpAxCfRlw32LINYwJ5AxvdIUeqFiDcK5LL0MrIeZBny2wH1LD Aa1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="J/hiwckX"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd11si24581219plb.184.2019.07.29.12.36.19; Mon, 29 Jul 2019 12:36:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="J/hiwckX"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388482AbfG2Tep (ORCPT + 99 others); Mon, 29 Jul 2019 15:34:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:49132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388281AbfG2Tem (ORCPT ); Mon, 29 Jul 2019 15:34:42 -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 1E0E92070B; Mon, 29 Jul 2019 19:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428882; bh=XO+6JP4T9omkolO039O/6hZFh57nRKGvyiVIMiYPqpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J/hiwckXqNYQhii+RRJZuRazem/PcnJIZ3tbrNXzfQ5LKB+qeGiI/k48fnfnb4vXX kTcIpi00l/KcWc7MFx/Dpar7VbVsx2GLM4sYB69t5L+JKxuZLob/rixjViK4bLDSGd 1fJmXASwhg1+N0El/vfZsqUjR5baERndBG7LLcs4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Suravee Suthikulpanit , Borislav Petkov , Thomas Gleixner , "Peter Zijlstra (Intel)" , Janakarajan Natarajan , Sasha Levin Subject: [PATCH 4.14 215/293] perf/events/amd/uncore: Fix amd_uncore_llc ID to use pre-defined cpu_llc_id Date: Mon, 29 Jul 2019 21:21:46 +0200 Message-Id: <20190729190840.965994077@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 [ Upstream commit 812af433038f984fd951224e8239b09188e36a13 ] Current logic iterates over CPUID Fn8000001d leafs (Cache Properties) to detect the last level cache, and derive the last-level cache ID. However, this information is already available in the cpu_llc_id. Therefore, make use of it instead. Signed-off-by: Suravee Suthikulpanit Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Cc: "Peter Zijlstra (Intel)" Cc: Janakarajan Natarajan Link: http://lkml.kernel.org/r/1524864877-111962-3-git-send-email-suravee.suthikulpanit@amd.com Signed-off-by: Sasha Levin --- arch/x86/events/amd/uncore.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 3a9ab16d9c2b..baa7e36073f9 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -19,6 +19,7 @@ #include #include #include +#include #define NUM_COUNTERS_NB 4 #define NUM_COUNTERS_L2 4 @@ -414,26 +415,8 @@ static int amd_uncore_cpu_starting(unsigned int cpu) } if (amd_uncore_llc) { - unsigned int apicid = cpu_data(cpu).apicid; - unsigned int nshared, subleaf, prev_eax = 0; - uncore = *per_cpu_ptr(amd_uncore_llc, cpu); - /* - * 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->id = per_cpu(cpu_llc_id, cpu); uncore = amd_uncore_find_online_sibling(uncore, amd_uncore_llc); *per_cpu_ptr(amd_uncore_llc, cpu) = uncore; -- 2.20.1