perf/core: Fix low freq setting via IOC_PERIOD
commit 0d39844150546fa1415127c5fbae26db64070dd3 upstream. A low attr::freq value cannot be set via IOC_PERIOD on some platforms. The perf_event_check_period() introduced in:81ec3f3c4c
("perf/x86: Add check_period PMU callback") was intended to check the period, rather than the frequency. A low frequency may be mistakenly rejected by limit_period(). Fix it. Fixes:81ec3f3c4c
("perf/x86: Add check_period PMU callback") Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20250117151913.3043942-2-kan.liang@linux.intel.com Closes: https://lore.kernel.org/lkml/20250115154949.3147-1-ravi.bangoria@amd.com/ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
25a9171d9a
commit
295fadbd3e
@ -5679,14 +5679,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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user