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

Recent Posts

Why Recapping Isn’t Always the Cure: And Amiga 1200 Repair Story

I often see on places such as Facebook that an Amiga owner will show a…

1 day ago

KDE Plasma Automatic Time Zone

I have been a full time KDE Plasma user for quite a while now. Whilst…

4 days ago

The wolfDemo Board Story: From Idea to Reality

I work building open-source cybersecurity solutions for wolfSSL. These solutions often involve embedded environments, which…

1 week ago

Upgrading the RAM Detective: A Firmware Adventure with RAMCHECK

The firmware in my RAMCHECK is very old, there were many updates since then. Unfortunately,…

3 months ago

The Ultimate RAM Detective: Meet the Innoventions RAMCHECK

Whilst repairing vintage machines, a lot of RAM passes by my benches. Most of it…

4 months ago

Vintage Speed Demon: Fixing an ARK1000VL Graphics Card

According to some, the ARK1000VL is considered the fastest VLB graphics card chip you can…

4 months ago