]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf/core: Fix perf-stat / read()
authorPeter Zijlstra <peterz@infradead.org>
Wed, 16 Apr 2025 18:50:27 +0000 (20:50 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 17 Apr 2025 12:21:15 +0000 (14:21 +0200)
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" <dapeng1.mi@linux.intel.com>
Reported-by: James Clark <james.clark@linaro.org>
Tested-by: James Clark <james.clark@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
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
kernel/events/core.c

index 2eb9cd5d86a1e31eff24a1d9bb385c8797131a6b..e4d7a0c4b308bd35d6f735a6978cddfd9b8651bf 100644 (file)
@@ -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)