Linux Perf
tsc.c
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-2.0
2
#include <linux/compiler.h>
3
#include <linux/types.h>
4
5
#include "
tsc.h
"
6
7
u64
perf_time_to_tsc
(u64
ns
,
struct
perf_tsc_conversion
*tc)
8
{
9
u64 t, quot, rem;
10
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
;
16
}
17
18
u64
tsc_to_perf_time
(u64 cyc,
struct
perf_tsc_conversion
*tc)
19
{
20
u64 quot, rem;
21
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
);
26
}
27
28
u64 __weak
rdtsc
(
void
)
29
{
30
return
0;
31
}
perf_tsc_conversion::time_zero
u64 time_zero
Definition:
tsc.h:12
perf_tsc_conversion::time_shift
u16 time_shift
Definition:
tsc.h:10
perf_tsc_conversion
Definition:
tsc.h:9
compaction-times.ns
def ns(sec, nsec)
Definition:
compaction-times.py:48
perf_time_to_tsc
u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
Definition:
tsc.c:7
tsc.h
perf_tsc_conversion::time_mult
u32 time_mult
Definition:
tsc.h:11
tsc_to_perf_time
u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
Definition:
tsc.c:18
rdtsc
u64 rdtsc(void)
Definition:
tsc.c:41
util
tsc.c
Generated by
1.8.13