Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Use 64-bit shifts with (TSC) time conversion

Commit b9511cd761fa ("perf/x86: Fix time_shift in perf_event_mmap_page")
altered the time conversion algorithms documented in the perf_event.h
header file, to use 64-bit shifts. That was done to make the code more
future-proof (i.e. some time in the future a 32-bit shift could be
allowed). Reflect those changes in perf tools.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1457005856-6143-9-git-send-email-adrian.hunter@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Adrian Hunter and committed by
Ingo Molnar
a23f96ee 4a018cc4

+2 -2
+1 -1
tools/perf/arch/x86/tests/rdpmc.c
··· 59 59 u64 quot, rem; 60 60 61 61 quot = (cyc >> time_shift); 62 - rem = cyc & ((1 << time_shift) - 1); 62 + rem = cyc & (((u64)1 << time_shift) - 1); 63 63 delta = time_offset + quot * time_mult + 64 64 ((rem * time_mult) >> time_shift); 65 65
+1 -1
tools/perf/util/tsc.c
··· 19 19 u64 quot, rem; 20 20 21 21 quot = cyc >> tc->time_shift; 22 - rem = cyc & ((1 << tc->time_shift) - 1); 22 + rem = cyc & (((u64)1 << tc->time_shift) - 1); 23 23 return tc->time_zero + quot * tc->time_mult + 24 24 ((rem * tc->time_mult) >> tc->time_shift); 25 25 }