Re: [RFC][PATCH v2] perf: Fix perf_addr_filters_afjust()

From: Leo Yan

Date: Wed Jun 24 2026 - 11:20:33 EST


On Tue, Jun 23, 2026 at 11:14:26AM +0200, Peter Zijlstra wrote:
>
> - adjust lock order; since perf_event_addr_filters_apply() takes mmap_lock
> inside child_mutex.
>
> - note that perf_event_mmap() is called by the thread doing the
> mmap()/mprotect()/.. operation, but not the other threads in the address
> space that might have inherited the same event.
>
> - have perf_addr_filters_adjust() iterate the child_list to find all other
> events for tasks that have the same mm.
>
> - since this can now adjust addr_filter_ranges[] for remote events, make sure
> to adjust things while holding ctx->lock; local_irq_disable() as implied by
> the ifh->lock is no longer suffient to serialize against event scheduling.
>
> - per the previous locking order; perf_event_mmap(), which is called holding
> mmap_lock, cannot take child_mutex, as such, make child_list RCU protected
> and iterate under RCU.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

Just verified this patch with Arm CoreSight:

perf record -e cs_etm//u --filter 'filter traced_region @/root/test' -- /root/test

The workload forks a child process to inherited the event, also used
trace_printk() to confirm perf_event_addr_filters_adjust() has been hit.
No warning reported by LOCKDEP.

Tested-by: Leo Yan <leo.yan@xxxxxxx>

If you want me to try any specific test, pleaset let me know and I am
glad to give a run.

Maybe it is good to fix typo in the subject: s/afjust()/adjust()/.