From 57e64a0848ca63546b12159bfd29bac9897bdde2 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 11 Mar 2026 20:45:31 +0100 Subject: [PATCH] performance-metrics: Kill stale processes on test timeout When a test times out, the spawned thread containing the cloud-hypervisor child process, iperf3/ethr sub processes, and all associated resources (TAP devices, file descriptors, hugepage reservations) is abandoned without cleanup. This attaches a cleanup routine that kills cloud-hypervisor, iperf3, and ethr processes on timeout, then waits briefly for the kernel to reclaim their resources. This prevents leaked processes from interfering with subsequent tests. Removes the existing TODO comment. Signed-off-by: Anatol Belski --- performance-metrics/src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/performance-metrics/src/main.rs b/performance-metrics/src/main.rs index c48e5a906..34986395a 100644 --- a/performance-metrics/src/main.rs +++ b/performance-metrics/src/main.rs @@ -1214,7 +1214,6 @@ fn run_test_with_timeout( let _ = sender.send(output); }); - // Todo: Need to cleanup/kill all hanging child processes let test_timeout = test.calc_timeout(&test_iterations, &test_timeout); receiver .recv_timeout(Duration::from_secs(test_timeout)) @@ -1223,10 +1222,18 @@ fn run_test_with_timeout( "[Error] Test '{}' time-out after {} seconds", test.name, test_timeout ); + cleanup_stale_processes(); Error::TestTimeout })? } +fn cleanup_stale_processes() { + for proc in &["cloud-hypervisor", "iperf3", "ethr"] { + let _ = Command::new("pkill").args(["-9", "-f", proc]).status(); + } + thread::sleep(Duration::from_secs(2)); +} + fn date() -> String { let output = test_infra::exec_host_command_output("date"); String::from_utf8_lossy(&output.stdout).trim().to_string()