summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/tsc.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2014-07-18 06:16:06 +0200
committerIngo Molnar <mingo@kernel.org>2014-07-18 06:16:06 +0200
commitec6dbcb7ade2a616675cbe3185cf299ee1615c9f (patch)
tree4953f7eca477e011aa9e16cdb236220ed9cec4be /tools/perf/util/tsc.c
parentff2ebe46e15bd49d52b9c2f3fc77f3a9d94eac7b (diff)
parent0b437860818dc717f6a9e8a5089223a8414f5fff (diff)
downloadop-kernel-dev-ec6dbcb7ade2a616675cbe3185cf299ee1615c9f.zip
op-kernel-dev-ec6dbcb7ade2a616675cbe3185cf299ee1615c9f.tar.gz
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: User visible changes: o Support S/390 in 'perf kvm stat' (Alexander Yarygin) Developer Stuff: o Various fixes and prep work related to supporting Intel PT (Adrian Hunter) o Introduce multiple debug variables control (Jiri Olsa) o Add callchain and additional sample information for python scripts (Joseph Schuchart) Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/tsc.c')
-rw-r--r--tools/perf/util/tsc.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c
new file mode 100644
index 0000000..ef4749836
--- /dev/null
+++ b/tools/perf/util/tsc.c
@@ -0,0 +1,25 @@
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+#include "tsc.h"
+
+u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
+{
+ u64 t, quot, rem;
+
+ t = ns - tc->time_zero;
+ quot = t / tc->time_mult;
+ rem = t % tc->time_mult;
+ return (quot << tc->time_shift) +
+ (rem << tc->time_shift) / tc->time_mult;
+}
+
+u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
+{
+ u64 quot, rem;
+
+ quot = cyc >> tc->time_shift;
+ rem = cyc & ((1 << tc->time_shift) - 1);
+ return tc->time_zero + quot * tc->time_mult +
+ ((rem * tc->time_mult) >> tc->time_shift);
+}
OpenPOWER on IntegriCloud