rr icon indicating copy to clipboard operation
rr copied to clipboard

Running on MacBook Pro, Windows 10 Bootcamp, WSL 2

Open vjpr opened this issue 3 years ago • 4 comments
trafficstars

An issue to track ability to run on Bootcamp on Apple Intel hardware.

Setup

https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-10#2-install-wsl

wsl --install -d ubuntu

Install perf

See: https://stackoverflow.com/a/65276025/130910

Test

Open PowerShell in Administrator mode.

wsl

Create a sample program to debug

multiple.c
#include <stdio.h>
#define SIZE 4

void zero(char *a, int size)
{
	while (size>0)
		a[size--] = 0; 
}

void initialize(char *a, int size)
{
	zero(a, size);
}

void multiply(char *a, int size, int mult)
{
	int i;
	for (i=0; i<size; i++)
		a[i] = i * mult;
}

void pr_array(char *a, int size)
{
	int i;
	for (i=0; i<size; i++)
		printf("f(%d)=%d\n", i, a[i]);
}

int main(int argc, char **argv)
{
	char a[SIZE];
	int mult = 2;

	initialize(a, SIZE);
	multiply(a, SIZE, mult);
	pr_array(a, SIZE);
	return 0;
}
sudo apt install gcc

gcc multiply.c -o multiply

./multiply
f(0)=0
f(1)=2
f(2)=4
f(3)=6
sudo rr record multiply

Fails to run:

[FATAL /home/roc/rr/rr/src/PerfCounters.cc:217:start_counter()] Unable to open performance counter with 'perf_event_open'; are hardware perf events available? See https://github.com/rr-debugger/rr/wiki/Will-rr-work-on-my-system

Check perf events supported

$ uname -a
Linux VMBP2019-WINBC 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ dmesg  | grep -i perf
[    0.062235] Performance Events: unsupported p6 CPU model 158 no PMU driver, software events only.

This seems to indicate that they are not.

Status

See: Support hardware performance counters - WSL2 - https://github.com/microsoft/WSL/issues/4678

Also: State of hardware performance monitoring in WSL2 - https://github.com/microsoft/WSL/issues/8480

No one seems to have got it working so far.

Potential fixes

Update custom Microsoft Linux kernel version for wsl2

5.10 to 5.15 (latest longterm - see https://www.kernel.org/)

Pending issue on wsl repo: https://github.com/microsoft/WSL/issues/8507

Doesn't seem to work

Try Windows 11

NOTE: Not compatible with Apple Intel hardware.

Doesn't seem to work

vjpr avatar Jul 16 '22 16:07 vjpr

Is this supposed to be different from normal wsl?

yuyichao avatar Jul 16 '22 16:07 yuyichao

WSL2 is an actual VM, not just a Linux/POSIX compatibility layer like WSL1 was.

You'll need WSL2 version 0.50.2 or later. If you're on Windows 10 you'll have to get that from the store IIRC. You also need to configure the VMM to enable hardware performance counters like so https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/manage/performance-monitoring-hardware

khuey avatar Jul 16 '22 19:07 khuey

FYI: Hardware counters in WSL2 just landed:

https://github.com/microsoft/WSL/issues/4678#issuecomment-1318579235

vjpr avatar Nov 17 '22 13:11 vjpr