From patchwork Tue Nov 9 10:25:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm/Do28gTcOhcmlvIERvbWluZ29z?= X-Patchwork-Id: 12610389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 784FBC433F5 for ; Tue, 9 Nov 2021 10:34:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4133C610F8 for ; Tue, 9 Nov 2021 10:34:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4133C610F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=T81YKxSH5xepMA/28XuNzCMedXNoTUWCAfvAUOozKQo=; b=DMR9hOoQzQvo8q ouEgpZ1hospwwsONqEXgHy+yzphBY/IB2cAAAY4lzk+fOTz9+onaYXEU4dxAs25F/QB1rgJ2HNFKq PtEmdsyZ7T481+oPP9Y/UNIqkoKkeSrDzxhCx20Ruo887NzYOpYurUdgfjmzXnS5cf1e0NJgMR3Hg 275SiDrVdddGqSjCZ+9lYcLvQGoiL5znFyIacxQAKkhLSKfBrAhkXJv8WbQ+vyhk5Pvdu9in4JOGP tuicyN3ul2wsEzo7xLvjdfcoWgASLxjryN3mL24lMDtdIw0WFP4jn2xeMQjq6BFFzW2mT0DJPPb8B /28QWXJS+hgSgg+PoZww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkOSL-001YlK-3g; Tue, 09 Nov 2021 10:34:21 +0000 Received: from smtp1.tecnico.ulisboa.pt ([193.136.128.21]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkORs-001YaL-IL for linux-riscv@lists.infradead.org; Tue, 09 Nov 2021 10:33:58 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id 921C16005433; Tue, 9 Nov 2021 10:26:00 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.11.0 (20160426) (Debian) at tecnico.ulisboa.pt Received: from smtp1.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp1.tecnico.ulisboa.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id ejsPI05q3Uta; Tue, 9 Nov 2021 10:25:57 +0000 (WET) Received: from mail2.tecnico.ulisboa.pt (mail2.ist.utl.pt [IPv6:2001:690:2100:1::4750:b5b4]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTPS id 6621B6005C37; Tue, 9 Nov 2021 10:25:57 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tecnico.ulisboa.pt; s=mail; t=1636453557; bh=4wJpEEWXqws1hIngv9XGihPaug2YZrgE2W8X/0vyhTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=um1+kyv0pSwr1E61X/NAys+sSdtIuBA6Eele67GVp9+POxu4NZwXa5XaU6FysWw7v Ov5qxpGoTs6aJZWjleuXlCshyRvhW4E9JSQqAuKUPj6g39Qhg3RJP2WX2klrAYi4Et i4qJUonyI15d/LGIiAf6Gvg+UZBVKmt6l+uHH3DA= Received: from localhost.localdomain (unknown [IPv6:2001:8a0:fa2d:4500:215:5dff:fe40:101]) (Authenticated sender: ist181713) by mail2.tecnico.ulisboa.pt (Postfix) with ESMTPSA id 3BAFA56007A; Tue, 9 Nov 2021 10:25:57 +0000 (WET) From: =?utf-8?b?Sm/Do28gTcOhcmlvIERvbWluZ29z?= To: palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu Cc: atish.patra@wdc.com, anup.patel@wdc.com, linux-riscv@lists.infradead.org Subject: [PATCH 1/4] RISC-V: Create unique identification for SoC PMU Date: Tue, 9 Nov 2021 10:25:52 +0000 Message-Id: <20211109102555.16381-2-joao.mario@tecnico.ulisboa.pt> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109102555.16381-1-joao.mario@tecnico.ulisboa.pt> References: <20211109102555.16381-1-joao.mario@tecnico.ulisboa.pt> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_023352_815632_9456F6D6 X-CRM114-Status: GOOD ( 14.73 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The SBI PMU platform driver did not provide any identification for perf events matching. This patch introduces a new sysfs file inside the platform device (soc:pmu/id) for pmu identification. The identification is a 64-bit value generated as: [63-32]: mvendorid; [31]: marchid[MSB]; [30-16]: marchid[15-0]; [15-0]: mimpid[15MSBs]; The CSRs are detailed in the RISC-V privileged spec [1]. The marchid is split in MSB + 15LSBs, due to the MSB being used for open-source architecture identification. [1] https://github.com/riscv/riscv-isa-manual Signed-off-by: João Mário Domingos --- arch/riscv/kernel/sbi.c | 3 +++ drivers/perf/riscv_pmu_sbi.c | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c index 7402a417f38e..4e4f5671b864 100644 --- a/arch/riscv/kernel/sbi.c +++ b/arch/riscv/kernel/sbi.c @@ -551,16 +551,19 @@ long sbi_get_mvendorid(void) { return __sbi_base_ecall(SBI_EXT_BASE_GET_MVENDORID); } +EXPORT_SYMBOL(sbi_get_mvendorid); long sbi_get_marchid(void) { return __sbi_base_ecall(SBI_EXT_BASE_GET_MARCHID); } +EXPORT_SYMBOL(sbi_get_marchid); long sbi_get_mimpid(void) { return __sbi_base_ecall(SBI_EXT_BASE_GET_MIMPID); } +EXPORT_SYMBOL(sbi_get_mimpid); static void sbi_send_cpumask_ipi(const struct cpumask *target) { diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index 7a68dfa89f6f..f913d8ddfe73 100644 --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -236,6 +236,15 @@ static const struct pmu_event_data pmu_cache_event_map[PERF_COUNT_HW_CACHE_MAX] }, }; +static DEVICE_ATTR(id, S_IRUGO | S_IWUSR, pmu_sbi_id_show, 0); + +static struct attribute *pmu_sbi_attrs[] = { + &dev_attr_id.attr, + NULL +}; + +ATTRIBUTE_GROUPS(pmu_sbi); + static int pmu_sbi_ctr_get_width(int idx) { return pmu_ctr_list[idx].width; @@ -642,6 +651,36 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde return 0; } +static uint64_t pmu_sbi_get_pmu_id(void) +{ + union sbi_pmu_id { + uint64_t value; + struct { + uint16_t imp:16; + uint16_t arch:16; + uint32_t vendor:32; + }; + }pmuid; + + pmuid.value = 0; + pmuid.vendor = (uint32_t) sbi_get_mvendorid(); + pmuid.arch = (sbi_get_marchid() >> (63 - 15) & (1 << 15)) | ( sbi_get_marchid() & 0x7FFF ); + pmuid.imp = (sbi_get_mimpid() >> 16); + + return pmuid.value; +} + +static ssize_t pmu_sbi_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int len; + len = sprintf(buf, "0x%lx\n", pmu_sbi_get_pmu_id()); + if (len <= 0) + dev_err(dev, "mydrv: Invalid sprintf len: %dn", len); + + return len; +} + static int pmu_sbi_device_probe(struct platform_device *pdev) { struct riscv_pmu *pmu = NULL; @@ -680,6 +719,13 @@ static int pmu_sbi_device_probe(struct platform_device *pdev) pmu->ctr_clear_idx = pmu_sbi_ctr_clear_idx; pmu->ctr_read = pmu_sbi_ctr_read; + ret = sysfs_create_group(&pdev->dev.kobj, &pmu_sbi_group); + if (ret) { + dev_err(&pdev->dev, "sysfs creation failed\n"); + return ret; + } + pdev->dev.groups = pmu_sbi_groups; + ret = cpuhp_state_add_instance(CPUHP_AP_PERF_RISCV_STARTING, &pmu->node); if (ret) return ret; From patchwork Tue Nov 9 10:25:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm/Do28gTcOhcmlvIERvbWluZ29z?= X-Patchwork-Id: 12610383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D45AC433EF for ; Tue, 9 Nov 2021 10:34:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 394F3610F8 for ; Tue, 9 Nov 2021 10:34:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 394F3610F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=90JKXkaKjPnsKCNYKnCOkWAos27Qi1btJj3ey23hSIg=; b=xoTBAm4TG0yzEO fwO6VBZjhyfdG2XIKRi0fhJRl0tvMxM0HaZ/RRyQIoukYhZ2R6Q1rJUrhX/Zuq5+2jl7eaQlt7LBy 4Dh+UKtO9O3q+vwE1anK7zSnIAJrMY0lxn1vlCcc5Dqa9uq0rfFQIvZxd0xjgf1nUckfGTog9AlxJ auL4vSd4s17ZTcOGBYF7sEZ6kniDOeEbWJMKcafUMJAEbrQVKiwQxxTi3avT/FyNyKVHk4CiPcAiK vbZHHiq19167fZ90fsVGcoi/nUwumo42khyvPuRmrTjk0b6UXn80WzOz8uq+6b8BR4YioyXdC2c+z 9HVaU9oFlDFAQHOV1okQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkOS1-001YeW-Vl; Tue, 09 Nov 2021 10:34:02 +0000 Received: from smtp1.tecnico.ulisboa.pt ([2001:690:2100:1::15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkORs-001YaM-Im for linux-riscv@lists.infradead.org; Tue, 09 Nov 2021 10:33:58 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id BDDA16005438; Tue, 9 Nov 2021 10:26:00 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.11.0 (20160426) (Debian) at tecnico.ulisboa.pt Received: from smtp1.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp1.tecnico.ulisboa.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id yIPkBlqvj0VD; Tue, 9 Nov 2021 10:25:57 +0000 (WET) Received: from mail2.tecnico.ulisboa.pt (mail2.ist.utl.pt [IPv6:2001:690:2100:1::4750:b5b4]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTPS id 8B15B6005C38; Tue, 9 Nov 2021 10:25:57 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tecnico.ulisboa.pt; s=mail; t=1636453557; bh=gB7Bk2VrzmEu20yTNuOy52qSSylQeFsF/mDum1VfHig=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=P2MMoJrauIZ5utItJ3aVkuyuoQRZUdKwxbtiK9VfuBJ+A4d/6kqz65ZuJS/MdJOP7 PJ8pKLy8VTCa8TbjT+imni6VBojvSzqLMcUXD4SOw7i26+2MdEbap2G26m3zG7Z1NM guPq/4rmFPqDVv8RRuBaSNEoihS5VaP5BYoDslOQ= Received: from localhost.localdomain (unknown [IPv6:2001:8a0:fa2d:4500:215:5dff:fe40:101]) (Authenticated sender: ist181713) by mail2.tecnico.ulisboa.pt (Postfix) with ESMTPSA id 5ECCF560085; Tue, 9 Nov 2021 10:25:57 +0000 (WET) From: =?utf-8?b?Sm/Do28gTcOhcmlvIERvbWluZ29z?= To: palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu Cc: atish.patra@wdc.com, anup.patel@wdc.com, linux-riscv@lists.infradead.org Subject: [PATCH 2/4] RISC-V: Support CPUID for risc-v in perf Date: Tue, 9 Nov 2021 10:25:53 +0000 Message-Id: <20211109102555.16381-3-joao.mario@tecnico.ulisboa.pt> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109102555.16381-1-joao.mario@tecnico.ulisboa.pt> References: <20211109102555.16381-1-joao.mario@tecnico.ulisboa.pt> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_023352_822630_86466E5B X-CRM114-Status: GOOD ( 17.77 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This patch creates the header.c file for the risc-v architecture and introduces support for PMU identification through sysfs. It is now possible to configure pmu-events in risc-v. Depends on patch [1], that introduces the id sysfs file. Signed-off-by: João Mário Domingos --- drivers/perf/riscv_pmu.c | 18 ++++++++ tools/perf/arch/riscv/util/Build | 1 + tools/perf/arch/riscv/util/header.c | 66 +++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 tools/perf/arch/riscv/util/header.c diff --git a/drivers/perf/riscv_pmu.c b/drivers/perf/riscv_pmu.c index 0c853e23f679..3752ffd4edaf 100644 --- a/drivers/perf/riscv_pmu.c +++ b/drivers/perf/riscv_pmu.c @@ -17,6 +17,23 @@ #include +PMU_FORMAT_ATTR(event, "config:0-63"); + +static struct attribute *riscv_arch_formats_attr[] = { + &format_attr_event.attr, + NULL, +}; + +static struct attribute_group riscv_pmu_format_group = { + .name = "format", + .attrs = riscv_arch_formats_attr, +}; + +static const struct attribute_group *riscv_pmu_attr_groups[] = { + &riscv_pmu_format_group, + NULL, +}; + static unsigned long csr_read_num(int csr_num) { #define switchcase_csr_read(__csr_num, __val) {\ @@ -314,6 +331,7 @@ struct riscv_pmu *riscv_pmu_alloc(void) cpuc->events[i] = NULL; } pmu->pmu = (struct pmu) { + .attr_groups = riscv_pmu_attr_groups, .event_init = riscv_pmu_event_init, .add = riscv_pmu_add, .del = riscv_pmu_del, diff --git a/tools/perf/arch/riscv/util/Build b/tools/perf/arch/riscv/util/Build index 7d3050134ae0..603dbb5ae4dc 100644 --- a/tools/perf/arch/riscv/util/Build +++ b/tools/perf/arch/riscv/util/Build @@ -1,4 +1,5 @@ perf-y += perf_regs.o +perf-y += header.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o diff --git a/tools/perf/arch/riscv/util/header.c b/tools/perf/arch/riscv/util/header.c new file mode 100644 index 000000000000..ef739ae36d48 --- /dev/null +++ b/tools/perf/arch/riscv/util/header.c @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include "../../util/debug.h" +#include "../../util/header.h" + +#define STR_LEN 1024 +#define ID_SIZE 64 + +static int _get_cpuid(char *buf, size_t sz) +{ + const char *sysfs = sysfs__mountpoint(); + u64 id = 0; + char path[PATH_MAX]; + FILE *file; + + if (!sysfs || sz < ID_SIZE) + return EINVAL; + + scnprintf(path, PATH_MAX, "%s/devices/platform/soc/soc:pmu/id", + sysfs); + + file = fopen(path, "r"); + if (!file) { + pr_debug("fopen failed for file %s\n", path); + return EINVAL; + } + if (!fgets(buf, ID_SIZE, file)) { + fclose(file); + return EINVAL; + } + + fclose(file); + + /*Check if value is numeric and remove special characters*/ + id = strtoul(buf, NULL, 16); + if (!id) + return EINVAL; + scnprintf(buf, ID_SIZE, "0x%lx", id); + + return 0; +} + +char *get_cpuid_str(struct perf_pmu *pmu __maybe_unused) +{ + char *buf = NULL; + int res; + + if (!pmu) + return NULL; + + buf = malloc(ID_SIZE); + if (!buf) + return NULL; + + /* read id */ + res = _get_cpuid(buf, ID_SIZE); + if (res) { + pr_err("failed to get cpuid string for PMU %s\n", pmu->name); + free(buf); + buf = NULL; + } + + return buf; +} \ No newline at end of file From patchwork Tue Nov 9 10:25:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm/Do28gTcOhcmlvIERvbWluZ29z?= X-Patchwork-Id: 12610387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2EB8EC433F5 for ; Tue, 9 Nov 2021 10:34:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D072B6115B for ; Tue, 9 Nov 2021 10:34:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D072B6115B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XSyMWrfdNiW+b+Q0wDy8zsMMiRP78a4pA6Ats36aqY4=; b=jME7Tsi0haoMTJ M8bCpVjwwY6oDhFGzLSoVfOdz5TE9EKw3/2TrZRHPDuUWiYwUCLy+CQJAcSgIDUl+hQ1ezb9R/Xyq KKe/+OWq3ckVSY6quWrrCVwTnnq9G/s53FkAD0qOb8LMfAUVkNbrYquXGOBsivy0ppr7lySDD9hMg bdpO5GIZU3Tq/smThQWTXV2Qui0AKrqulPme6imP4hf17NMPvQeRwKtSs3IwW8xMgMu9YJ0cTqgaZ mL4Ew4IWL9lspjiKn8hbhdM5YQlDF5A90kHEejxFK5SDUCQsF/CEmDBCxcOw3PKxAFBfute+KiekP eaauVQOb/cmyjkZS7wgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkOSF-001YiE-1K; Tue, 09 Nov 2021 10:34:15 +0000 Received: from smtp1.tecnico.ulisboa.pt ([2001:690:2100:1::15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkORs-001YaK-LS for linux-riscv@lists.infradead.org; Tue, 09 Nov 2021 10:33:58 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id 4620F600542B; Tue, 9 Nov 2021 10:26:00 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.11.0 (20160426) (Debian) at tecnico.ulisboa.pt Received: from smtp1.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp1.tecnico.ulisboa.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id hnrB0xPeHVIE; Tue, 9 Nov 2021 10:25:57 +0000 (WET) Received: from mail2.tecnico.ulisboa.pt (mail2.ist.utl.pt [193.136.128.12]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTPS id AA6166005C39; Tue, 9 Nov 2021 10:25:57 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tecnico.ulisboa.pt; s=mail; t=1636453557; bh=nwXJSM4wunq2bwnbpV9zr1hdbtnfGoDzz2gci2CRIiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PlISkIPuhOWaNZ+2NY03eUlT41ab/DOTXb1/E/AUtjBV9wxqS3SlxHEFJxfEPSg68 s8n9+UkF2CaWno9o25MhZtKjAyGO3Wix3vFFjqg6Xl4ryjZrWwyJy/BXRufGaAeE+c x6ECIwSYYKV+E7Uc9XcImVJtAfab8qV7c1eKroS0= Received: from localhost.localdomain (unknown [IPv6:2001:8a0:fa2d:4500:215:5dff:fe40:101]) (Authenticated sender: ist181713) by mail2.tecnico.ulisboa.pt (Postfix) with ESMTPSA id 80CB456007A; Tue, 9 Nov 2021 10:25:57 +0000 (WET) From: =?utf-8?b?Sm/Do28gTcOhcmlvIERvbWluZ29z?= To: palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu Cc: atish.patra@wdc.com, anup.patel@wdc.com, linux-riscv@lists.infradead.org Subject: [PATCH 3/4] RISC-V: Added generic pmu-events mapfile Date: Tue, 9 Nov 2021 10:25:54 +0000 Message-Id: <20211109102555.16381-4-joao.mario@tecnico.ulisboa.pt> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109102555.16381-1-joao.mario@tecnico.ulisboa.pt> References: <20211109102555.16381-1-joao.mario@tecnico.ulisboa.pt> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_023352_948524_F5C91C4A X-CRM114-Status: GOOD ( 11.77 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The pmu-events now supports custom events for RISC-V, plus the cycle, time and instret events were defined. Signed-off-by: João Mário Domingos --- tools/perf/pmu-events/arch/riscv/mapfile.csv | 14 +++++++++++++ .../pmu-events/arch/riscv/riscv-generic.json | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tools/perf/pmu-events/arch/riscv/mapfile.csv create mode 100644 tools/perf/pmu-events/arch/riscv/riscv-generic.json diff --git a/tools/perf/pmu-events/arch/riscv/mapfile.csv b/tools/perf/pmu-events/arch/riscv/mapfile.csv new file mode 100644 index 000000000000..6a1ab4209334 --- /dev/null +++ b/tools/perf/pmu-events/arch/riscv/mapfile.csv @@ -0,0 +1,14 @@ +# Format: +# MIDR,Version,JSON/file/pathname,Type +# +# where +# MIDR Processor version +# Variant[23:20] and Revision [3:0] should be zero. +# Version could be used to track version of of JSON file +# but currently unused. +# JSON/file/pathname is the path to JSON file, relative +# to tools/perf/pmu-events/arch/riscv/. +# Type is core, uncore etc +# +# +#Family-model,Version,Filename,EventType diff --git a/tools/perf/pmu-events/arch/riscv/riscv-generic.json b/tools/perf/pmu-events/arch/riscv/riscv-generic.json new file mode 100644 index 000000000000..013e50efad99 --- /dev/null +++ b/tools/perf/pmu-events/arch/riscv/riscv-generic.json @@ -0,0 +1,20 @@ +[ + { + "PublicDescription": "CPU Cycles", + "EventCode": "0x00", + "EventName": "riscv_cycles", + "BriefDescription": "CPU cycles RISC-V generic counter" + }, + { + "PublicDescription": "CPU Time", + "EventCode": "0x01", + "EventName": "riscv_time", + "BriefDescription": "CPU time RISC-V generic counter" + }, + { + "PublicDescription": "CPU Instructions", + "EventCode": "0x02", + "EventName": "riscv_instret", + "BriefDescription": "CPU retired instructions RISC-V generic counter" + } +] \ No newline at end of file From patchwork Tue Nov 9 10:25:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm/Do28gTcOhcmlvIERvbWluZ29z?= X-Patchwork-Id: 12610379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70E90C433F5 for ; Tue, 9 Nov 2021 10:32:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B26A610F8 for ; Tue, 9 Nov 2021 10:32:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1B26A610F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=tecnico.ulisboa.pt Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eg2hbqzSdzere7V4ZE1UFNTDP5VJYIICPQSpPShSDTI=; b=lt9BNEv4/rsDq1 JOMXDCAl7c9s9klpe8hckJ4FvLVAdKDSRPIwUWi6v35FchmdcxEiMIfx5OFciYSJUUAAhmEtpwVMY CjgXL1Zv79meC0QObvohbZ14RHPFB95/5MgB0H1PzdGuHq3OnWcHNz4IQnn0FFLDkTO841tEkeDrC s+FcqeL8noq9rvlf4//IosHPKAAU/7HJReHKYnAF2B7WzXyXZ9u1NQJ63Tlk5ipAjpGKQkVFh1ozj AJSfzbNPcMxNwuTy3uuJ/MJdutBZRN9YKyFj4sOdNcdhtcOSviwACcFulFGr4RvM1x0fSnfoX3mOd 7ZeONixfURK6oR3ZE3Ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkOQg-001YBu-El; Tue, 09 Nov 2021 10:32:38 +0000 Received: from smtp2.tecnico.ulisboa.pt ([2001:690:2100:1::16]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkOQZ-001Y98-Qm for linux-riscv@lists.infradead.org; Tue, 09 Nov 2021 10:32:35 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.tecnico.ulisboa.pt (Postfix) with ESMTP id 620933808B9; Tue, 9 Nov 2021 10:26:01 +0000 (WET) X-Virus-Scanned: by amavisd-new-2.11.0 (20160426) (Debian) at tecnico.ulisboa.pt Received: from smtp2.tecnico.ulisboa.pt ([127.0.0.1]) by localhost (smtp2.tecnico.ulisboa.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id 7mmrgpLsOiqQ; Tue, 9 Nov 2021 10:25:58 +0000 (WET) Received: from mail2.tecnico.ulisboa.pt (mail2.ist.utl.pt [193.136.128.12]) by smtp2.tecnico.ulisboa.pt (Postfix) with ESMTPS id D1A9838077E; Tue, 9 Nov 2021 10:25:57 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tecnico.ulisboa.pt; s=mail; t=1636453557; bh=5UcxturWN+QRbmvoQwFUQN52emapOjM/n81I8bBKJqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V7tn6HOtGMMQz8pEibjlXoP+FMw9UlQlCkZIwj0d8Rz7v+8PsGND3nuzS/EAskR8Z MiP39ahYqtNpEuPOVBRj6Y6Q0nGvh+giXmPtBo/8XcDLIBAG/rDXj0FZ26VACLi6gP ctJEE2xoyQr7tpd7RFpEQTev8r2Xo09667dSitu4= Received: from localhost.localdomain (unknown [IPv6:2001:8a0:fa2d:4500:215:5dff:fe40:101]) (Authenticated sender: ist181713) by mail2.tecnico.ulisboa.pt (Postfix) with ESMTPSA id A34C3560087; Tue, 9 Nov 2021 10:25:57 +0000 (WET) From: =?utf-8?b?Sm/Do28gTcOhcmlvIERvbWluZ29z?= To: palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu Cc: atish.patra@wdc.com, anup.patel@wdc.com, linux-riscv@lists.infradead.org Subject: [PATCH 4/4] RISC-V: Added HiFive Unmatched PMU events Date: Tue, 9 Nov 2021 10:25:55 +0000 Message-Id: <20211109102555.16381-5-joao.mario@tecnico.ulisboa.pt> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211109102555.16381-1-joao.mario@tecnico.ulisboa.pt> References: <20211109102555.16381-1-joao.mario@tecnico.ulisboa.pt> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211109_023233_196209_80E218A0 X-CRM114-Status: GOOD ( 12.65 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This patch contains all the available events for the HiFive Unmatched performance monitoring unit. Depends on patch [3], for the base mapfile.csv file. Signed-off-by: João Mário Domingos --- tools/perf/pmu-events/arch/riscv/mapfile.csv | 1 + .../arch/riscv/sifive/u74/instructions.json | 92 +++++++++++++++++++ .../arch/riscv/sifive/u74/memory.json | 32 +++++++ .../arch/riscv/sifive/u74/microarch.json | 57 ++++++++++++ 4 files changed, 182 insertions(+) create mode 100644 tools/perf/pmu-events/arch/riscv/sifive/u74/instructions.json create mode 100644 tools/perf/pmu-events/arch/riscv/sifive/u74/memory.json create mode 100644 tools/perf/pmu-events/arch/riscv/sifive/u74/microarch.json diff --git a/tools/perf/pmu-events/arch/riscv/mapfile.csv b/tools/perf/pmu-events/arch/riscv/mapfile.csv index 6a1ab4209334..9e540938a8cf 100644 --- a/tools/perf/pmu-events/arch/riscv/mapfile.csv +++ b/tools/perf/pmu-events/arch/riscv/mapfile.csv @@ -12,3 +12,4 @@ # # #Family-model,Version,Filename,EventType +0x48980072018,v1,sifive/u74,core diff --git a/tools/perf/pmu-events/arch/riscv/sifive/u74/instructions.json b/tools/perf/pmu-events/arch/riscv/sifive/u74/instructions.json new file mode 100644 index 000000000000..5eab718c9256 --- /dev/null +++ b/tools/perf/pmu-events/arch/riscv/sifive/u74/instructions.json @@ -0,0 +1,92 @@ +[ + { + "EventName": "EXCEPTION_TAKEN", + "EventCode": "0x0000100", + "BriefDescription": "Exception taken" + }, + { + "EventName": "INTEGER_LOAD_RETIRED", + "EventCode": "0x0000200", + "BriefDescription": "Integer load instruction retired" + }, + { + "EventName": "INTEGER_STORE_RETIRED", + "EventCode": "0x0000400", + "BriefDescription": "Integer store instruction retired" + }, + { + "EventName": "ATOMIC_MEMORY_RETIRED", + "EventCode": "0x0000800", + "BriefDescription": "Atomic memory operation retired" + }, + { + "EventName": "SYSTEM_INSTRUCTION_RETIRED", + "EventCode": "0x0001000", + "BriefDescription": "System instruction retired" + }, + { + "EventName": "INTEGER_ARITHMETIC_RETIRED", + "EventCode": "0x0002000", + "BriefDescription": "Integer arithmetic instruction retired" + }, + { + "EventName": "CONDITIONAL_BRANCH_RETIRED", + "EventCode": "0x0004000", + "BriefDescription": "Conditional branch retired" + }, + { + "EventName": "JAL_INSTRUCTION_RETIRED", + "EventCode": "0x0008000", + "BriefDescription": "JAL instruction retired" + }, + { + "EventName": "JALR_INSTRUCTION_RETIRED", + "EventCode": "0x0010000", + "BriefDescription": "JALR instruction retired" + }, + { + "EventName": "INTEGER_MULTIPLICATION_RETIRED", + "EventCode": "0x0020000", + "BriefDescription": "Integer multiplication instruction retired" + }, + { + "EventName": "INTEGER_DIVISION_RETIRED", + "EventCode": "0x0040000", + "BriefDescription": "Integer division instruction retired" + }, + { + "EventName": "FP_LOAD_RETIRED", + "EventCode": "0x0080000", + "BriefDescription": "Floating-point load instruction retired" + }, + { + "EventName": "FP_STORE_RETIRED", + "EventCode": "0x0100000", + "BriefDescription": "Floating-point store instruction retired" + }, + { + "EventName": "FP_ADDITION_RETIRED", + "EventCode": "0x0200000", + "BriefDescription": "Floating-point addition retired" + }, + { + "EventName": "FP_MULTIPLICATION_RETIRED", + "EventCode": "0x0400000", + "BriefDescription": "Floating-point multiplication retired" + }, + { + "EventName": "FP_FUSEDMADD_RETIRED", + "EventCode": "0x0800000", + "BriefDescription": "Floating-point fused multiply-add retired" + }, + { + "EventName": "FP_DIV_SQRT_RETIRED", + "EventCode": "0x1000000", + "BriefDescription": "Floating-point division or square-root retired" + }, + { + "EventName": "OTHER_FP_RETIRED", + "EventCode": "0x2000000", + "BriefDescription": "Other floating-point instruction retired" + } +] \ No newline at end of file diff --git a/tools/perf/pmu-events/arch/riscv/sifive/u74/memory.json b/tools/perf/pmu-events/arch/riscv/sifive/u74/memory.json new file mode 100644 index 000000000000..be1a46312ac3 --- /dev/null +++ b/tools/perf/pmu-events/arch/riscv/sifive/u74/memory.json @@ -0,0 +1,32 @@ +[ + { + "EventName": "ICACHE_RETIRED", + "EventCode": "0x0000102", + "BriefDescription": "Instruction cache miss" + }, + { + "EventName": "DCACHE_MISS_MMIO_ACCESSES", + "EventCode": "0x0000202", + "BriefDescription": "Data cache miss or memory-mapped I/O access" + }, + { + "EventName": "DCACHE_WRITEBACK", + "EventCode": "0x0000402", + "BriefDescription": "Data cache write-back" + }, + { + "EventName": "INST_TLB_MISS", + "EventCode": "0x0000802", + "BriefDescription": "Instruction TLB miss" + }, + { + "EventName": "DATA_TLB_MISS", + "EventCode": "0x0001002", + "BriefDescription": "Data TLB miss" + }, + { + "EventName": "UTLB_MISS", + "EventCode": "0x0002002", + "BriefDescription": "UTLB miss" + } +] \ No newline at end of file diff --git a/tools/perf/pmu-events/arch/riscv/sifive/u74/microarch.json b/tools/perf/pmu-events/arch/riscv/sifive/u74/microarch.json new file mode 100644 index 000000000000..50ffa55418cb --- /dev/null +++ b/tools/perf/pmu-events/arch/riscv/sifive/u74/microarch.json @@ -0,0 +1,57 @@ +[ + { + "EventName": "ADDRESSGEN_INTERLOCK", + "EventCode": "0x0000101", + "BriefDescription": "Address-generation interlock" + }, + { + "EventName": "LONGLAT_INTERLOCK", + "EventCode": "0x0000201", + "BriefDescription": "Long-latency interlock" + }, + { + "EventName": "CSR_READ_INTERLOCK", + "EventCode": "0x0000401", + "BriefDescription": "CSR read interlock" + }, + { + "EventName": "ICACHE_ITIM_BUSY", + "EventCode": "0x0000801", + "BriefDescription": "Instruction cache/ITIM busy" + }, + { + "EventName": "DCACHE_DTIM_BUSY", + "EventCode": "0x0001001", + "BriefDescription": "Data cache/DTIM busy" + }, + { + "EventName": "BRANCH_DIRECTION_MISPREDICTION", + "EventCode": "0x0002001", + "BriefDescription": "Branch direction misprediction" + }, + { + "EventName": "BRANCH_TARGET_MISPREDICTION", + "EventCode": "0x0004001", + "BriefDescription": "Branch/jump target misprediction" + }, + { + "EventName": "PIPE_FLUSH_CSR_WRITE", + "EventCode": "0x0008001", + "BriefDescription": "Pipeline flush from CSR write" + }, + { + "EventName": "PIPE_FLUSH_OTHER_EVENT", + "EventCode": "0x0010001", + "BriefDescription": "Pipeline flush from other event" + }, + { + "EventName": "INTEGER_MULTIPLICATION_INTERLOCK", + "EventCode": "0x0020001", + "BriefDescription": "Integer multiplication interlock" + }, + { + "EventName": "FP_INTERLOCK", + "EventCode": "0x0040001", + "BriefDescription": "Floating-point interlock" + } +] \ No newline at end of file