# One-time perf setup (needs sudo)

`perf` is not installed and kernel profiling is currently locked down
(`perf_event_paranoid = 4`). Run these once, then tell me and I'll run `profile.sh`.

## 1. Install perf

```bash
sudo apt-get update
sudo apt-get install -y linux-tools-generic linux-tools-5.15.0-185-generic
```

If the version-specific package can't be found, try the running-kernel form:

```bash
sudo apt-get install -y "linux-tools-$(uname -r)" linux-tools-generic
```

Verify:

```bash
perf --version
```

## 2. Allow user-space profiling

```bash
sudo sysctl kernel.perf_event_paranoid=1
sudo sysctl kernel.kptr_restrict=0
```

(These reset on reboot. To persist, add `kernel.perf_event_paranoid=1` and
`kernel.kptr_restrict=0` to `/etc/sysctl.conf`.)

Verify (must be <= 2):

```bash
cat /proc/sys/kernel/perf_event_paranoid
```

## 3. FlameGraph

No action needed — `profile.sh` clones
`https://github.com/brendangregg/FlameGraph` automatically (no sudo).

---

Once `perf --version` works and `perf_event_paranoid <= 2`, run:

```bash
./profile.sh
```
