1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/compiler.h>
3 #include <linux/types.h>
7 u64
perf_time_to_tsc(u64 ns
, struct perf_tsc_conversion
*tc
)
11 t
= ns
- tc
->time_zero
;
12 quot
= t
/ tc
->time_mult
;
13 rem
= t
% tc
->time_mult
;
14 return (quot
<< tc
->time_shift
) +
15 (rem
<< tc
->time_shift
) / tc
->time_mult
;
18 u64
tsc_to_perf_time(u64 cyc
, struct perf_tsc_conversion
*tc
)
22 quot
= cyc
>> tc
->time_shift
;
23 rem
= cyc
& (((u64
)1 << tc
->time_shift
) - 1);
24 return tc
->time_zero
+ quot
* tc
->time_mult
+
25 ((rem
* tc
->time_mult
) >> tc
->time_shift
);
28 u64 __weak
rdtsc(void)