(&mut self)
| 120 | |
| 121 | impl Drop for MemoryTunables { |
| 122 | fn drop(&mut self) { |
| 123 | if self.thp.is_empty() && self.swap.is_empty() { |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | start_group!("Restoring kernel memory tunables"); |
| 128 | // `swapon -a` would only cover the areas listed in /etc/fstab, so a swap |
| 129 | // file activated by hand would never come back. Restoring in the order |
| 130 | // /proc/swaps listed them also gives the areas whose priority the kernel |
| 131 | // picks back their original relative order. |
| 132 | for area in &self.swap { |
| 133 | let argv = area.swapon_argv(); |
| 134 | if let Err(error) = run_with_sudo("swapon", &argv) { |
| 135 | warn!( |
| 136 | "Failed to re-enable swap on {}, re-run manually with `sudo swapon {}`: {error}", |
| 137 | area.path, |
| 138 | argv.join(" ") |
| 139 | ); |
| 140 | } |
| 141 | } |
| 142 | for (path, value) in &self.thp { |
| 143 | if let Err(error) = write_root_file(path, value) { |
| 144 | warn!("Failed to restore transparent huge pages ({path}) to {value}: {error}"); |
| 145 | } |
| 146 | } |
| 147 | end_group!(); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | const PROC_SWAPS: &str = "/proc/swaps"; |
nothing calls this directly
no test coverage detected