]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - tools/perf/util/tsc.c
Merge tag 'tty-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[mirror_ubuntu-eoan-kernel.git] / tools / perf / util / tsc.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
0b437860
AH
2#include <linux/compiler.h>
3#include <linux/types.h>
4
5#include "tsc.h"
6
7u64 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
18u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
19{
20 u64 quot, rem;
21
22 quot = cyc >> tc->time_shift;
a23f96ee 23 rem = cyc & (((u64)1 << tc->time_shift) - 1);
0b437860
AH
24 return tc->time_zero + quot * tc->time_mult +
25 ((rem * tc->time_mult) >> tc->time_shift);
26}
a6a69db4
AH
27
28u64 __weak rdtsc(void)
29{
30 return 0;
31}