public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -rt] cycles_to_usecs rounding fix
       [not found] <20071212201258.890003246@mvista.com>
@ 2007-12-12 20:15 ` Daniel Walker
  0 siblings, 0 replies; only message in thread
From: Daniel Walker @ 2007-12-12 20:15 UTC (permalink / raw)
  To: rostedt; +Cc: mingo, linux-kernel, linux-rt-users, johnstul

do_div() rounds down, so we add have the divisor to round up. This effected my
change to preempt_max_latency. Each time you read preempt_max_latency it gets 
rounded lower.

Signed-off-by: Daniel Walker <dwalker@mvista.com>


---
 kernel/time/timekeeping.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-2.6.23/kernel/time/timekeeping.c
===================================================================
--- linux-2.6.23.orig/kernel/time/timekeeping.c
+++ linux-2.6.23/kernel/time/timekeeping.c
@@ -144,7 +144,8 @@ unsigned long notrace cycles_to_usecs(cy
 {
 	u64 ret = cyc2ns(clock, cycles);
 
-	do_div(ret, 1000);
+	ret += NSEC_PER_USEC/2; /* For rounding in do_div() */
+	do_div(ret, NSEC_PER_USEC);
 
 	return ret;
 }
-- 

-- 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-12-12 20:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20071212201258.890003246@mvista.com>
2007-12-12 20:15 ` [PATCH -rt] cycles_to_usecs rounding fix Daniel Walker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox