4 #include <linux/perf_event.h>
6 #include "../../perf.h"
7 #include <linux/types.h>
8 #include "../../util/debug.h"
9 #include "../../util/tsc.h"
12 int perf_read_tsc_conversion(const struct perf_event_mmap_page
*pc
,
13 struct perf_tsc_conversion
*tc
)
15 bool cap_user_time_zero
;
22 tc
->time_mult
= pc
->time_mult
;
23 tc
->time_shift
= pc
->time_shift
;
24 tc
->time_zero
= pc
->time_zero
;
25 cap_user_time_zero
= pc
->cap_user_time_zero
;
27 if (pc
->lock
== seq
&& !(seq
& 1))
30 pr_debug("failed to get perf_event_mmap_page lock\n");
35 if (!cap_user_time_zero
)
43 unsigned int low
, high
;
45 asm volatile("rdtsc" : "=a" (low
), "=d" (high
));
47 return low
| ((u64
)high
) << 32;