Skip to contentSkip to conversation

perf: Fix the POLL_HUP delivery breakage

PATCH Applied [email protected] 4 participants 4 messages Aug 11, 2025 – Sep 3, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Fix the POLL_HUP delivery breakage

From: Kan Liang <[email protected]>

The event_limit can be set by the PERF_EVENT_IOC_REFRESH to limit the number of events. When the event_limit reaches 0, the POLL_HUP signal should be sent. But it's missed.

The corresponding counter should be stopped when the event_limit reaches
0. It was implemented in the ARCH-specific code. However, since the commit 9734e25fbf5a ("perf: Fix the throttle logic for a group"), all the ARCH-specific code has been moved to the generic code. The code to handle the event_limit was lost.

Add the event->pmu->stop(event, 0); back.

---
 kernel/events/core.c | 1 +
 1 file changed, 1 insertion(+)
kernel/events/core.c +1 -0
index dd8cf3c7fb7a..ec19c456b66d 100644
@@ -10378,6 +10378,7 @@ static int __perf_event_overflow(struct perf_event *event,
 		ret = 1;
 		event->pending_kill = POLL_HUP;
 		perf_event_disable_inatomic(event);
+		event->pmu->stop(event, 0);
 	}
 
 	if (event->attr.sigtrap) {
Signature · 1 line
2.38.1
#1 lore raw
Quoted 38 lines · On Mon, Aug 11, 2025 at 11:26:44AM -0700, [email protected] wrote:

From: Kan Liang <[email protected]>

The event_limit can be set by the PERF_EVENT_IOC_REFRESH to limit the number of events. When the event_limit reaches 0, the POLL_HUP signal should be sent. But it's missed.

The corresponding counter should be stopped when the event_limit reaches
0. It was implemented in the ARCH-specific code. However, since the commit 9734e25fbf5a ("perf: Fix the throttle logic for a group"), all the ARCH-specific code has been moved to the generic code. The code to handle the event_limit was lost.

Add the event->pmu->stop(event, 0); back.

---
 kernel/events/core.c | 1 +
 1 file changed, 1 insertion(+)
kernel/events/core.c +1 -0
index dd8cf3c7fb7a..ec19c456b66d 100644
@@ -10378,6 +10378,7 @@ static int __perf_event_overflow(struct perf_event *event,
 		ret = 1;
 		event->pending_kill = POLL_HUP;
 		perf_event_disable_inatomic(event);
+		event->pmu->stop(event, 0);
 	}
 
 	if (event->attr.sigtrap) {
Signature · 1 line
2.38.1

Hi All,

It would be great, if this patch can be integrated soon.

Thank you

maintainer
#2 lore raw
In reply to [email protected]
Quoted 28 lines · On Mon, Aug 11, 2025 at 11:26:44AM -0700, [email protected] wrote:

From: Kan Liang <[email protected]>

The event_limit can be set by the PERF_EVENT_IOC_REFRESH to limit the number of events. When the event_limit reaches 0, the POLL_HUP signal should be sent. But it's missed.

The corresponding counter should be stopped when the event_limit reaches
0. It was implemented in the ARCH-specific code. However, since the commit 9734e25fbf5a ("perf: Fix the throttle logic for a group"), all the ARCH-specific code has been moved to the generic code. The code to handle the event_limit was lost.

Add the event->pmu->stop(event, 0); back.

---
 kernel/events/core.c | 1 +
 1 file changed, 1 insertion(+)
kernel/events/core.c +0 -0
index dd8cf3c7fb7a..ec19c456b66d 100644

kernel/events/core.c static int __perf_event_overflow(struct perf_event *event, · line 10384

Quoted 7 lines
kernel/events/core.c +1 -0
@@ -10378,6 +10378,7 @@ static int __perf_event_overflow(struct perf_event *event,
 		ret = 1;
 		event->pending_kill = POLL_HUP;
 		perf_event_disable_inatomic(event);
+		event->pmu->stop(event, 0);
 	}
 
 	if (event->attr.sigtrap) {

Right. I've queued the patch, but should we take a hard look at anybody still consuming the return value of perf_event_overflow?

merge bot Applied
#3 lore raw
In reply to [email protected]
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:     18dbcbfabfffc4a5d3ea10290c5ad27f22b0d240
Gitweb:        https://git.kernel.org/tip/18dbcbfabfffc4a5d3ea10290c5ad27f22b0d240
Author:        Kan Liang <[email protected]>
AuthorDate:    Mon, 11 Aug 2025 11:26:44 -07:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Wed, 03 Sep 2025 10:10:59 +02:00

perf: Fix the POLL_HUP delivery breakage

The event_limit can be set by the PERF_EVENT_IOC_REFRESH to limit the number of events. When the event_limit reaches 0, the POLL_HUP signal should be sent. But it's missed.

The corresponding counter should be stopped when the event_limit reaches
0. It was implemented in the ARCH-specific code. However, since the commit 9734e25fbf5a ("perf: Fix the throttle logic for a group"), all the ARCH-specific code has been moved to the generic code. The code to handle the event_limit was lost.

Add the event->pmu->stop(event, 0); back.

---
 kernel/events/core.c | 1 +
 1 file changed, 1 insertion(+)
kernel/events/core.c +1 -0
index 872122e..8201275 100644
@@ -10330,6 +10330,7 @@ static int __perf_event_overflow(struct perf_event *event,
 		ret = 1;
 		event->pending_kill = POLL_HUP;
 		perf_event_disable_inatomic(event);
+		event->pmu->stop(event, 0);
 	}
 
 	if (event->attr.sigtrap) {