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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A4AACCDB470 for ; Wed, 24 Jun 2026 07:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M0CL+kMVOC1mDF+/wqoFJ1JNaggZod6IATuEGnA4t30=; b=ci7YYRCq9AZJwF IL4pZMcIMwGbgumaaxi9PNnqz5wLWXPKEeEt8XFc/c5l3n2+US/1fbhSBmaJJas9aF/90TDqIuU7R /rUhWN1wj9WrMSViYy+rJ7ttYMbplfH+ImMCsgpFh16mQ9pV8gEk9ANleXP/f84ROuLDb18Ufmqf4 3Qa1Xw0NtMEnt3GZQ2yBI8R9b+lE068slosbk79HbeK7TEt3GigW0coFKGNGopmZmr9NK/GbJktm/ 3hB3GqmLGTxLnFDxdJ3BBZVrH8HlesrCtYztOKYeEcX9QW9ngcBLmiSXqbxqI+6tmsGvp0E/DzaSi y1jMsxn7jT3uxgAvecPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wcHao-00000007GV9-2Ncu; Wed, 24 Jun 2026 07:00:14 +0000 Received: from out-183.mta0.migadu.com ([91.218.175.183]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wcHal-00000007GTg-0M7A for linux-riscv@lists.infradead.org; Wed, 24 Jun 2026 07:00:13 +0000 Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1782284407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GLWIFVQRHB5qd32LJSyZVW2YD4K906tt2u8jGkqFmSQ=; b=GCjf4y4G2cFqF2sb9SzQPMbGZ00TV7Isvch0xHsbC0kXWXnVhyj3D0TmXGNDbN8rAgLJT/ ePYuWASdg1NFDZhlEXhW1GeGm8acBTbyUHj7wGiUqix5DPSY+wQ8QWagAXgQFz+O4qCTvm eNdJKVP7KC0FiRkQ+54md/XPjC6QTQ4= Date: Wed, 24 Jun 2026 00:00:01 -0700 MIME-Version: 1.0 Subject: Re: [PATCH v6 17/21] RISC-V: perf: Add Qemu virt machine events To: Charlie Jenkins Cc: James Clark , Rob Herring , Arnaldo Carvalho de Melo , Jiri Olsa , Will Deacon , Mark Rutland , Anup Patel , Namhyung Kim , Paul Walmsley , Krzysztof Kozlowski , Ian Rogers , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Conor Dooley , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20260608-counter_delegation-v6-0-285b72ed65a9@meta.com> <20260608-counter_delegation-v6-17-285b72ed65a9@meta.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Atish Patra In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260624_000011_415942_05CB2184 X-CRM114-Status: GOOD ( 19.83 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On 6/21/26 11:44 PM, Charlie Jenkins wrote: > On Mon, Jun 08, 2026 at 11:01:31PM -0700, Atish Patra wrote: >> From: Atish Patra >> >> Qemu virt machine supports a very minimal set of legacy perf events. >> Add them to the vendor table so that users can use them when >> counter delegation is enabled. >> >> Signed-off-by: Atish Patra >> --- >> arch/riscv/include/asm/vendorid_list.h | 4 ++++ >> drivers/perf/riscv_pmu_sbi.c | 36 ++++++++++++++++++++++++++++++++++ >> 2 files changed, 40 insertions(+) >> >> diff --git a/arch/riscv/include/asm/vendorid_list.h b/arch/riscv/include/asm/vendorid_list.h >> index 7f5030ee1fcf..603aa2b21c0b 100644 >> --- a/arch/riscv/include/asm/vendorid_list.h >> +++ b/arch/riscv/include/asm/vendorid_list.h >> @@ -11,4 +11,8 @@ >> #define SIFIVE_VENDOR_ID 0x489 >> #define THEAD_VENDOR_ID 0x5b7 >> >> +#define QEMU_VIRT_VENDOR_ID 0x000 >> +#define QEMU_VIRT_IMPL_ID 0x000 >> +#define QEMU_VIRT_ARCH_ID 0x000 > Palmer proposed a change to this a while ago to set the archid for qemu > as 42 but it looks like it was never merged in qemu, but it was merged > into the riscv spec. > > Here is the spec PR: https://github.com/riscv/riscv-isa-manual/pull/1213 > Here is the current spec: https://github.com/riscv/riscv-isa-manual/blob/main/marchid.md > Here is the QEMU patch: https://lore.kernel.org/all/20240131182430.20174-1-palmer@rivosinc.com/ > > Should we follow up with this/maybe this should be accounted for here as > an alternate id? Ahh yes. I remember that thread now. Thanks for digging this. Yes. We should resurrect that patch and use that archid as an alternate ID. > - Charlie > >> + >> #endif >> diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c >> index 00b84b28117a..74acac54328e 100644 >> --- a/drivers/perf/riscv_pmu_sbi.c >> +++ b/drivers/perf/riscv_pmu_sbi.c >> @@ -26,6 +26,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -453,7 +454,42 @@ struct riscv_vendor_pmu_events { >> .hw_event_map = _hw_event_map, .cache_event_map = _cache_event_map, \ >> .attrs_events = _attrs }, >> >> +/* QEMU virt PMU events */ >> +static const struct riscv_pmu_event qemu_virt_hw_event_map[PERF_COUNT_HW_MAX] = { >> + PERF_MAP_ALL_UNSUPPORTED, >> + [PERF_COUNT_HW_CPU_CYCLES] = {0x01, 0xFFFFFFF8}, >> + [PERF_COUNT_HW_INSTRUCTIONS] = {0x02, 0xFFFFFFF8} >> +}; >> + >> +static const struct riscv_pmu_event qemu_virt_cache_event_map[PERF_COUNT_HW_CACHE_MAX] >> + [PERF_COUNT_HW_CACHE_OP_MAX] >> + [PERF_COUNT_HW_CACHE_RESULT_MAX] = { >> + PERF_CACHE_MAP_ALL_UNSUPPORTED, >> + [C(DTLB)][C(OP_READ)][C(RESULT_MISS)] = {0x10019, 0xFFFFFFF8}, >> + [C(DTLB)][C(OP_WRITE)][C(RESULT_MISS)] = {0x1001B, 0xFFFFFFF8}, >> + >> + [C(ITLB)][C(OP_READ)][C(RESULT_MISS)] = {0x10021, 0xFFFFFFF8}, >> +}; >> + >> +RVPMU_EVENT_CMASK_ATTR(cycles, cycles, 0x01, 0xFFFFFFF8); >> +RVPMU_EVENT_CMASK_ATTR(instructions, instructions, 0x02, 0xFFFFFFF8); >> +RVPMU_EVENT_CMASK_ATTR(dTLB-load-misses, dTLB_load_miss, 0x10019, 0xFFFFFFF8); >> +RVPMU_EVENT_CMASK_ATTR(dTLB-store-misses, dTLB_store_miss, 0x1001B, 0xFFFFFFF8); >> +RVPMU_EVENT_CMASK_ATTR(iTLB-load-misses, iTLB_load_miss, 0x10021, 0xFFFFFFF8); >> + >> +static struct attribute *qemu_virt_event_group[] = { >> + RVPMU_EVENT_ATTR_PTR(cycles), >> + RVPMU_EVENT_ATTR_PTR(instructions), >> + RVPMU_EVENT_ATTR_PTR(dTLB_load_miss), >> + RVPMU_EVENT_ATTR_PTR(dTLB_store_miss), >> + RVPMU_EVENT_ATTR_PTR(iTLB_load_miss), >> + NULL, >> +}; >> + >> static struct riscv_vendor_pmu_events pmu_vendor_events_table[] = { >> + RISCV_VENDOR_PMU_EVENTS(QEMU_VIRT_VENDOR_ID, QEMU_VIRT_ARCH_ID, QEMU_VIRT_IMPL_ID, >> + qemu_virt_hw_event_map, qemu_virt_cache_event_map, >> + qemu_virt_event_group) >> }; >> >> static const struct riscv_pmu_event *current_pmu_hw_event_map; >> >> -- >> 2.53.0-Meta >> >> _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv