Re: [PATCH v2] perf: Reject group leaders detached by CPU hot-unplug
From: Peter Zijlstra
Date: Thu Nov 19 2026 - 04:20:32 EST
On Thu, Nov 19, 2026 at 02:24:19PM +0530, Aditya Chillara wrote:
> task already asleep in poll() a fresh poll()
> before your patch stays asleep no data
> your patch stays asleep EPOLLHUP
> your patch + wakeup woken, sees EPOLLHUP EPOLLHUP
>
> perf_event_exit_event() kicks perf_poll() with perf_event_wakeup() after
> moving events to EXIT, but this path doesn't, so a task already sleeping
> in poll() is not woken and only sees EPOLLHUP when its timeout runs out.
>
> Deferring the wakeup to the event's irq_work, as merge_sched_in() does,
> seems enough. Something like this, on top of your patch:
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index c1f3e1f013ec..885b6594139a 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -15350,6 +15350,9 @@ static void __perf_event_exit_context(void *__info)
> list_for_each_entry(event, &ctx->event_list, event_entry) {
> __perf_remove_from_context(event, cpuctx, ctx,
> (void *)(DETACH_EXIT | DETACH_GROUP));
> + /* Kick perf_poll() for is_event_hup(). */
> + event->pending_wakeup = 1;
> + irq_work_queue(&event->pending_irq);
> }
> raw_spin_unlock(&ctx->lock);
> }
Yeah, I suppose that makes sense.