Linux

Using rr On Newer Intel CPUs

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.

About rr

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 Problem

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.

The 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!

LinuxJedi

Share
Published by
LinuxJedi

Recent Posts

The Legend Continues: Amiga 1000 Keyboard Revival

I have restored the boxed Amiga 1000 main unit and the mice that came with…

7 days ago

Amiga 4000 Repair: This one was just weird

I was recently sent an Amiga 4000 motherboard repair. It should have been quite straightforward,…

1 week ago

Unboxing the Legend Continues: Amiga 1000 Mouse Restoration.

I recently received a boxed Amiga 1000 which was in excellent condition, but required a…

2 weeks ago

Unboxing a Legend: Amiga 1000

I have a local friend who is a private collector of vintage computers and consoles,…

3 weeks ago

Amiga 4000 With Lots of Little Problems

I’ve had a few people send me things in to repair lately. Amongst these was…

2 months ago

Amiga A3640 CPU Card Repair

Lately, I've been very busy, but haven't had many interesting things to blog about happen.…

3 months ago