Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2542697imm; Sat, 12 May 2018 14:11:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZruSmZAUA2lKYS5z0nBiAZiNn4WQcsIgFzxjLZvVrADiyWz+uTKNXWInOb6sUsRiAa0RErL X-Received: by 2002:a17:902:7601:: with SMTP id k1-v6mr3747213pll.200.1526159481231; Sat, 12 May 2018 14:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526159481; cv=none; d=google.com; s=arc-20160816; b=h08maCoMQCEhb1tE+3U5mmkttmqmC2nb9qIGwfuzOu4tGuyCZkQS0tqxww/L0h6bj6 TtJ4mrEVbw8s+aX4Rc/CgRwCSi9vug0XAvOjkapQPc7FEblg2BMm2hwUWwuqfn5CWEDe ZKZeaNPbhH7rZODRRKmAtuVmaHhEk25IJQfyQmrdZuw+ReQ1aYOfms3b+elOuWdXlXR0 wGGFkKADseSvLSBdHsfkBKk8bzVqM5X+WC7Vp22ZocKXr5Qb6Il9YlESd5Z0RUpQsu4C 1MHAmFTU3lOmOB33G71Vt5+URIUEQ70NDZpL7SqhMBw+CBlebOqj4agW0vkLzf2qvyuN 9koQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=5vaUWEOA0WhcDpJIq8ueWHECqpUOvHsgWOBL279D7wQ=; b=RykMiVxhRA9SP2aYj/SLG7ycSn6DtP1ovxxymIjwivGZRF64GMftXvuRSomEHymy4z LF6jNpmlMcssI8UqkQQVZprkwZlugkvuQEEHRWhA+GsAagigjbfqFxR+pQ86m7QjZhEo CuhpxUFQtH6gREy7HxSqNpwrwXWsftKHaMp8UUOVRBEPmCBN7aKkSH9VIs1BFq581N+d OuxBb4BTVXxThyiDno1Zz8+Do/pm3NsEe+oIE5+BmYOWiQ604CRRyPULpXNNl9Zu/oXD a/eGjYbY8AxzbpHr8+buLrBedHW0D/AkO/KZMYNR4W9+SuLOTFO9+4zjAMTMlwCdccuT cmxg== ARC-Authentication-Results: i=1; mx.google.com; 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 i62-v6si6300445pfg.218.2018.05.12.14.11.06; Sat, 12 May 2018 14:11:21 -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; 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 S1751975AbeELVKq (ORCPT + 99 others); Sat, 12 May 2018 17:10:46 -0400 Received: from terminus.zytor.com ([198.137.202.136]:35467 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751739AbeELVKp (ORCPT ); Sat, 12 May 2018 17:10:45 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w4CLAJOd095962 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 12 May 2018 14:10:20 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w4CLAHsm095955; Sat, 12 May 2018 14:10:17 -0700 Date: Sat, 12 May 2018 14:10:17 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Suravee Suthikulpanit Message-ID: Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, suravee.suthikulpanit@amd.com, Janakarajan.Natarajan@amd.com, bp@suse.de, mingo@kernel.org, peterz@infradead.org Reply-To: tglx@linutronix.de, suravee.suthikulpanit@amd.com, hpa@zytor.com, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@kernel.org, Janakarajan.Natarajan@amd.com, bp@suse.de In-Reply-To: <1524864877-111962-3-git-send-email-suravee.suthikulpanit@amd.com> References: <1524864877-111962-3-git-send-email-suravee.suthikulpanit@amd.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] perf/events/amd/uncore: Fix amd_uncore_llc ID to use pre-defined cpu_llc_id Git-Commit-ID: 812af433038f984fd951224e8239b09188e36a13 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 812af433038f984fd951224e8239b09188e36a13 Gitweb: https://git.kernel.org/tip/812af433038f984fd951224e8239b09188e36a13 Author: Suravee Suthikulpanit AuthorDate: Fri, 27 Apr 2018 16:34:35 -0500 Committer: Thomas Gleixner CommitDate: Sun, 6 May 2018 12:49:15 +0200 perf/events/amd/uncore: Fix amd_uncore_llc ID to use pre-defined cpu_llc_id 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 --- 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 f5cbbba99283..981ba5e8241b 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 @@ -399,26 +400,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;