From 4c665c0ecde88c155c6b69d9ce3f5a59364fefc6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 15 Jan 2020 07:06:45 -0800 Subject: [PATCH] Don't assume iowait always increases on Linux According to [documentation] looks like this value is documented as it can decrease, so let's handle that without overflowing. [documentation]: http://man7.org/linux/man-pages/man5/proc.5.html --- src/cargo/util/cpu.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/util/cpu.rs b/src/cargo/util/cpu.rs index 6d462c231b3..5def01032d2 100644 --- a/src/cargo/util/cpu.rs +++ b/src/cargo/util/cpu.rs @@ -72,7 +72,7 @@ mod imp { let nice = next.nice - prev.nice; let system = next.system - prev.system; let idle = next.idle - prev.idle; - let iowait = next.iowait - prev.iowait; + let iowait = next.iowait.checked_sub(prev.iowait).unwrap_or(0); let irq = next.irq - prev.irq; let softirq = next.softirq - prev.softirq; let steal = next.steal - prev.steal;