perf/core: Change to POLLERR for pinned events with error
authorNamhyung Kim <namhyung@kernel.org>
Tue, 22 Apr 2025 22:33:18 +0000 (15:33 -0700)
committerIngo Molnar <mingo@kernel.org>
Wed, 23 Apr 2025 07:39:06 +0000 (09:39 +0200)
Commit:

  f4b07fd62d4d11d5 ("perf/core: Use POLLHUP for pinned events in error")

started to emit POLLHUP for pinned events in an error state.

But the POLLHUP is also used to signal events that the attached task is
terminated.  To distinguish pinned per-task events in the error state
it would need to check if the task is live.

Change it to POLLERR to make it clear.

Suggested-by: Gabriel Marin <gmx@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250422223318.180343-1-namhyung@kernel.org
kernel/events/core.c

index e93c195..95e7038 100644 (file)
@@ -3943,7 +3943,7 @@ static int merge_sched_in(struct perf_event *event, void *data)
                        perf_event_set_state(event, PERF_EVENT_STATE_ERROR);
 
                        if (*perf_event_fasync(event))
-                               event->pending_kill = POLL_HUP;
+                               event->pending_kill = POLL_ERR;
 
                        perf_event_wakeup(event);
                } else {
@@ -6075,7 +6075,7 @@ static __poll_t perf_poll(struct file *file, poll_table *wait)
 
        if (unlikely(READ_ONCE(event->state) == PERF_EVENT_STATE_ERROR &&
                     event->attr.pinned))
-               return events;
+               return EPOLLERR;
 
        /*
         * Pin the event->rb by taking event->mmap_mutex; otherwise