From: Will Deacon <will@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Jens Axboe" <axboe@kernel.dk>,
"Carter Li 李通洲" <carter.li@eoitek.com>,
"Pavel Begunkov" <asml.silence@gmail.com>,
io-uring <io-uring@vger.kernel.org>,
"Oleg Nesterov" <oleg@redhat.com>,
"Mark Rutland" <mark.rutland@arm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] asm-generic/atomic: Add try_cmpxchg() fallbacks
Date: Thu, 20 Feb 2020 10:39:35 +0000 [thread overview]
Message-ID: <20200220103934.GA14459@willie-the-truck> (raw)
In-Reply-To: <20200220103727.GW18400@hirez.programming.kicks-ass.net>
On Thu, Feb 20, 2020 at 11:37:27AM +0100, Peter Zijlstra wrote:
> On Thu, Feb 20, 2020 at 10:30:45AM +0000, Will Deacon wrote:
> > On Tue, Feb 18, 2020 at 03:27:00PM +0100, Peter Zijlstra wrote:
> > > diff --git a/scripts/atomic/gen-atomic-fallback.sh b/scripts/atomic/gen-atomic-fallback.sh
> > > index b6c6f5d306a7..3c9be8d550e0 100755
> > > --- a/scripts/atomic/gen-atomic-fallback.sh
> > > +++ b/scripts/atomic/gen-atomic-fallback.sh
> > > @@ -140,6 +140,32 @@ cat <<EOF
> > > EOF
> > > }
> > >
> > > +gen_try_cmpxchg_fallback()
> > > +{
> > > + local order="$1"; shift;
> > > +
> > > +cat <<EOF
> > > +#ifndef try_cmpxchg${order}
> > > +#define try_cmpxchg${order}(_ptr, _oldp, _new) \\
> > > +({ \\
> > > + typeof(*ptr) ___r, ___o = *(_oldp); \\
> > > + ___r = cmpxchg${order}((_ptr), ___o, (_new)); \\
> > > + if (unlikely(___r != ___o)) \\
> > > + *(_old) = ___r; \\
> >
> > This doesn't compile because _old isn't declared. Probably best to avoid
> > evaluating _oldp twice though.
>
> Compiler had already spotted that, I'll make it something like:
>
> typeof(*ptr) *___op = (_oldp), ___o = *___op;
>
> ...
>
> *___op = ___r;
>
> Which avoids the double eval.
Cool, you can stick my Ack on the patch with that change.
Will
prev parent reply other threads:[~2020-02-20 10:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5995f84e-8a6c-e774-6bb5-5b9b87a9cd3c@kernel.dk>
[not found] ` <7c4c3996-4886-eb58-cdee-fe0951907ab5@kernel.dk>
[not found] ` <addcd44e-ed9b-5f82-517d-c1ed3ee2d85c@kernel.dk>
[not found] ` <b8069e62-7ea4-c7f3-55a3-838241951068@kernel.dk>
[not found] ` <20200217120920.GQ14914@hirez.programming.kicks-ass.net>
[not found] ` <53de3581-b902-89ba-3f53-fd46b052df40@kernel.dk>
[not found] ` <43c066d1-a892-6a02-82e7-7be850d9454d@kernel.dk>
[not found] ` <20200217174610.GU14897@hirez.programming.kicks-ass.net>
[not found] ` <592cf069-41ee-0bc1-1f83-e058e5dd53ff@kernel.dk>
[not found] ` <20200218131310.GZ14914@hirez.programming.kicks-ass.net>
2020-02-18 14:27 ` Peter Zijlstra
2020-02-18 14:40 ` Peter Zijlstra
2020-02-20 10:30 ` Will Deacon
2020-02-20 10:37 ` Peter Zijlstra
2020-02-20 10:39 ` Will Deacon [this message]
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=20200220103934.GA14459@willie-the-truck \
--to=will@kernel.org \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=carter.li@eoitek.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®