All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: linux-kernel@vger.kernel.org
Cc: Christoph Lameter <clameter@sgi.com>
Subject: [PATCH 3/7] Simple Performance Counters: i386 support
Date: Tue, 31 Jul 2007 16:25:08 -0700	[thread overview]
Message-ID: <11859243121503-git-send-email-clameter@sgi.com> (raw)
In-Reply-To: simple-perf-counters

Export a cycles_to_ns function

Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
 arch/i386/kernel/tsc.c   |    2 +-
 include/asm-i386/timex.h |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index debd7db..c150ac0 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -118,7 +118,7 @@ unsigned long long native_sched_clock(void)
 	rdtscll(this_offset);
 
 	/* return the value in ns */
-	return cycles_2_ns(this_offset);
+	return cycles_to_ns(this_offset);
 }
 
 /* We need to define a real function for sched_clock, to override the
diff --git a/include/asm-i386/timex.h b/include/asm-i386/timex.h
index 3666044..37b0338 100644
--- a/include/asm-i386/timex.h
+++ b/include/asm-i386/timex.h
@@ -19,4 +19,12 @@
 extern int read_current_timer(unsigned long *timer_value);
 #define ARCH_HAS_READ_CURRENT_TIMER	1
 
+extern long cyc2ns_scale;
+#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
+
+static inline unsigned long long cycles_to_ns(unsigned long long cyc)
+{
+	return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
+}
+
 #endif
-- 
1.5.2.4


                 reply	other threads:[~2007-07-31 23:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11859243121503-git-send-email-clameter@sgi.com \
    --to=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.