aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVince Weaver <vincent.weaver@maine.edu>2016-10-21 00:38:06 -0400
committerMichael Kerrisk <mtk.manpages@gmail.com>2016-10-21 08:44:15 +0200
commit988688f6067a3327236d9f97fde71e4b8edb399c (patch)
treeda60c663b9ef25a4f63403b846b80b2a4dda4ab9
parentdceb9af608235aca743ccc2423c40c485d950de2 (diff)
downloadman-pages-988688f6067a3327236d9f97fde71e4b8edb399c.tar.gz
perf_event_open.2: Update time_shift sample code
Linux 4.3 (b20112edeadf0b8a1416de061caa4beb11539902) improved the accuracy of the clock/ns conversion routines. As a result the shift factor can now be 32. This value is directly exported in the perf_event_open() mmap page, and this potentially breaks the sample code that shifts 1 left by the shift value. Add a cast in the sample code so that a proper 64-bit value results from the shift. This is the same change that was made to the sample code in include/uapi/linux/perf_event.h in Linux 4.4 (b9511cd761faafca7a1acc059e792c1399f9d7c6). Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>
-rw-r--r--man2/perf_event_open.24
1 files changed, 2 insertions, 2 deletions
diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2
index ae15cc6bc9..fade28cae5 100644
--- a/man2/perf_event_open.2
+++ b/man2/perf_event_open.2
@@ -1619,7 +1619,7 @@ delta since
u64 quot, rem;
u64 delta;
quot = (cyc >> time_shift);
- rem = cyc & ((1 << time_shift) \- 1);
+ rem = cyc & (((u64)1 << time_shift) \- 1);
delta = time_offset + quot * time_mult +
((rem * time_mult) >> time_shift);
.fi
@@ -1664,7 +1664,7 @@ And vice versa:
.nf
quot = cyc >> time_shift;
- rem = cyc & ((1 << time_shift) - 1);
+ rem = cyc & (((u64)1 << time_shift) - 1);
timestamp = time_zero + quot * time_mult +
((rem * time_mult) >> time_shift);
.fi