diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2014-07-22 09:17:32 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-07-23 10:48:11 -0400 |
commit | a6a69db4b686e51045771945669bba6578af67c1 (patch) | |
tree | db97f51a927367b4bd875c7879150af5eba0714a | |
parent | b9d266baac0429f70df3f9cf751b045730d612e3 (diff) |
perf tools: Move rdtsc() function
Move the rdtsc() function so it can be reusued.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1406035081-14301-24-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/arch/x86/util/tsc.c | 9 | ||||
-rw-r--r-- | tools/perf/tests/perf-time-to-tsc.c | 9 | ||||
-rw-r--r-- | tools/perf/util/tsc.c | 5 | ||||
-rw-r--r-- | tools/perf/util/tsc.h | 1 |
4 files changed, 15 insertions, 9 deletions
diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c index 3655f24c3170..fd2868490d00 100644 --- a/tools/perf/arch/x86/util/tsc.c +++ b/tools/perf/arch/x86/util/tsc.c | |||
@@ -37,3 +37,12 @@ int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, | |||
37 | 37 | ||
38 | return 0; | 38 | return 0; |
39 | } | 39 | } |
40 | |||
41 | u64 rdtsc(void) | ||
42 | { | ||
43 | unsigned int low, high; | ||
44 | |||
45 | asm volatile("rdtsc" : "=a" (low), "=d" (high)); | ||
46 | |||
47 | return low | ((u64)high) << 32; | ||
48 | } | ||
diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c index 0372f6edca20..f238442b238a 100644 --- a/tools/perf/tests/perf-time-to-tsc.c +++ b/tools/perf/tests/perf-time-to-tsc.c | |||
@@ -25,15 +25,6 @@ | |||
25 | } \ | 25 | } \ |
26 | } | 26 | } |
27 | 27 | ||
28 | static u64 rdtsc(void) | ||
29 | { | ||
30 | unsigned int low, high; | ||
31 | |||
32 | asm volatile("rdtsc" : "=a" (low), "=d" (high)); | ||
33 | |||
34 | return low | ((u64)high) << 32; | ||
35 | } | ||
36 | |||
37 | /** | 28 | /** |
38 | * test__perf_time_to_tsc - test converting perf time to TSC. | 29 | * test__perf_time_to_tsc - test converting perf time to TSC. |
39 | * | 30 | * |
diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c index ef4749836ce9..4d4210d4e13d 100644 --- a/tools/perf/util/tsc.c +++ b/tools/perf/util/tsc.c | |||
@@ -23,3 +23,8 @@ u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc) | |||
23 | return tc->time_zero + quot * tc->time_mult + | 23 | return tc->time_zero + quot * tc->time_mult + |
24 | ((rem * tc->time_mult) >> tc->time_shift); | 24 | ((rem * tc->time_mult) >> tc->time_shift); |
25 | } | 25 | } |
26 | |||
27 | u64 __weak rdtsc(void) | ||
28 | { | ||
29 | return 0; | ||
30 | } | ||
diff --git a/tools/perf/util/tsc.h b/tools/perf/util/tsc.h index 4eca84887c8a..a8b78f1b3243 100644 --- a/tools/perf/util/tsc.h +++ b/tools/perf/util/tsc.h | |||
@@ -7,5 +7,6 @@ | |||
7 | 7 | ||
8 | u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc); | 8 | u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc); |
9 | u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc); | 9 | u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc); |
10 | u64 rdtsc(void); | ||
10 | 11 | ||
11 | #endif | 12 | #endif |