Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp443338ybc; Sat, 23 Nov 2019 01:27:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzGSn8y/m3kAbjtkJwSNl4SDFlIrvD2qLuxbNnH1RlIjuA2IPxDQDe7+3FyUCA9CcickFtG X-Received: by 2002:a50:ec83:: with SMTP id e3mr6317393edr.292.1574501273925; Sat, 23 Nov 2019 01:27:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574501273; cv=none; d=google.com; s=arc-20160816; b=L5+supAp7rtsf6kRutB6p1oq4FFCfJx/WTO4sX+CgIzd8nCKm0htuZ+N563PSK1Hzy WgPhWgbDey6M80I6xjjwfz8Uep760GwqZooRqIOTMC2VE0tLvnCUWl82WiVVJidwCd5h 3Rva+unlkcg1bw8g73EGjTVZIrgmf8Cb1YbbqZcycvSCptMmspffK5UV6WFtD5s7HaTA rlHesgsQWiWxP5Gp0GAy4312bbdR+yyfzeOF6mBuCRHuTiozDaIpIIh9HNMyyIbzWUL4 2muuQfkr8D77f3zXTjh8pSmNxHgoEkfyzd0ENlGJDpSV0LM+LmVGKkKZeDtgeg17p4YE 9UXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=0uiTRRYbeLZ5E6X6IjwEYR453UryrU7y4RWIkhCe50o=; b=t9B7IdjCZln6GqMUxy667qwu1sWKG5mhhIxS/AO79j3KqBuE/k4UeD/B0UYULyI6tk YSe1mSe1SwoR6LKBamjZI8Edhuv7RRLQKa8g0AdH6Qp8qgxVTaoaJOPDOqJKRToivG7D zfCmWIKY/Ijhpzn59cnOxCS/C7AWXrFniyEjiraDnjDN+HBLJbw2WJYyve6JQatjkalm 8auntv75eSdwsulMnZB4qq3zM3IGzbZ+EsJ5OwVA+zCOhCD+bPv/Q4/mn1wwxusufi0r cEPgudE7dr8RUNJhkq862s81RW1prW/rlDI2VR8m8HIzWbhKNonoPR62bo6E1/TxKMWl 3d0g== 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 t6si455163edr.52.2019.11.23.01.26.54; Sat, 23 Nov 2019 01:27:53 -0800 (PST) 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 S1726784AbfKWJYl (ORCPT + 99 others); Sat, 23 Nov 2019 04:24:41 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:6706 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726524AbfKWJYk (ORCPT ); Sat, 23 Nov 2019 04:24:40 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6AF948F924E54E9A4201; Sat, 23 Nov 2019 17:24:35 +0800 (CST) Received: from huawei.com (10.175.102.38) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Sat, 23 Nov 2019 17:24:29 +0800 From: Tan Xiaojun To: , , , , , , , , , , , , , , , CC: , , , , , , Subject: [RFC v3 4/5] drivers: perf: add some arm spe events Date: Sat, 23 Nov 2019 18:11:17 +0800 Message-ID: <20191123101118.12635-5-tanxiaojun@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123101118.12635-1-tanxiaojun@huawei.com> References: <20191123101118.12635-1-tanxiaojun@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.38] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add some definitions of arm spe events, these are precise ip events. Displayed in the perf list as follows: --------------------------------------------------------------------- ... arm_spe_0// [Kernel PMU event] arm_spe_0/branch_miss/ [Kernel PMU event] arm_spe_0/llc_miss/ [Kernel PMU event] arm_spe_0/remote_access/ [Kernel PMU event] arm_spe_0/tlb_miss/ [Kernel PMU event] ... --------------------------------------------------------------------- Signed-off-by: Tan Xiaojun --- drivers/perf/arm_spe_pmu.c | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 4e4984a55cd1..4df9abdb2255 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -161,6 +161,9 @@ static struct attribute_group arm_spe_pmu_cap_group = { #define ATTR_CFG_FLD_pct_enable_CFG config /* PMSCR_EL1.PCT */ #define ATTR_CFG_FLD_pct_enable_LO 2 #define ATTR_CFG_FLD_pct_enable_HI 2 +#define ATTR_CFG_FLD_event_CFG config /* ARM SPE EVENTS */ +#define ATTR_CFG_FLD_event_LO 3 +#define ATTR_CFG_FLD_event_HI 6 #define ATTR_CFG_FLD_jitter_CFG config /* PMSIRR_EL1.RND */ #define ATTR_CFG_FLD_jitter_LO 16 #define ATTR_CFG_FLD_jitter_HI 16 @@ -174,6 +177,11 @@ static struct attribute_group arm_spe_pmu_cap_group = { #define ATTR_CFG_FLD_store_filter_LO 34 #define ATTR_CFG_FLD_store_filter_HI 34 +#define ARM_SPE_EVENT_LLC_MISS BIT(0) +#define ARM_SPE_EVENT_BRANCH_MISS BIT(1) +#define ARM_SPE_EVENT_TLB_MISS BIT(2) +#define ARM_SPE_EVENT_REMOTE_ACCESS BIT(3) + #define ATTR_CFG_FLD_event_filter_CFG config1 /* PMSEVFR_EL1 */ #define ATTR_CFG_FLD_event_filter_LO 0 #define ATTR_CFG_FLD_event_filter_HI 63 @@ -213,8 +221,43 @@ GEN_PMU_FORMAT_ATTR(load_filter); GEN_PMU_FORMAT_ATTR(store_filter); GEN_PMU_FORMAT_ATTR(event_filter); GEN_PMU_FORMAT_ATTR(min_latency); +GEN_PMU_FORMAT_ATTR(event); + +static ssize_t +arm_spe_events_sysfs_show(struct device *dev, + struct device_attribute *attr, char *page) +{ + struct perf_pmu_events_attr *pmu_attr; + + pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr); + + return sprintf(page, "event=0x%03llx\n", pmu_attr->id); +} + +#define ARM_SPE_EVENT_ATTR(name, config) \ + PMU_EVENT_ATTR(name, arm_spe_event_attr_##name, \ + config, arm_spe_events_sysfs_show) + +ARM_SPE_EVENT_ATTR(llc_miss, ARM_SPE_EVENT_LLC_MISS); +ARM_SPE_EVENT_ATTR(branch_miss, ARM_SPE_EVENT_BRANCH_MISS); +ARM_SPE_EVENT_ATTR(tlb_miss, ARM_SPE_EVENT_TLB_MISS); +ARM_SPE_EVENT_ATTR(remote_access, ARM_SPE_EVENT_REMOTE_ACCESS); + +static struct attribute *arm_spe_pmu_event_attrs[] = { + &arm_spe_event_attr_llc_miss.attr.attr, + &arm_spe_event_attr_branch_miss.attr.attr, + &arm_spe_event_attr_tlb_miss.attr.attr, + &arm_spe_event_attr_remote_access.attr.attr, + NULL, +}; + +static struct attribute_group arm_spe_pmu_event_group = { + .name = "events", + .attrs = arm_spe_pmu_event_attrs, +}; static struct attribute *arm_spe_pmu_formats_attr[] = { + &format_attr_event.attr, &format_attr_ts_enable.attr, &format_attr_pa_enable.attr, &format_attr_pct_enable.attr, @@ -252,6 +295,7 @@ static struct attribute_group arm_spe_pmu_group = { }; static const struct attribute_group *arm_spe_pmu_attr_groups[] = { + &arm_spe_pmu_event_group, &arm_spe_pmu_group, &arm_spe_pmu_cap_group, &arm_spe_pmu_format_group, -- 2.17.1