How do I set `perf_event_paranoid`?

I want to use this tool to do some profiling, and it suggests I set perf_event_paranoid to 1.

I check it on my system and it’s 2

$ cat /proc/sys/kernel/perf_event_paranoid
2

Usually there’s a nix option to set variables like this, accompanied with documentation to warn me away from dangerous settings, but a quick google for paranoid didn’t turn anything up in search.nixos.org or discourse. Does anyone know the correct option to set?

This is a kernel sysctl, which you can set here: boot.kernel.sysctl.

It’s probably best not to set it permanently unless you have to, it has security implications. Simply writing 1 to the file as suggested by that readme is the recommended way on NixOS too (note it will revert back to 2 on your next reboot).

1 Like

Example:

1 Like

Thanks for your help!