perf tools: Move rdtsc() function
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 22 Jul 2014 13:17:32 +0000 (16:17 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 23 Jul 2014 14:48:11 +0000 (11:48 -0300)
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>
tools/perf/arch/x86/util/tsc.c
tools/perf/tests/perf-time-to-tsc.c
tools/perf/util/tsc.c
tools/perf/util/tsc.h

index 3655f24c3170f165d304a848d40d5c549c442561..fd2868490d00ea895b380e5cd408482c2f990a35 100644 (file)
@@ -37,3 +37,12 @@ int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc,
 
        return 0;
 }
+
+u64 rdtsc(void)
+{
+       unsigned int low, high;
+
+       asm volatile("rdtsc" : "=a" (low), "=d" (high));
+
+       return low | ((u64)high) << 32;
+}
index 0372f6edca20d958281ae355449d1e3bedbd03cc..f238442b238a297d11e0622f275bf847e5b7db94 100644 (file)
        }                                       \
 }
 
-static u64 rdtsc(void)
-{
-       unsigned int low, high;
-
-       asm volatile("rdtsc" : "=a" (low), "=d" (high));
-
-       return low | ((u64)high) << 32;
-}
-
 /**
  * test__perf_time_to_tsc - test converting perf time to TSC.
  *
index ef4749836ce94337a1618263afc19abe0761e553..4d4210d4e13d1d7fbc32a5c1f4afff58a0810fd0 100644 (file)
@@ -23,3 +23,8 @@ u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
        return tc->time_zero + quot * tc->time_mult +
               ((rem * tc->time_mult) >> tc->time_shift);
 }
+
+u64 __weak rdtsc(void)
+{
+       return 0;
+}
index 4eca84887c8a5e9a4c16b53eadd2e0d0db1d98b9..a8b78f1b3243891c40560c6501c93ba2d377e37c 100644 (file)
@@ -7,5 +7,6 @@
 
 u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc);
 u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc);
+u64 rdtsc(void);
 
 #endif