From: Hangbin Liu <liuhangbin@gmail•com>
To: David Laight <david.laight.linux@gmail•com>
Cc: Richard Henderson <richard.henderson@linaro•org>,
Matt Turner <mattst88@gmail•com>,
Magnus Lindholm <linmag7@gmail•com>,
Vineet Gupta <vgupta@kernel•org>, Brian Cain <bcain@kernel•org>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership•com>,
Helge Deller <deller@gmx•de>,
Madhavan Srinivasan <maddy@linux•ibm.com>,
Michael Ellerman <mpe@ellerman•id.au>,
Nicholas Piggin <npiggin@gmail•com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel•org>,
Paul Walmsley <pjw@kernel•org>,
Palmer Dabbelt <palmer@dabbelt•com>,
Albert Ou <aou@eecs•berkeley.edu>,
Alexandre Ghiti <alex@ghiti•fr>,
Yoshinori Sato <ysato@users•sourceforge.jp>,
Rich Felker <dalias@libc•org>,
John Paul Adrian Glaubitz <glaubitz@physik•fu-berlin.de>,
"David S. Miller" <davem@davemloft•net>,
Andreas Larsson <andreas@gaisler•com>,
Thomas Gleixner <tglx@kernel•org>, Ingo Molnar <mingo@redhat•com>,
Borislav Petkov <bp@alien8•de>,
Dave Hansen <dave.hansen@linux•intel.com>,
x86@kernel•org, "H. Peter Anvin" <hpa@zytor•com>,
Chris Zankel <chris@zankel•net>,
Max Filippov <jcmvbkbc@gmail•com>,
linux-alpha@vger•kernel.org, linux-kernel@vger•kernel.org,
linux-snps-arc@lists•infradead.org,
linux-hexagon@vger•kernel.org, linux-parisc@vger•kernel.org,
linuxppc-dev@lists•ozlabs.org, linux-riscv@lists•infradead.org,
linux-sh@vger•kernel.org, sparclinux@vger•kernel.org,
Jakub Kicinski <kuba@kernel•org>
Subject: Re: [PATCH] cmpxchg: allow const-qualified old value in cmpxchg()
Date: Thu, 2 Apr 2026 13:07:45 +0000 [thread overview]
Message-ID: <ac5qIUS5azbWAc9q@fedora> (raw)
In-Reply-To: <20260402095747.6efbd456@pumpkin>
On Thu, Apr 02, 2026 at 09:57:47AM +0100, David Laight wrote:
> > diff --git a/arch/alpha/include/asm/cmpxchg.h b/arch/alpha/include/asm/cmpxchg.h
> > index ae1b96479d0c..b4b8dac759c4 100644
> > --- a/arch/alpha/include/asm/cmpxchg.h
> > +++ b/arch/alpha/include/asm/cmpxchg.h
> > @@ -234,7 +234,7 @@ ____cmpxchg(volatile void *ptr, unsigned long old, unsigned long new,
> >
> > #define arch_cmpxchg_local(ptr, o, n) \
> > ({ \
> > - __typeof__(*(ptr)) _o_ = (o); \
> > + __typeof__(*(ptr)) _o_ = (__typeof__(*(ptr)))(o); \
> > __typeof__(*(ptr)) _n_ = (n); \
> > (__typeof__(*(ptr))) ____cmpxchg((ptr), (unsigned long)_o_, \
> > (unsigned long)_n_, \
>
> That looks like it loses the check that 'o' has the same type as '*ptr'.
> Maybe this works?
> auto _o_ = 1 ? (o) : *(ptr);
>
Oh, I didn't notice this. Thanks for the comment!
Best Regards
Hangbin
next prev parent reply other threads:[~2026-04-02 13:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 6:56 [PATCH] cmpxchg: allow const-qualified old value in cmpxchg() Hangbin Liu
2026-04-02 8:57 ` David Laight
2026-04-02 13:07 ` Hangbin Liu [this message]
2026-04-02 10:47 ` Peter Zijlstra
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=ac5qIUS5azbWAc9q@fedora \
--to=liuhangbin@gmail$(echo .)com \
--cc=James.Bottomley@hansenpartnership$(echo .)com \
--cc=alex@ghiti$(echo .)fr \
--cc=andreas@gaisler$(echo .)com \
--cc=aou@eecs$(echo .)berkeley.edu \
--cc=bcain@kernel$(echo .)org \
--cc=bp@alien8$(echo .)de \
--cc=chleroy@kernel$(echo .)org \
--cc=chris@zankel$(echo .)net \
--cc=dalias@libc$(echo .)org \
--cc=dave.hansen@linux$(echo .)intel.com \
--cc=davem@davemloft$(echo .)net \
--cc=david.laight.linux@gmail$(echo .)com \
--cc=deller@gmx$(echo .)de \
--cc=glaubitz@physik$(echo .)fu-berlin.de \
--cc=hpa@zytor$(echo .)com \
--cc=jcmvbkbc@gmail$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=linmag7@gmail$(echo .)com \
--cc=linux-alpha@vger$(echo .)kernel.org \
--cc=linux-hexagon@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-parisc@vger$(echo .)kernel.org \
--cc=linux-riscv@lists$(echo .)infradead.org \
--cc=linux-sh@vger$(echo .)kernel.org \
--cc=linux-snps-arc@lists$(echo .)infradead.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=maddy@linux$(echo .)ibm.com \
--cc=mattst88@gmail$(echo .)com \
--cc=mingo@redhat$(echo .)com \
--cc=mpe@ellerman$(echo .)id.au \
--cc=npiggin@gmail$(echo .)com \
--cc=palmer@dabbelt$(echo .)com \
--cc=pjw@kernel$(echo .)org \
--cc=richard.henderson@linaro$(echo .)org \
--cc=sparclinux@vger$(echo .)kernel.org \
--cc=tglx@kernel$(echo .)org \
--cc=vgupta@kernel$(echo .)org \
--cc=x86@kernel$(echo .)org \
--cc=ysato@users$(echo .)sourceforge.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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