Skip to contentSkip to conversation

perf/core: Change to POLLERR for pinned events with error

RFC/PATCH for-perf-urgent Applied Namhyung Kim 2 participants 2 messages Apr 22, 2025 – Apr 23, 2025 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

The 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.

If we can change it to POLLERR it should be clear.

---
 kernel/events/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/core.c +2 -2
index e93c195659140d30..95e703891b24f8fc 100644
@@ -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
Signature · 1 line
2.49.0.805.g082f7c87e0-goog
merge bot Applied
#1 lore raw
The following commit has been merged into the perf/urgent branch of tip:

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     0db61388b389f43c1ba2f1cee3613feb4fd12150
Gitweb:        https://git.kernel.org/tip/0db61388b389f43c1ba2f1cee3613feb4fd12150
Author:        Namhyung Kim <[email protected]>
AuthorDate:    Tue, 22 Apr 2025 15:33:18 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 23 Apr 2025 09:39:06 +02:00

perf/core: Change to POLLERR for pinned events with error

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.

---
 kernel/events/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/core.c +2 -2
index e93c195..95e7038 100644
@@ -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