Re: [PATCH] perf record: fix poll storm when monitored threads exit

From: Namhyung Kim

Date: Wed Jul 08 2026 - 15:25:56 EST


On Tue, 07 Jul 2026 23:38:00 +0800, Jiawei Sun wrote:
> When `perf record` samples a multi-threaded process and one of the
> target threads exits during the session, perf itself may start burning
> 100% CPU (up to 200% across two cores) until the session ends. A
> single dead fd is sufficient to trigger this; it can be reproduced with
> 15 pthreads in a compute loop where one thread exits halfway through.
>
> The root cause is two independent instances of the same defect: dead
> perf_event ring-buffer fds are left in a pollfd array. When a monitored
> thread exits, the kernel closes its ring-buffer fd, which then returns
> POLLHUP. POSIX specifies that poll() always reports POLLHUP and POLLERR
> regardless of the events mask, so any dead fd left in the array makes
> poll() return immediately every time, spinning in a tight loop:
>
> [...]
Applied to perf-tools-next, thanks!

Best regards,
Namhyung