Commit f6938a56 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar
Browse files

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: da916e96 ("perf: Make perf_pmu_unregister() useable")
Reported-by: default avatar"Mi, Dapeng" <dapeng1.mi@linux.intel.com>
Reported-by: default avatarJames Clark <james.clark@linaro.org>
Tested-by: default avatarJames Clark <james.clark@linaro.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo 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
parent 1d34a054
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)