Re: [BUG] perf/core: Task stuck on global_ctx_data_rwsem
From: Namhyung Kim
Date: Mon Dec 22 2025 - 18:36:56 EST
Added a subject prefix and CC LKML.
Thanks,
Namhyung
On Mon, Dec 22, 2025 at 03:34:23PM -0800, Namhyung Kim wrote:
> Hello,
>
> I got a report that a task is stuck in perf_event_exit_task() waiting
> for global_ctx_data_rwsem. On large systems, it'd have performance
> issues when it grabs the lock to iterate all threads in the system to
> allocate the context data. And it'd block task exit path which is
> problematic especially under memory pressure.
>
> perf_event_open
> perf_event_alloc
> attach_perf_ctx_data
> attach_global_ctx_data
> percpu_down_write (global_ctx_data_rwsem)
> for_each_process_thread
> alloc_task_ctx_data
> do_exit
> perf_event_exit_task
> percpu_down_read (global_ctx_data_rwsem)
>
> I think attach_global_ctx_data() should skip tasks with PF_EXITING and
> it'd be nice if perf_event_exit_task() could release the ctx_data
> unconditionally. But I'm not sure how to synchronize them properly.
>
> Any thoughts?
>
> Thanks,
> Namhyung
>