lockstat: fix numerical output rounding error
authorJoe Korty <joe.korty@ccur.com>
Mon, 25 Aug 2008 21:15:33 +0000 (17:15 -0400)
committerIngo Molnar <mingo@elte.hu>
Tue, 26 Aug 2008 08:37:46 +0000 (10:37 +0200)
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 <mingo@elte.hu>
kernel/lockdep_proc.c

index 4b194d3..20dbcbf 100644 (file)
@@ -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)