* [PATCH] lockstat - fix numerical output rounding error
@ 2008-08-25 21:15 Joe Korty
2008-08-26 8:37 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Joe Korty @ 2008-08-25 21:15 UTC (permalink / raw)
To: mingo; +Cc: linux-kernel
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
Index: 2.6.26/kernel/lockdep_proc.c
===================================================================
--- 2.6.26.orig/kernel/lockdep_proc.c 2008-07-13 17:51:29.000000000 -0400
+++ 2.6.26/kernel/lockdep_proc.c 2008-08-25 16:58:04.000000000 -0400
@@ -406,8 +406,9 @@
{
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] lockstat - fix numerical output rounding error
2008-08-25 21:15 [PATCH] lockstat - fix numerical output rounding error Joe Korty
@ 2008-08-26 8:37 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-08-26 8:37 UTC (permalink / raw)
To: Joe Korty; +Cc: linux-kernel, Peter Zijlstra
* Joe Korty <joe.korty@ccur.com> wrote:
> 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
applied to tip/core/urgent - thanks Joe!
(btw., please include Signed-off-by lines in your patches in the future)
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-26 8:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-25 21:15 [PATCH] lockstat - fix numerical output rounding error Joe Korty
2008-08-26 8:37 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox