Skip to content

Commit c8f9eb0

Browse files
Peter Zijlstrawilldeacon
authored andcommitted
arm64: perf: Add cap_user_time_short
This completes the ARM64 cap_user_time support. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Leo Yan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 6c0246a commit c8f9eb0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/arm64/kernel/perf_event.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ void arch_perf_update_userpage(struct perf_event *event,
11771177

11781178
userpg->cap_user_time = 0;
11791179
userpg->cap_user_time_zero = 0;
1180+
userpg->cap_user_time_short = 0;
11801181

11811182
do {
11821183
rd = sched_clock_read_begin(&seq);
@@ -1187,13 +1188,13 @@ void arch_perf_update_userpage(struct perf_event *event,
11871188
userpg->time_mult = rd->mult;
11881189
userpg->time_shift = rd->shift;
11891190
userpg->time_zero = rd->epoch_ns;
1191+
userpg->time_cycles = rd->epoch_cyc;
1192+
userpg->time_mask = rd->sched_clock_mask;
11901193

11911194
/*
1192-
* This isn't strictly correct, the ARM64 counter can be
1193-
* 'short' and then we get funnies when it wraps. The correct
1194-
* thing would be to extend the perf ABI with a cycle and mask
1195-
* value, but because wrapping on ARM64 is very rare in
1196-
* practise this 'works'.
1195+
* Subtract the cycle base, such that software that
1196+
* doesn't know about cap_user_time_short still 'works'
1197+
* assuming no wraps.
11971198
*/
11981199
ns = mul_u64_u32_shr(rd->epoch_cyc, rd->mult, rd->shift);
11991200
userpg->time_zero -= ns;
@@ -1219,4 +1220,5 @@ void arch_perf_update_userpage(struct perf_event *event,
12191220
*/
12201221
userpg->cap_user_time = 1;
12211222
userpg->cap_user_time_zero = 1;
1223+
userpg->cap_user_time_short = 1;
12221224
}

0 commit comments

Comments
 (0)