Skip to content

Commit

Permalink
lockstat: fix numerical output rounding error
Browse files Browse the repository at this point in the history
Fix rounding error in /proc/lock_stat numerical output.

On occasion the two digit fractional part contains the three
digit value '100'.  This is due to a bug in the rounding algorithm
which pushes values in the range '95..99' to '100' rather than
to '00' + an increment to the integer part.  For example,

	- 123456.100      old display
	+ 123457.00	  new display

Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Joe Korty authored and Ingo Molnar committed Aug 26, 2008
1 parent 83097ac commit 2189459
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/lockdep_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ static void snprint_time(char *buf, size_t bufsiz, s64 nr)
{
unsigned long rem;

nr += 5; /* for display rounding */
rem = do_div(nr, 1000); /* XXX: do_div_signed */
snprintf(buf, bufsiz, "%lld.%02d", (long long)nr, ((int)rem+5)/10);
snprintf(buf, bufsiz, "%lld.%02d", (long long)nr, (int)rem/10);
}

static void seq_time(struct seq_file *m, s64 time)
Expand Down

0 comments on commit 2189459

Please sign in to comment.