[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201027074726.GX2611@hirez.programming.kicks-ass.net>
Date: Tue, 27 Oct 2020 08:47:26 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Waiman Long <longman@...hat.com>
Cc: Arnd Bergmann <arnd@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Matthew Wilcox <willy@...radead.org>,
Ingo Molnar <mingo@...nel.org>, Will Deacon <will@...nel.org>,
Will Deacon <will.deacon@....com>,
Thomas Gleixner <tglx@...utronix.de>,
Nicholas Piggin <npiggin@...il.com>,
Michael Ellerman <mpe@...erman.id.au>,
Herbert Xu <herbert@...dor.apana.org.au>,
linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] qspinlock: use signed temporaries for cmpxchg
On Mon, Oct 26, 2020 at 02:03:06PM -0400, Waiman Long wrote:
> On 10/26/20 12:57 PM, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@...db.de>
> >
> > When building with W=2, the build log is flooded with
> >
> > include/asm-generic/qrwlock.h:65:56: warning: pointer targets in passing argument 2 of 'atomic_try_cmpxchg_acquire' differ in signedness [-Wpointer-sign]
> > include/asm-generic/qrwlock.h:92:53: warning: pointer targets in passing argument 2 of 'atomic_try_cmpxchg_acquire' differ in signedness [-Wpointer-sign]
> > include/asm-generic/qspinlock.h:68:55: warning: pointer targets in passing argument 2 of 'atomic_try_cmpxchg_acquire' differ in signedness [-Wpointer-sign]
> > include/asm-generic/qspinlock.h:82:52: warning: pointer targets in passing argument 2 of 'atomic_try_cmpxchg_acquire' differ in signedness [-Wpointer-sign]
> >
> > The atomics are built on top of signed integers, but the caller
> > doesn't actually care. Just use signed types as well.
Code consistency cares. Fundamentally we're treating it as a u32 here,
using int just because of a confused compiler warning will confuse.
> > @@ -77,7 +77,7 @@ extern void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
> > */
> > static __always_inline void queued_spin_lock(struct qspinlock *lock)
> > {
> > - u32 val = 0;
> > + int val = 0;
> > if (likely(atomic_try_cmpxchg_acquire(&lock->val, &val, _Q_LOCKED_VAL)))
> > return;
> Yes, it shouldn't really matter if the value is defined as int or u32.
> However, the only caveat that I see is queued_spin_lock_slowpath() is
> expecting a u32 argument. Maybe you should cast it back to (u32) when
> calling it.
No, we're not going to confuse the code. That stuff is hard enough as it
is. This warning is garbage and just needs to stay off.
Powered by blists - more mailing lists