Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2478603imd; Fri, 2 Nov 2018 12:06:49 -0700 (PDT) X-Google-Smtp-Source: AJdET5eGShAA3z2SKwL50TDO/tZouD3wPy04m68cxhPFM5fMbImzR7rnRjX/Q4cM9ea9Piqzmuvi X-Received: by 2002:a63:2ad4:: with SMTP id q203-v6mr11714957pgq.356.1541185609891; Fri, 02 Nov 2018 12:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541185609; cv=none; d=google.com; s=arc-20160816; b=tbow5VJAU6RzJfS8t2OWlHlQGbuTSKz1aWeGc4BMFiGOHg2IqlewOM5OIyaioJjcS4 GPU4vcErvOXDaoRUH7zDTgcBqSZurARRQG5i/zNKj2dvlzFmnCpcm629/6Q+5FBFhd5+ 25T8i21I574gQSFNepU/7uViCoMuoSEMzbZEEmOVWTFXjufRTrQXXzF1JGKcPs4qPI6A b/zO+AXVHbjZOwIA2HCiUwm4N8mQw7hdAHqouQRFr+Gk9igIFv4JHUFA4ligOXnrxifa sMaOPpP3N9+DCsvh8fAf/xrl3uWoLjigJgL5CavS5E5SpvZK83jEZPtUjmOmqY8oE90L QATQ== 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=/o7EDw1L6ugG82Zb4mc2vRB+k+wIgnIpUROB1rjq024=; b=CGi2z+QF/vIVP+W4KZeM5IYKA/BPfmdjV2LyHBS3KCT1J+ZpPETASoUdO6B0le9hER QeMpFhECo0oRgORNDmXVyhowXnnOLkU99IW2cw/SC0TFt+4ySkIwZZ23mPiCBy/Tchny RkX/mzu54CPBj3GHJwwzu2JRH66LE3cFVlpPL6tpSVj4LyWyGjcmA3GrvUU4Q5lNV+Au rQ9k/QjLgq+DxqH8foWHi+efz3ChjaQiEWCqpGJfnARiz4ciuqA1s7OXbyjVLpaTPTy0 IzSyEIPiPPsY1CvXXdNeVFHvqawpF/Ng54BTJRWfySBJMMHW77UChO4IInlLPYrInLqm vx5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CEDySOy3; 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 r12-v6si34156627pga.346.2018.11.02.12.06.34; Fri, 02 Nov 2018 12:06:49 -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=CEDySOy3; 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 S1729680AbeKCDuD (ORCPT + 99 others); Fri, 2 Nov 2018 23:50:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:44836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728835AbeKCDuB (ORCPT ); Fri, 2 Nov 2018 23:50:01 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.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 A06DF2084A; Fri, 2 Nov 2018 18:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184109; bh=u7X62NUCErPKELiytj9YapuSbzcq5e4FZpcHGdHUzsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CEDySOy3/U3NSlizdpC0gyZuntQZwwgCBJe/q1Bko6wxzYRpJ7pxSUP8Ki3IBGEPy 2YlFbAN/aTAuY/vZA3sumisXyiu0T1Ij5HHOBUlEkqdyFvhGV3OVGCP84GolgD3zQu 3b0TD1/oGlX86+CRv+KjaKD97ArH2gvOQPkBTW6g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janakarajan Natarajan , "Peter Zijlstra (Intel)" , Alexander Shishkin , Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Borislav Petkov , "H . Peter Anvin" , Jiri Olsa , Linus Torvalds , Namhyung Kim , Stephane Eranian , Suravee , Thomas Gleixner , Vince Weaver , Ingo Molnar , Sasha Levin Subject: [PATCH 4.18 057/150] perf/x86/amd/uncore: Set ThreadMask and SliceMask for L3 Cache perf events Date: Fri, 2 Nov 2018 19:33:39 +0100 Message-Id: <20181102182907.517570865@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit d7cbbe49a9304520181fb8c9272d1327deec8453 ] In Family 17h, some L3 Cache Performance events require the ThreadMask and SliceMask to be set. For other events, these fields do not affect the count either way. Set ThreadMask and SliceMask to 0xFF and 0xF respectively. Signed-off-by: Janakarajan Natarajan Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Arnaldo Carvalho de Melo Cc: Borislav Petkov Cc: H . Peter Anvin Cc: Jiri Olsa Cc: Linus Torvalds Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Suravee Cc: Thomas Gleixner Cc: Vince Weaver Link: http://lkml.kernel.org/r/Message-ID: Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- arch/x86/events/amd/uncore.c | 10 ++++++++++ arch/x86/include/asm/perf_event.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/arch/x86/events/amd/uncore.c b/arch/x86/events/amd/uncore.c index 981ba5e8241b..8671de126eac 100644 --- a/arch/x86/events/amd/uncore.c +++ b/arch/x86/events/amd/uncore.c @@ -36,6 +36,7 @@ static int num_counters_llc; static int num_counters_nb; +static bool l3_mask; static HLIST_HEAD(uncore_unused_list); @@ -209,6 +210,13 @@ static int amd_uncore_event_init(struct perf_event *event) hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB; hwc->idx = -1; + /* + * 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) + hwc->config |= (AMD64_L3_SLICE_MASK | AMD64_L3_THREAD_MASK); + if (event->cpu < 0) return -EINVAL; @@ -525,6 +533,7 @@ static int __init amd_uncore_init(void) amd_llc_pmu.name = "amd_l3"; format_attr_event_df.show = &event_show_df; format_attr_event_l3.show = &event_show_l3; + l3_mask = true; } else { num_counters_nb = NUM_COUNTERS_NB; num_counters_llc = NUM_COUNTERS_L2; @@ -532,6 +541,7 @@ static int __init amd_uncore_init(void) amd_llc_pmu.name = "amd_l2"; format_attr_event_df = format_attr_event; format_attr_event_l3 = format_attr_event; + l3_mask = false; } amd_nb_pmu.attr_groups = amd_uncore_attr_groups_df; diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h index 12f54082f4c8..78241b736f2a 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -46,6 +46,14 @@ #define INTEL_ARCH_EVENT_MASK \ (ARCH_PERFMON_EVENTSEL_UMASK | ARCH_PERFMON_EVENTSEL_EVENT) +#define AMD64_L3_SLICE_SHIFT 48 +#define AMD64_L3_SLICE_MASK \ + ((0xFULL) << AMD64_L3_SLICE_SHIFT) + +#define AMD64_L3_THREAD_SHIFT 56 +#define AMD64_L3_THREAD_MASK \ + ((0xFFULL) << AMD64_L3_THREAD_SHIFT) + #define X86_RAW_EVENT_MASK \ (ARCH_PERFMON_EVENTSEL_EVENT | \ ARCH_PERFMON_EVENTSEL_UMASK | \ -- 2.17.1