Performance counters over Linux

It has been a few years since I looked at the perf counters, but originally linux refused to support them because there was no overflow support, which is necessary to get meaningful results over non trivial time periods. A patch set was written at WD as a proof of concept but not upstreamed. Meanwhile, a new ISA extension was created to add the missing overflow support, and that has since been reviewed and approved. But neither Unleashed nor Unmatched has the new counter overflow extension. I don’t know if the new Pro P550 does, I haven’t seen one yet. It might not as the new ISA extension is still very new, ratified Mar 28 2024 apparently.

To access the perf counters, you need patches for opensbi (which runs in M mode) to make the perf counters available to the linux kernel (which runs in S mode). Then you need linux kernel patches to make them available to user mode. It has been a few years since I last looked so there might already be patches but these patches likely won’t work on Unleashed/Unmatched because of the missing overflow support.

The missing ISA support is
https://github.com/riscv/riscv-smcdeleg-ssccfg/releases