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!
I have restored the boxed Amiga 1000 main unit and the mice that came with…
I was recently sent an Amiga 4000 motherboard repair. It should have been quite straightforward,…
I recently received a boxed Amiga 1000 which was in excellent condition, but required a…
I have a local friend who is a private collector of vintage computers and consoles,…
I’ve had a few people send me things in to repair lately. Amongst these was…
Lately, I've been very busy, but haven't had many interesting things to blog about happen.…