Applies the controls on a best-effort basis: a control that cannot be set is warned about, never fatal.
()
| 32 | /// Applies the controls on a best-effort basis: a control that cannot be |
| 33 | /// set is warned about, never fatal. |
| 34 | pub fn apply() -> Option<Self> { |
| 35 | // Blocking the run on an interactive password prompt would be worse than |
| 36 | // measuring without the knobs. |
| 37 | if !can_elevate_without_prompt() { |
| 38 | warn!( |
| 39 | "Cannot elevate privileges without a password prompt, skipping kernel memory tunables" |
| 40 | ); |
| 41 | return None; |
| 42 | } |
| 43 | |
| 44 | start_group!("Applying kernel memory tunables"); |
| 45 | let tunables = Self { |
| 46 | thp: Self::set_thp_enabled("never"), |
| 47 | swap: Self::disable_swap(), |
| 48 | }; |
| 49 | // After swapoff: faulting the swapped-out pages back in dirties the cache. |
| 50 | Self::drop_page_cache(); |
| 51 | end_group!(); |
| 52 | |
| 53 | Some(tunables) |
| 54 | } |
| 55 | |
| 56 | /// Drops the page cache. Nothing to restore: the node is a write-only |
| 57 | /// trigger and the kernel refills the cache on demand. |
nothing calls this directly
no test coverage detected