Skip to content

Commit

Permalink
cpudist: Protect against potentially negative time deltas
Browse files Browse the repository at this point in the history
It seems from experimentation that the calculated timestamps between
on- and off-CPU switch events can produce incorrect results, with a
later event having a smaller timestamp. Discard events when the
resulting delta time would be negative.
  • Loading branch information
goldshtn committed Jun 30, 2016
1 parent 06d90d3 commit bee8d36
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/cpudist.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
if (tsp == 0)
return;
if (ts < *tsp) {
// Probably a clock issue where the recorded on-CPU event had a
// timestamp later than the recorded off-CPU event, or vice versa.
return;
}
u64 delta = ts - *tsp;
FACTOR
STORE
Expand Down

0 comments on commit bee8d36

Please sign in to comment.