linux-mips
[Top] [All Lists]

[PATCH] MIPS: Add sched_clock() to csrc-octeon.c

To: linux-mips@linux-mips.org, ralf@linux-mips.org
Subject: [PATCH] MIPS: Add sched_clock() to csrc-octeon.c
From: David Daney <ddaney@caviumnetworks.com>
Date: Wed, 23 Dec 2009 13:18:54 -0800
Cc: David Daney <ddaney@caviumnetworks.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
With the advent of function graph tracing on MIPS, Octeon needs a high
precision sched_clock() implementation.  Without it, most timing
numbers are reported as 0.000.

This new sched_clock just uses the 64-bit cycle counter appropriately
scaled.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
 arch/mips/cavium-octeon/csrc-octeon.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/mips/cavium-octeon/csrc-octeon.c 
b/arch/mips/cavium-octeon/csrc-octeon.c
index 96110f2..96df821 100644
--- a/arch/mips/cavium-octeon/csrc-octeon.c
+++ b/arch/mips/cavium-octeon/csrc-octeon.c
@@ -50,6 +50,13 @@ static struct clocksource clocksource_mips = {
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+unsigned long long notrace sched_clock(void)
+{
+       return clocksource_cyc2ns(read_c0_cvmcount(),
+                                 clocksource_mips.mult,
+                                 clocksource_mips.shift);
+}
+
 void __init plat_time_init(void)
 {
        clocksource_mips.rating = 300;
-- 
1.6.0.6


<Prev in Thread] Current Thread [Next in Thread>