]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.9/sparc-perf-fix-updated-event-period-in-response-to-p.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.9 / sparc-perf-fix-updated-event-period-in-response-to-p.patch
CommitLineData
816f13a8
SL
1From acda9fdcd53e9fa1432b36626464210d4f5e29b8 Mon Sep 17 00:00:00 2001
2From: Young Xiao <92siuyang@gmail.com>
3Date: Wed, 29 May 2019 10:21:48 +0800
4Subject: sparc: perf: fix updated event period in response to
5 PERF_EVENT_IOC_PERIOD
6
7[ Upstream commit 56cd0aefa475079e9613085b14a0f05037518fed ]
8
9The PERF_EVENT_IOC_PERIOD ioctl command can be used to change the
10sample period of a running perf_event. Consequently, when calculating
11the next event period, the new period will only be considered after the
12previous one has overflowed.
13
14This patch changes the calculation of the remaining event ticks so that
15they are offset if the period has changed.
16
17See commit 3581fe0ef37c ("ARM: 7556/1: perf: fix updated event period in
18response to PERF_EVENT_IOC_PERIOD") for details.
19
20Signed-off-by: Young Xiao <92siuyang@gmail.com>
21Signed-off-by: David S. Miller <davem@davemloft.net>
22Signed-off-by: Sasha Levin <sashal@kernel.org>
23---
24 arch/sparc/kernel/perf_event.c | 4 ++++
25 1 file changed, 4 insertions(+)
26
27diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
28index 71e7f77f6776..84a80cd004eb 100644
29--- a/arch/sparc/kernel/perf_event.c
30+++ b/arch/sparc/kernel/perf_event.c
31@@ -889,6 +889,10 @@ static int sparc_perf_event_set_period(struct perf_event *event,
32 s64 period = hwc->sample_period;
33 int ret = 0;
34
35+ /* The period may have been changed by PERF_EVENT_IOC_PERIOD */
36+ if (unlikely(period != hwc->last_period))
37+ left = period - (hwc->last_period - left);
38+
39 if (unlikely(left <= -period)) {
40 left = period;
41 local64_set(&hwc->period_left, left);
42--
432.20.1
44