From: Steven Rostedt <rostedt@goodmis.org>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
Uros Bizjak <ubizjak@gmail.com>,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org,
Frederic Weisbecker <frederic@kernel.org>,
Neeraj Upadhyay <quic_neeraju@quicinc.com>,
Josh Triplett <josh@joshtriplett.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Lai Jiangshan <jiangshanlai@gmail.com>
Subject: Re: [PATCH] rcu: use try_cmpxchg in check_cpu_stall
Date: Tue, 28 Feb 2023 19:08:46 -0500 [thread overview]
Message-ID: <20230228190846.79b06089@gandalf.local.home> (raw)
In-Reply-To: <CAEXW_YQ515_DOLVUm48GvDADuaY2mSrYTaKa7u6jYDNqBncJww@mail.gmail.com>
On Tue, 28 Feb 2023 18:30:14 -0500
Joel Fernandes <joel@joelfernandes.org> wrote:
> >
> > But looking at this use case, I'd actually NAK it, as it is misleading.
>
> I'm trying to parse this. You are saying it is misleading, because it
> updates js when it doesn't need to?
Correct.
>
> > As try_cmpxchg() is used to get rid of the updating of the old value. As in
> > the ring buffer code we had:
> >
> > void ring_buffer_record_off(struct trace_buffer *buffer)
> > {
> > unsigned int rd;
> > unsigned int new_rd;
> >
> > do {
> > rd = atomic_read(&buffer->record_disabled);
> > new_rd = rd | RB_BUFFER_OFF;
> > } while (!atomic_cmpxchg(&buffer->record_disabled, &rd, new_rd) != rd);
>
> Hear you actually meant "rd" as the second parameter without the & ?
Yes, I cut and pasted the updated code and incorrectly try to revert it in
this example :-p
>
> > }
> >
> > and the try_cmpxchg() converted it to:
> >
> > void ring_buffer_record_off(struct trace_buffer *buffer)
> > {
> > unsigned int rd;
> > unsigned int new_rd;
> >
> > rd = atomic_read(&buffer->record_disabled);
> > do {
> > new_rd = rd | RB_BUFFER_OFF;
> > } while (!atomic_try_cmpxchg(&buffer->record_disabled, &rd, new_rd));
> > }
> >
> > Which got rid of the need to constantly update the rd variable (cmpxchg
> > will load rax with the value read, so it removes the need for an extra
> > move).
>
> So that's a good thing?
Yes. For looping, try_cmpxchg() is the proper function to use. But in the
RCU case (and other cases in the ring-buffer patch) there is no loop, and
no need to modify the "old" variable.
>
> >
> > But in your case, we don't need to update js, in which case the
> > try_cmpxchg() does.
>
> Right, it has lesser value here but I'm curious why you feel it also
> doesn't belong in that ring buffer loop you shared (or did you mean,
> it does belong there but not in other ftrace code modified by Uros?).
The ring buffer patch had more than one change, where half the updates were
fine, and half were not.
-- Steve
next prev parent reply other threads:[~2023-03-01 0:08 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 15:51 [PATCH] rcu: use try_cmpxchg in check_cpu_stall Uros Bizjak
2023-02-28 20:39 ` Joel Fernandes
2023-02-28 20:56 ` Joel Fernandes
2023-02-28 21:03 ` Steven Rostedt
2023-02-28 21:29 ` Paul E. McKenney
2023-02-28 21:41 ` Steven Rostedt
2023-02-28 21:56 ` Paul E. McKenney
2023-02-28 23:30 ` Joel Fernandes
2023-03-01 0:08 ` Steven Rostedt [this message]
2023-03-01 0:45 ` Joel Fernandes
2023-03-01 10:28 ` Uros Bizjak
2023-03-01 16:38 ` Steven Rostedt
2023-03-01 18:43 ` Uros Bizjak
2023-03-01 18:52 ` Steven Rostedt
2023-03-01 19:18 ` Uros Bizjak
2023-03-01 19:43 ` Steven Rostedt
2023-03-01 19:46 ` Joel Fernandes
2023-03-01 19:45 ` Joel Fernandes
2023-03-01 20:08 ` Paul E. McKenney
2023-03-01 20:18 ` Joel Fernandes
2023-03-01 20:18 ` Steven Rostedt
2023-03-01 20:36 ` Paul E. McKenney
2023-03-01 20:46 ` Steven Rostedt
2023-03-01 21:29 ` Paul E. McKenney
2023-03-01 9:52 ` Uros Bizjak
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=20230228190846.79b06089@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.kernel.org \
--cc=ubizjak@gmail.com \
/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