From patchwork Tue Nov 16 15:48:08 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: 12622771 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 C9A19C433EF for ; Tue, 16 Nov 2021 15:48:54 +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 7461C6120F for ; Tue, 16 Nov 2021 15:48:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7461C6120F 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=51sjezSU5YXBuEbnlfbMxLCmwIE91VIkqa+ChLkX894=; b=S4wkXDWy10c7tK YEufvInUMu/xNuGvs++OzoKZqLiaPV3lYsRoASVooA6Jx7VJtR5OKGpuhLKvyLMEIOwqj2ET8IR5+ 47nFVwDX/x1Sp8XTLH06x1D1Vno0OGeDNftaPOB5lHQvh8f7zBcbBIW/3JFoVlDDDseHjkaCa8eRf jSWa2KSJtU4PVUQXc3lVD1GBzSKcVbXBnbOE0G8NxEjwcuKWFx7Rt+afuWbZClXZPgWkZQVvPLw3v Ghzx9JW4/fnLaHhQ5pi3IeJOtlVjfG/EstHrr6BkBZCD4px3EeUpjUrFURPbe8rMsdpltFLgne9s3 F99PQAMOvzJ/xxx2zcQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mn0hS-002Bkd-Ni; Tue, 16 Nov 2021 15:48:46 +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 1mn0hI-002Bej-3M for linux-riscv@lists.infradead.org; Tue, 16 Nov 2021 15:48:40 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.tecnico.ulisboa.pt (Postfix) with ESMTP id 9C9D16005C35; Tue, 16 Nov 2021 15:48:17 +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 HRaNRFfzqbmN; Tue, 16 Nov 2021 15:48:14 +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 6C3916005C2B; Tue, 16 Nov 2021 15:48:14 +0000 (WET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tecnico.ulisboa.pt; s=mail; t=1637077694; bh=b4kgQvW6iWvH+FzTaAGNQduyyzvgw1jK3C18ubEUaw0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S0tYVqqSLZaL7XRiMhgcdG9jG/2ioE6ZFgGMvXt02aUpWY7xS6yDoUGvvmhpm3tEk sGkDfHQS4Peo5oK1jjVbQJIqWQKzmSS83BpbV9TDKiC4BbT4ox8/VQX4lWOQYkZLIK n8iM2C+0YBUYR42VXX0bZB4vgqwHQsvTWpVxttSM= Received: from joaomariovmubuntu.Home (unknown [IPv6:2001:8a0:fa2d:4500:215:5dff:fe40:101]) (Authenticated sender: ist181713) by mail2.tecnico.ulisboa.pt (Postfix) with ESMTPSA id DCC93560075; Tue, 16 Nov 2021 15:48:12 +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, nikita.shubin@maquefel.me, joao.mario@tecnico.ulisboa.pt Subject: [PATCH v2 0/4] Introduce pmu-events support for HiFive Unmatched Date: Tue, 16 Nov 2021 15:48:08 +0000 Message-Id: <20211116154812.17008-1-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-20211116_074836_490774_7AFF4ED9 X-CRM114-Status: GOOD ( 13.21 ) 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 series of patches introduces support for the RISC-V PMU identification and raw events matching between perf and the PMU. The HiFive Unmatched board can now use all the counters with named events. The work in these patches is completelly and directly dependent on the proposed SBI PMU patch [4], by Atish Patra. This series has been tested in the HiFive Unmatched board. OpenSBI[1] and U-Boot[2] patches are required to test it on the board, alongside with the series of patches that introduce RISC-V Perf support with the SBI PMU and sscofpmf extension [3-4]. The U-Boot fu740 dts [5] must be updated, may be fixed in future U-BOOT versions, with the events that will be tested, this comprehends changes to the riscv,raw-event-to-mhpmcounters entry. Also, an OpenSBI patch [6] proposes bitfield awareness for the DT raw-events, this will simplify, and improve, events description in the DT file. Here is the output of perf list and perf stat with all the available unmatched events monitoring a stress-ng trignometric stressor. HiFive Unmatched: ================= perf list pmu instructions: atomic_memory_retired [Atomic memory operation retired] conditional_branch_retired [Conditional branch retired] exception_taken [Exception taken] fp_addition_retired [Floating-point addition retired] fp_div_sqrt_retired [Floating-point division or square-root retired] fp_fusedmadd_retired [Floating-point fused multiply-add retired] fp_load_retired [Floating-point load instruction retired] fp_multiplication_retired [Floating-point multiplication retired] fp_store_retired [Floating-point store instruction retired] integer_arithmetic_retired [Integer arithmetic instruction retired] integer_division_retired [Integer division instruction retired] integer_load_retired [Integer load instruction retired] integer_multiplication_retired [Integer multiplication instruction retired] integer_store_retired [Integer store instruction retired] jal_instruction_retired [JAL instruction retired] jalr_instruction_retired [JALR instruction retired] other_fp_retired [Other floating-point instruction retired] system_instruction_retired [System instruction retired] memory: data_tlb_miss [Data TLB miss] dcache_miss_mmio_accesses [Data cache miss or memory-mapped I/O access] dcache_writeback [Data cache write-back] icache_retired [Instruction cache miss] inst_tlb_miss [Instruction TLB miss] utlb_miss [UTLB miss] microarch: addressgen_interlock [Address-generation interlock] branch_direction_misprediction [Branch direction misprediction] branch_target_misprediction [Branch/jump target misprediction] csr_read_interlock [CSR read interlock] dcache_dtim_busy [Data cache/DTIM busy] fp_interlock [Floating-point interlock] icache_itim_busy [Instruction cache/ITIM busy] integer_multiplication_interlock [Integer multiplication interlock] longlat_interlock [Long-latency interlock] pipe_flush_csr_write [Pipeline flush from CSR write] pipe_flush_other_event [Pipeline flush from other event] perf stat -eexception_taken,integer_load_retired,integer_store_retired,atomic_memory_retired,system_instruction_retired,integer_arithmetic_retired,conditional_branch_retired,jal_instruction_retired,jalr_instruction_retired,integer_multiplication_retired,integer_division_retired,fp_load_retired,fp_store_retired,fp_addition_retired,fp_multiplication_retired,fp_fusedmadd_retired,fp_div_sqrt_retired,other_fp_retired,data_tlb_miss,dcache_miss_mmio_accesses,dcache_writeback,icache_retired,inst_tlb_miss,utlb_miss,addressgen_interlock,longlat_interlock,csr_read_interlock,icache_itim_busy,dcache_dtim_busy,branch_direction_misprediction,branch_target_misprediction,pipe_flush_csr_write,pipe_flush_other_event,integer_multiplication_interlock,fp_interlock stress-ng --cpu 1 --cpu-method trig -t 60s stress-ng: info: [500] setting to a 60 second run per stressor stress-ng: info: [500] dispatching hogs: 1 cpu stress-ng: info: [500] successful run completed in 60.02s (1 min, 0.02 secs) Performance counter stats for 'stress-ng --cpu 1 --cpu-method trig -t 60s': 233185 exception_taken (5.72%) 5010843878 integer_load_retired (5.73%) 4437123760 integer_store_retired (5.73%) 875636 atomic_memory_retired (5.72%) 787401517 system_instruction_retired (5.73%) 58176497169 integer_arithmetic_retired (5.74%) 9689155944 conditional_branch_retired (5.73%) 2141143732 jal_instruction_retired (5.72%) 624939326 jalr_instruction_retired (5.72%) 1900272300 integer_multiplication_retired (5.72%) 29231344 integer_division_retired (5.72%) 1672274835 fp_load_retired (5.73%) 592215149 fp_store_retired (5.73%) 13592616 fp_addition_retired (5.73%) 13597374 fp_multiplication_retired (5.72%) 1331957808 fp_fusedmadd_retired (5.72%) 592410829 fp_div_sqrt_retired (5.72%) 227334317 other_fp_retired (5.72%) 95772283 data_tlb_miss (5.72%) 6291088 dcache_miss_mmio_accesses (5.72%) 55591 dcache_writeback (5.72%) 47394708 icache_retired (5.72%) 62778259 inst_tlb_miss (5.72%) 10159938 utlb_miss (5.72%) 424446212 addressgen_interlock (5.72%) 849061809 longlat_interlock (5.72%) 0 csr_read_interlock (5.71%) 16924613138 icache_itim_busy (5.71%) 204163844 dcache_dtim_busy (5.70%) 175163620 branch_direction_misprediction (5.72%) 202874026 branch_target_misprediction (5.71%) 433228932 pipe_flush_csr_write (5.71%) 0 pipe_flush_other_event (5.71%) 429384915 integer_multiplication_interlock (5.71%) 8635530214 fp_interlock (5.71%) 60.044837787 seconds time elapsed 60.001431000 seconds user 0.033660000 seconds sys [1] https://github.com/atishp04/opensbi/tree/pmu_sscofpmf_v2 [2] https://github.com/atishp04/u-boot/tree/hifive_unmatched_dt_pmu [3] https://github.com/atishp04/linux/tree/riscv_pmu_v4 [4] http://lists.infradead.org/pipermail/linux-riscv/2021-October/009408.html [5] https://github.com/atishp04/u-boot/blob/hifive_unmatched_dt_pmu/arch/riscv/dts/fu740-c000.dtsi [6] https://patchwork.ozlabs.org/project/opensbi/patch/20211105013301.27656-1-vincent.chen@sifive.com/ Signed-off-by: João Mário Domingos This work was developed at INESC-ID, Instituto Superior Técnico, Universidade de Lisboa. Tested-by: Nikita Shubin --- Changes in v2: - Fix compilation errors and warnings - Remove space idents - Correct formatting João Mário Domingos (4): RISC-V: Create unique identification for SoC PMU RISC-V: Support CPUID for risc-v in perf RISC-V: Added generic pmu-events mapfile RISC-V: Added HiFive Unmatched PMU events arch/riscv/kernel/sbi.c | 3 + drivers/perf/riscv_pmu.c | 18 ++++ drivers/perf/riscv_pmu_sbi.c | 47 ++++++++++ tools/perf/arch/riscv/util/Build | 1 + tools/perf/arch/riscv/util/header.c | 66 +++++++++++++ tools/perf/pmu-events/arch/riscv/mapfile.csv | 15 +++ .../pmu-events/arch/riscv/riscv-generic.json | 20 ++++ .../arch/riscv/sifive/u74/instructions.json | 92 +++++++++++++++++++ .../arch/riscv/sifive/u74/memory.json | 32 +++++++ .../arch/riscv/sifive/u74/microarch.json | 57 ++++++++++++ 10 files changed, 351 insertions(+) create mode 100644 tools/perf/arch/riscv/util/header.c create mode 100644 tools/perf/pmu-events/arch/riscv/mapfile.csv create mode 100644 tools/perf/pmu-events/arch/riscv/riscv-generic.json 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