From: Peter Zijlstra Date: Wed, 16 Apr 2025 18:50:27 +0000 (+0200) Subject: perf/core: Fix perf-stat / read() X-Git-Tag: v6.16-rc1~196^2~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6938a562a6249000de211a710807ebf0b8fdf26;p=thirdparty%2Flinux.git perf/core: Fix perf-stat / read() In the zeal to adjust all event->state checks to include the new REVOKED state, one adjustment was made in error. Notably it resulted in read() on the perf filedesc to stop working for any state lower than ERROR, specifically EXIT. This leads to problems with (among others) perf-stat, which wants to read the counts after a program has finished execution. Fixes: da916e96e2de ("perf: Make perf_pmu_unregister() useable") Reported-by: "Mi, Dapeng" Reported-by: James Clark Tested-by: James Clark Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Link: https://lkml.kernel.org/r/77036114-8723-4af9-a068-1d535f4e2e81@linaro.org Link: https://lore.kernel.org/r/20250417080725.GH38216@noisy.programming.kicks-ass.net --- diff --git a/kernel/events/core.c b/kernel/events/core.c index 2eb9cd5d86a1e..e4d7a0c4b308b 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6021,7 +6021,7 @@ __perf_read(struct perf_event *event, char __user *buf, size_t count) * error state (i.e. because it was pinned but it couldn't be * scheduled on to the CPU at some point). */ - if (event->state <= PERF_EVENT_STATE_ERROR) + if (event->state == PERF_EVENT_STATE_ERROR) return 0; if (count < event->read_size)