Re: [PATCH] trace/pid_list: optimize pid_list->lock contention
From: Sebastian Andrzej Siewior
Date: Tue Nov 11 2025 - 03:22:11 EST
On 2025-11-10 18:38:54 [-0500], Steven Rostedt wrote:
> On Wed, 15 Oct 2025 19:49:52 +0800
> Yongliang Gao <leonylgao@xxxxxxxxx> wrote:
>
> > diff --git a/kernel/trace/pid_list.c b/kernel/trace/pid_list.c
> > index 090bb5ea4a19..62082a4f60db 100644
> > --- a/kernel/trace/pid_list.c
> > +++ b/kernel/trace/pid_list.c
> > @@ -138,14 +138,14 @@ bool trace_pid_list_is_set(struct trace_pid_list *pid_list, unsigned int pid)
> > if (pid_split(pid, &upper1, &upper2, &lower) < 0)
> > return false;
> >
> > - raw_spin_lock_irqsave(&pid_list->lock, flags);
> > + read_lock_irqsave(&pid_list->lock, flags);
> > upper_chunk = pid_list->upper[upper1];
> > if (upper_chunk) {
> > lower_chunk = upper_chunk->data[upper2];
> > if (lower_chunk)
> > ret = test_bit(lower, lower_chunk->data);
> > }
> > - raw_spin_unlock_irqrestore(&pid_list->lock, flags);
> > + read_unlock_irqrestore(&pid_list->lock, flags);
> >
> > return ret;
> > }
>
> Unfortunately you cannot do this because this is called while holding the
> task pi_lock and rq locks. In PREEMPT_RT() the read/write_lock_* turn into
> mutexes.
>
> Sebastian, is there any equivalent of raw_read/write_locks() that can be
> used?
Nope, no read-write lock that can be used in atomic sections. Well,
there is RCU.
> -- Steve
Sebastian