()
| 36 | } |
| 37 | |
| 38 | pub fn ensure_linux_profiling_sysctls() -> Result<Vec<LinuxSysctl>> { |
| 39 | if !cfg!(target_os = "linux") { |
| 40 | return Ok(Vec::new()); |
| 41 | } |
| 42 | |
| 43 | let mut sysctls = Vec::new(); |
| 44 | |
| 45 | for (name, target_value) in [ |
| 46 | ("kernel.kptr_restrict", 0), |
| 47 | ("kernel.perf_event_paranoid", -1), |
| 48 | ] { |
| 49 | let sysctl = LinuxSysctl::set(name, target_value)?; |
| 50 | if sysctl.is_changed() { |
| 51 | sysctls.push(sysctl); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | Ok(sysctls) |
| 56 | } |
| 57 | |
| 58 | /// Sets a sysctl, returning the value it held before, or `None` when it was |
| 59 | /// already at `target_value` and nothing was written. |
no test coverage detected