linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yongliang Gao <leonylgao@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: mhiramat@kernel.org, mathieu.desnoyers@efficios.com,
	 linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	 Yongliang Gao <leonylgao@tencent.com>,
	Huang Cun <cunhuang@tencent.com>,
	frankjpliu@tencent.com
Subject: Re: [PATCH] trace/pid_list: optimize pid_list->lock contention
Date: Tue, 11 Nov 2025 18:38:43 +0800	[thread overview]
Message-ID: <CAJxhyqD1kUmraC-FxvkyMssKWdyX4BkpKoH7Agm7c2FYTd6EjQ@mail.gmail.com> (raw)
In-Reply-To: <20251111081314.j8CFfAD6@linutronix.de>

Hi Steven, Sebastian,

Thank you for your review and explanation.
You are absolutely right. I overlooked the case of PREEMPT_RT. I will
look into other possible optimization methods later.

Best regards,
Yongliang

On Tue, Nov 11, 2025 at 4:13 PM Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
>
> On 2025-11-10 18:38:54 [-0500], Steven Rostedt wrote:
> > On Wed, 15 Oct 2025 19:49:52 +0800
> > Yongliang Gao <leonylgao@gmail.com> 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

  reply	other threads:[~2025-11-11 10:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 11:49 [PATCH] trace/pid_list: optimize pid_list->lock contention Yongliang Gao
2025-11-10 23:38 ` Steven Rostedt
2025-11-11  8:13   ` Sebastian Andrzej Siewior
2025-11-11 10:38     ` Yongliang Gao [this message]
2025-11-11 15:27     ` Steven Rostedt
2025-11-12  5:27       ` Yongliang Gao
2025-11-12 15:42         ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJxhyqD1kUmraC-FxvkyMssKWdyX4BkpKoH7Agm7c2FYTd6EjQ@mail.gmail.com \
    --to=leonylgao@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=cunhuang@tencent.com \
    --cc=frankjpliu@tencent.com \
    --cc=leonylgao@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).