[PATCH v2 0/6] arm64: perf: Proper cap_user_time* support

From: Leo Yan
Date: Tue Jul 14 2020 - 22:05:29 EST


This patch set is rebased for Peter's patch set to support
cap_user_time/cap_user_time_short ABI for Arm64, and export Arm arch
timer counter related parameters from kernel to Perf tool.

In this version, there have two changes comparing to Peter's original
patch set [1]:

The first change is for calculation 'time_zero', in the old patch it
used the formula:

userpg->time_zero -= (rd->epoch_cyc * rd->mult) >> rd->shift;

>From the testing, if 'rd->epoch_cyc' is a big counter value, then it's
easily to cause overflow issue when multiply by the 'rd->mult'. So in
this patch set, it changes to use quot/rem approach for the calculation
and can avoid overflow:

quot = rd->epoch_cyc >> rd->shift;
rem = rd->epoch_cyc & (((u64)1 << rd->shift) - 1);
ns = quot * rd->mult + ((rem * rd->mult) >> rd->shift);
userpg->time_zero -= ns;

The second change is to add new patch 'tools headers UAPI: Update
tools's copy of linux/perf_event.h', it's used to update perf tool
header so make sure the headers are consistent between kernel and user
space.

This patch set has been rebased on mainline kernel with the latest
commit 11ba468877bb ("Linux 5.8-rc5"); it has been verified with Perf
tool for Arm SPE timestamp enabling, the patch set for Arm SPE timestamp
enabling will be sent out separately.


[1] https://lkml.org/lkml/2020/5/12/481


Leo Yan (1):
tools headers UAPI: Update tools's copy of linux/perf_event.h

Peter Zijlstra (5):
sched_clock: Expose struct clock_read_data
arm64: perf: Implement correct cap_user_time
arm64: perf: Only advertise cap_user_time for arch_timer
perf: Add perf_event_mmap_page::cap_user_time_short ABI
arm64: perf: Add cap_user_time_short

arch/arm64/kernel/perf_event.c | 59 ++++++++++++++++++++-------
include/linux/sched_clock.h | 28 +++++++++++++
include/uapi/linux/perf_event.h | 23 +++++++++--
kernel/time/sched_clock.c | 41 ++++++-------------
tools/include/uapi/linux/perf_event.h | 23 +++++++++--
5 files changed, 126 insertions(+), 48 deletions(-)

--
2.17.1