Skip to content

Commit

Permalink
Don't assume iowait always increases on Linux
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexcrichton committed Jan 15, 2020
1 parent ad3dbe1 commit 4c665c0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cargo/util/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4c665c0

Please sign in to comment.