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=-11.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 27DDFC742DF for ; Sat, 13 Jul 2019 11:12:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 009ED20848 for ; Sat, 13 Jul 2019 11:12:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="rYwno2U5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727910AbfGMLML (ORCPT ); Sat, 13 Jul 2019 07:12:11 -0400 Received: from terminus.zytor.com ([198.137.202.136]:60651 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726474AbfGMLMK (ORCPT ); Sat, 13 Jul 2019 07:12:10 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6DBBZOE3841752 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 13 Jul 2019 04:11:35 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6DBBZOE3841752 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1563016296; bh=otuByoDP0t/zpW5lFi6qIpRPgYUEBP1U0bXRUDzizkM=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=rYwno2U5rjKLDcVSHuQgpS5FECWsZ7JOHL7uvn3Fj8pXTK2XnC85akDlEL2oXsd7W OnGA333lDPcGp21pNDRcQYqqukV1jCAfd93GXPZqtCVu31oeBasNcckcPnaO8XJIz+ vO4obHUKthvNcTHSErCfEUoGhgxCAfPPLO0pzp/1YnQCL7j28CWO8d0E1c5udQpsqg 0JyHOJeujBhPMptrtyMP4IiaZmDWhXiWqIHqnnfr1j8Kgrr0f26X+JFfWKaAsnMnvT v8H4UX8VVth/zwTCZOWxWAz13EbkTFAEUzHCdn7T0fDNpTQzHjXhByW3hpLWznZNRg HcfR4szdN87CA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6DBBYFp3841749; Sat, 13 Jul 2019 04:11:34 -0700 Date: Sat, 13 Jul 2019 04:11:34 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Kim Phillips Message-ID: Cc: hpa@zytor.com, tglx@linutronix.de, kim.phillips@amd.com, acme@redhat.com, torvalds@linux-foundation.org, Gary.Hook@amd.com, puwen@hygon.cn, alexander.shishkin@linux.intel.com, Suravee.Suthikulpanit@amd.com, mingo@kernel.org, mliska@suse.cz, bp@alien8.de, namhyung@kernel.org, Janakarajan.Natarajan@amd.com, stable@vger.kernel.org, peterz@infradead.org, jolsa@redhat.com, linux-kernel@vger.kernel.org, eranian@google.com, vincent.weaver@maine.edu Reply-To: hpa@zytor.com, tglx@linutronix.de, acme@redhat.com, kim.phillips@amd.com, torvalds@linux-foundation.org, puwen@hygon.cn, alexander.shishkin@linux.intel.com, Gary.Hook@amd.com, Suravee.Suthikulpanit@amd.com, mingo@kernel.org, mliska@suse.cz, namhyung@kernel.org, bp@alien8.de, Janakarajan.Natarajan@amd.com, peterz@infradead.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, jolsa@redhat.com, eranian@google.com, vincent.weaver@maine.edu In-Reply-To: <20190628215906.4276-2-kim.phillips@amd.com> References: <20190628215906.4276-2-kim.phillips@amd.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/x86/amd/uncore: Set the thread mask for F17h L3 PMCs Git-Commit-ID: 2f217d58a8a086d3399fecce39fb358848e799c4 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2f217d58a8a086d3399fecce39fb358848e799c4 Gitweb: https://git.kernel.org/tip/2f217d58a8a086d3399fecce39fb358848e799c4 Author: Kim Phillips AuthorDate: Fri, 28 Jun 2019 21:59:33 +0000 Committer: Ingo Molnar CommitDate: Sat, 13 Jul 2019 11:21:27 +0200 perf/x86/amd/uncore: Set the thread mask for F17h L3 PMCs Fill in the L3 performance event select register ThreadMask bitfield, to enable per hardware thread accounting. Signed-off-by: Kim Phillips Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: Gary Hook Cc: H. Peter Anvin Cc: Janakarajan Natarajan Cc: Jiri Olsa Cc: Linus Torvalds Cc: Martin Liska Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Pu Wen Cc: Stephane Eranian Cc: Suravee Suthikulpanit Cc: Thomas Gleixner Cc: Vince Weaver Link: https://lkml.kernel.org/r/20190628215906.4276-2-kim.phillips@amd.com Signed-off-by: Ingo Molnar --- arch/x86/events/amd/uncore.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index c2c4ae5fbbfc..a6ea07f2aa84 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -202,15 +202,22 @@ static int amd_uncore_event_init(struct perf_event *event) hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; hwc->idx = -1; + if (event->cpu < 0) + return -EINVAL; + /* * SliceMask and ThreadMask need to be set for certain L3 events in * Family 17h. For other events, the two fields do not affect the count. */ - if (l3_mask && is_llc_event(event)) - hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK); + if (l3_mask && is_llc_event(event)) { + int thread = 2 * (cpu_data(event->cpu).cpu_core_id % 4); - if (event->cpu < 0) - return -EINVAL; + if (smp_num_siblings > 1) + thread += cpu_data(event->cpu).apicid & 1; + + hwc->config |= (1ULL << (AMD64_L3_THREAD_SHIFT + thread) & + AMD64_L3_THREAD_MASK) | AMD64_L3_SLICE_MASK; + } uncore = event_to_amd_uncore(event); if (!uncore)