If, like me, you have a newer Intel hybrid CPU, with P-Cores and E-Cores, you may hit an issue running rr in Linux to debug things. Here is how to solve it.
If you haven’t used it before, and you are used to using gdb to debug, you should definitely try out rr. You basically record the execution of a binary and then can debug at any point in time of that execution. You can even walk backwards through the execution. Detail can be found at https://rr-project.org/.
The crux of the problem comes down to not all of the cores supporting a required feature. When running rr record you get:
Got 0 branch events, expected at least 500.
The hardware performance counter seems to not be working. Check
that hardware performance counters are working by running
perf stat -e r5111c4 true
and checking that it reports a nonzero number of events.
If performance counters seem to be working with 'perf', file an
rr issue, otherwise check your hardware/OS/VM configuration. Also
check that other software is not using performance counters on
this CPU. This problem has been described in the bug tracker, but to date, there is no real fix. There is, however, a workaround.
Basically, you need to pin rr so that it only runs on the P-Cores of the CPU. You can do this by creating the following script and calling it pcores. This is also found in the source repository of rr:
#!/usr/bin/env bash
# Runs a process on just the p-cores in the system
set -eu
pcores="$(cat /sys/devices/cpu_core/cpus)"
taskset -c "$pcores" "$@"
If you put this in your path, you can now run rr using:
pcores rr record <exec> With that, everything should be good to go again!
Back in the 80s and early 90s, when games often came on floppy disks, the…
A while back I built a 486-based machine to play with some late 80s /…
I managed to score an Amiga 600 motherboard which was faulty for £41. This weekend…
I recently repaired an Amiga 1200 with a difficult to find fault. Unfortunately, it came…
I often see on places such as Facebook that an Amiga owner will show a…
I have been a full time KDE Plasma user for quite a while now. Whilst…