Skip to content

Commit

Permalink
Auto merge of #7803 - alexcrichton:less-overflow, r=Eh2406
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jan 15, 2020
2 parents c22380d + 4c665c0 commit 4e0d2f1
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 4e0d2f1

Please sign in to comment.