[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250117151913.3043942-2-kan.liang@linux.intel.com>
Date: Fri, 17 Jan 2025 07:19:12 -0800
From: kan.liang@...ux.intel.com
To: peterz@...radead.org,
mingo@...hat.com,
acme@...nel.org,
namhyung@...nel.org,
irogers@...gle.com,
linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org
Cc: ak@...ux.intel.com,
ravi.bangoria@....com,
jolsa@...hat.com,
Kan Liang <kan.liang@...ux.intel.com>,
stable@...r.kernel.org
Subject: [PATCH 2/3] perf: Fix low freq setting via IOC_PERIOD
From: Kan Liang <kan.liang@...ux.intel.com>
A low freq cannot be set via IOC_PERIOD on some platforms.
The perf_event_check_period() introduced in commit 81ec3f3c4c4d
("perf/x86: Add check_period PMU callback") intended to check the
period, rather than the freq. A low freq may be mistakenly rejected by
the limit_period().
Fixes: 81ec3f3c4c4d ("perf/x86: Add check_period PMU callback")
Closes: https://lore.kernel.org/lkml/20250115154949.3147-1-ravi.bangoria@amd.com/
Signed-off-by: Kan Liang <kan.liang@...ux.intel.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Ravi Bangoria <ravi.bangoria@....com>
Cc: stable@...r.kernel.org
---
kernel/events/core.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index f91ba29048ce..a9a04d4f3619 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5960,14 +5960,15 @@ static int _perf_event_period(struct perf_event *event, u64 value)
if (!value)
return -EINVAL;
- if (event->attr.freq && value > sysctl_perf_event_sample_rate)
- return -EINVAL;
-
- if (perf_event_check_period(event, value))
- return -EINVAL;
-
- if (!event->attr.freq && (value & (1ULL << 63)))
- return -EINVAL;
+ if (event->attr.freq) {
+ if (value > sysctl_perf_event_sample_rate)
+ return -EINVAL;
+ } else {
+ if (perf_event_check_period(event, value))
+ return -EINVAL;
+ if (value & (1ULL << 63))
+ return -EINVAL;
+ }
event_function_call(event, __perf_event_period, &value);
--
2.38.1
Powered by blists - more mailing lists