MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / drop

Method drop

src/executor/memory/tunables.rs:122–148  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

120
121impl 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
151const PROC_SWAPS: &str = "/proc/swaps";

Callers

nothing calls this directly

Calls 4

run_with_sudoFunction · 0.85
write_root_fileFunction · 0.85
swapon_argvMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected