]>
Commit | Line | Data |
---|---|---|
816f13a8 SL |
1 | From acda9fdcd53e9fa1432b36626464210d4f5e29b8 Mon Sep 17 00:00:00 2001 |
2 | From: Young Xiao <92siuyang@gmail.com> | |
3 | Date: Wed, 29 May 2019 10:21:48 +0800 | |
4 | Subject: sparc: perf: fix updated event period in response to | |
5 | PERF_EVENT_IOC_PERIOD | |
6 | ||
7 | [ Upstream commit 56cd0aefa475079e9613085b14a0f05037518fed ] | |
8 | ||
9 | The PERF_EVENT_IOC_PERIOD ioctl command can be used to change the | |
10 | sample period of a running perf_event. Consequently, when calculating | |
11 | the next event period, the new period will only be considered after the | |
12 | previous one has overflowed. | |
13 | ||
14 | This patch changes the calculation of the remaining event ticks so that | |
15 | they are offset if the period has changed. | |
16 | ||
17 | See commit 3581fe0ef37c ("ARM: 7556/1: perf: fix updated event period in | |
18 | response to PERF_EVENT_IOC_PERIOD") for details. | |
19 | ||
20 | Signed-off-by: Young Xiao <92siuyang@gmail.com> | |
21 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
22 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
23 | --- | |
24 | arch/sparc/kernel/perf_event.c | 4 ++++ | |
25 | 1 file changed, 4 insertions(+) | |
26 | ||
27 | diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c | |
28 | index 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 | -- | |
43 | 2.20.1 | |
44 |