4 #include <linux/perf_event.h>
6 #include "../../perf.h"
7 #include "../../util/types.h"
8 #include "../../util/debug.h"
11 u64
perf_time_to_tsc(u64 ns
, struct perf_tsc_conversion
*tc
)
15 t
= ns
- tc
->time_zero
;
16 quot
= t
/ tc
->time_mult
;
17 rem
= t
% tc
->time_mult
;
18 return (quot
<< tc
->time_shift
) +
19 (rem
<< tc
->time_shift
) / tc
->time_mult
;
22 u64
tsc_to_perf_time(u64 cyc
, struct perf_tsc_conversion
*tc
)
26 quot
= cyc
>> tc
->time_shift
;
27 rem
= cyc
& ((1 << tc
->time_shift
) - 1);
28 return tc
->time_zero
+ quot
* tc
->time_mult
+
29 ((rem
* tc
->time_mult
) >> tc
->time_shift
);
32 int perf_read_tsc_conversion(const struct perf_event_mmap_page
*pc
,
33 struct perf_tsc_conversion
*tc
)
35 bool cap_user_time_zero
;
42 tc
->time_mult
= pc
->time_mult
;
43 tc
->time_shift
= pc
->time_shift
;
44 tc
->time_zero
= pc
->time_zero
;
45 cap_user_time_zero
= pc
->cap_user_time_zero
;
47 if (pc
->lock
== seq
&& !(seq
& 1))
50 pr_debug("failed to get perf_event_mmap_page lock\n");
55 if (!cap_user_time_zero
)
This page took 0.03187 seconds and 5 git commands to generate.