Hello,
I have been trying to get perf to show more events than ‘instructions’ and ‘cycles’ but am having some trouble.
There has been success in doing this as seen in this post ( U740 Hardware Perfomance Monitor support for Linux perf ), but I am running into issues when applying the patches provided.
I have built the patched openSBI and can see it being used via the bootlogs, but now when I run a command like ‘perf stat -e cycles sleep 1’ the kernel panics with from an illegal instruction (see below). Could this be due to me being on the RevB version of the board?
I am using the Ubuntu 24.04.3 LTS image, and I see ‘SBI PMU extension is available’ in the boot logs so I assume the suggested Linux PMU patch made it upstream.
More info:
OS: Ubuntu 24.04, 6.14.0-33-generic
Board: SiFive HiFive Unmatched RevB
Any advice on solving this or guidance on other approaches would be much appreciated
Full Panic Message from “perf stat -e cycles sleep 1“:
[ 113.219721] Oops - illegal instruction [#1]
[ 113.219742] Modules linked in: qrtr cfg80211 ofpart cmdlinepart spi_norda9063_onkey mtd lm90 at24 leds_pwm pwm_sifive binfmt_misc leds_pwm_multicolorled_class_multicolor nls_iso8859_1 sch_fq_codel dm_multipath efi_pstorenfnetlink dmi_sysfs ip_tables x_tables autofs4 btrfs blake2b_generic raid10raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pqraid1 raid0 linear nvme nvme_core nvme_auth mscc macsec rtc_da9063da9063_regulator macb mmc_spi crc7 phylink of_mmc_spi crc_itu_t i2c_ocoresspi_sifive uio_pdrv_genirq uio
[ 113.219906] CPU: 2 UID: 1000 PID: 874 Comm: sleep Not tainted 6.14.0-33-generic#33.1~24.04.1-Ubuntu
[ 113.219916] Hardware name: sifive SiFive HiFive Unmatched A00/SiFive HiFiveUnmatched A00, BIOS 2025.10-00784-gf17f11880a16 10/01/2025
[ 113.219923] epc : csr_read_num+0x1ba/0x1c0
[ 113.219952] ra : riscv_pmu_ctr_read_csr+0x2e/0x52
[ 113.219964] epc : ffffffff80af4fba ra : ffffffff80af52f6 sp : ffffffc6010337c0
[ 113.219970] gp : ffffffff825a8e90 tp : ffffffd6893a8000 t0 :0000000000000000
[ 113.219975] t1 : 0000000000000000 t2 : 0000000000000000 s0 :ffffffc6010337d0
[ 113.219980] s1 : 8000000000000001 a0 : 0000000000000c00 a1 :0000000000000000
[ 113.219985] a2 : 0000000000000000 a3 : 0000000000000000 a4 :ffffffff8169b668
[ 113.219990] a5 : ffffffff80af4fba a6 : 0000000000000000 a7 :0000000000000000
[ 113.219995] s2 : ffffffd687361b98 s3 : ffffffd6873619b0 s4 :ffffffd6880e7600
[ 113.220001] s5 : ffffffffffffffff s6 : ffffffd680992080 s7 :0000000000002001
[ 113.220006] s8 : 0000003a19150d08 s9 : 0000003a19151008 s10:0000002f954fa9e3
[ 113.220011] s11: 0000000000000000 t3 : 0000000000000000 t4 :0000000000000000
[ 113.220016] t5 : 0000000000000000 t6 : 0000000000000000
[ 113.220020] status: 0000000200000100 badaddr: 00000000c0002573 cause:0000000000000002
[ 113.220027] [<ffffffff80af4fba>] csr_read_num+0x1ba/0x1c0
[ 113.220039] [<ffffffff80af52f6>] riscv_pmu_ctr_read_csr+0x2e/0x52
[ 113.220050] [<ffffffff80af5ed0>] pmu_sbi_ctr_read+0x56/0xd0
[ 113.220061] [<ffffffff80af53d0>] riscv_pmu_event_update+0x64/0xc2
[ 113.220072] [<ffffffff80af5460>] riscv_pmu_stop+0x32/0x56
[ 113.220081] [<ffffffff80af54b8>] riscv_pmu_del+0x34/0x82
[ 113.220091] [<ffffffff802321e2>] event_sched_out+0x9c/0x14e
[ 113.220110] [<ffffffff802322cc>] group_sched_out+0x38/0x74
[ 113.220120] [<ffffffff802323f4>] __pmu_ctx_sched_out+0xec/0x160
[ 113.220131] [<ffffffff80232580>] ctx_sched_out+0x118/0x1a4
[ 113.220141] [<ffffffff8023263c>] task_ctx_sched_out+0x30/0x5c
[ 113.220150] [<ffffffff80233928>] perf_event_context_sched_out+0x180/0x2be
[ 113.220162] [<ffffffff8023550c>] __perf_event_task_sched_out+0x4c/0xca
[ 113.220170] [<ffffffff80071f3a>] perf_event_task_sched_out+0xde/0xf8
[ 113.220191] [<ffffffff80075032>] prepare_task_switch+0x6a/0x1d6
[ 113.220202] [<ffffffff80d66dba>] __schedule+0x1a8/0x610
[ 113.220212] [<ffffffff80d67244>] schedule+0x22/0xc0
[ 113.220218] [<ffffffff80d6c722>] do_nanosleep+0x3e/0x11a
[ 113.220232] [<ffffffff80106f0a>] hrtimer_nanosleep+0x96/0x14c
[ 113.220245] [<ffffffff8010e438>] common_nsleep+0x36/0x52
[ 113.220263] [<ffffffff8010f36c>] __riscv_sys_clock_nanosleep+0xb8/0x11e
[ 113.220272] [<ffffffff80d63718>] do_trap_ecall_u+0x9a/0x1ee
[ 113.220289] [<ffffffff80d6f7dc>] handle_exception+0x150/0x15c
[ 113.220313] Code: b579 2573 c030 b561 2573 c020 b549 2573 c010 bdb5 (2573) c000
[ 113.220325] ---[ end trace 0000000000000000 ]---
[ 113.220331] Kernel panic - not syncing: Fatal exception in interrupt
[ 113.220338] SMP: stopping secondary CPUs
[ 113.220354] Kernel Offset: 0x0 from 0xffffffff80000000
[ 113.546535] ---[ end Kernel panic - not syncing: Fatal exception in interrupt]---