From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0A736118 for ; Fri, 24 Mar 2023 14:13:18 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2A1AF11FB; Fri, 24 Mar 2023 07:14:02 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.55.116]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 367B43F71E; Fri, 24 Mar 2023 07:13:16 -0700 (PDT) Date: Fri, 24 Mar 2023 14:13:13 +0000 From: Mark Rutland To: Uros Bizjak Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org, linux-perf-users@vger.kernel.org, Will Deacon , Peter Zijlstra , Boqun Feng Subject: Re: [PATCH 01/10] locking/atomic: Add missing cast to try_cmpxchg() fallbacks Message-ID: References: <20230305205628.27385-1-ubizjak@gmail.com> <20230305205628.27385-2-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: loongarch@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230305205628.27385-2-ubizjak@gmail.com> On Sun, Mar 05, 2023 at 09:56:19PM +0100, Uros Bizjak wrote: > Cast _oldp to the type of _ptr to avoid incompatible-pointer-types warning. Can you give an example of where we are passing an incompatible pointer? That sounds indicative of a bug in the caller, but maybe I'm missing some reason this is necessary due to some indirection. > Fixes: 29f006fdefe6 ("asm-generic/atomic: Add try_cmpxchg() fallbacks") I'm not sure that this needs a fixes tag. Does anything go wrong today, or only later in this series? Thanks, Mark. > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Mark Rutland > Signed-off-by: Uros Bizjak > --- > include/linux/atomic/atomic-arch-fallback.h | 18 +++++++++--------- > scripts/atomic/gen-atomic-fallback.sh | 2 +- > 2 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/include/linux/atomic/atomic-arch-fallback.h b/include/linux/atomic/atomic-arch-fallback.h > index 77bc5522e61c..19debd501ee7 100644 > --- a/include/linux/atomic/atomic-arch-fallback.h > +++ b/include/linux/atomic/atomic-arch-fallback.h > @@ -87,7 +87,7 @@ > #ifndef arch_try_cmpxchg > #define arch_try_cmpxchg(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -98,7 +98,7 @@ > #ifndef arch_try_cmpxchg_acquire > #define arch_try_cmpxchg_acquire(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg_acquire((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -109,7 +109,7 @@ > #ifndef arch_try_cmpxchg_release > #define arch_try_cmpxchg_release(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg_release((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -120,7 +120,7 @@ > #ifndef arch_try_cmpxchg_relaxed > #define arch_try_cmpxchg_relaxed(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg_relaxed((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -157,7 +157,7 @@ > #ifndef arch_try_cmpxchg64 > #define arch_try_cmpxchg64(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg64((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -168,7 +168,7 @@ > #ifndef arch_try_cmpxchg64_acquire > #define arch_try_cmpxchg64_acquire(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg64_acquire((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -179,7 +179,7 @@ > #ifndef arch_try_cmpxchg64_release > #define arch_try_cmpxchg64_release(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg64_release((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -190,7 +190,7 @@ > #ifndef arch_try_cmpxchg64_relaxed > #define arch_try_cmpxchg64_relaxed(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg64_relaxed((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -2456,4 +2456,4 @@ arch_atomic64_dec_if_positive(atomic64_t *v) > #endif > > #endif /* _LINUX_ATOMIC_FALLBACK_H */ > -// b5e87bdd5ede61470c29f7a7e4de781af3770f09 > +// 1b4d4c82ae653389cd1538d5b07170267d9b3837 > diff --git a/scripts/atomic/gen-atomic-fallback.sh b/scripts/atomic/gen-atomic-fallback.sh > index 3a07695e3c89..39f447161108 100755 > --- a/scripts/atomic/gen-atomic-fallback.sh > +++ b/scripts/atomic/gen-atomic-fallback.sh > @@ -171,7 +171,7 @@ cat < #ifndef arch_try_${cmpxchg}${order} > #define arch_try_${cmpxchg}${order}(_ptr, _oldp, _new) \\ > ({ \\ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \\ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \\ > ___r = arch_${cmpxchg}${order}((_ptr), ___o, (_new)); \\ > if (unlikely(___r != ___o)) \\ > *___op = ___r; \\ > -- > 2.39.2 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6125C76196 for ; Fri, 24 Mar 2023 14:14:26 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4PjkjY0LWMz3fP0 for ; Sat, 25 Mar 2023 01:14:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arm.com (client-ip=217.140.110.172; helo=foss.arm.com; envelope-from=mark.rutland@arm.com; receiver=) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lists.ozlabs.org (Postfix) with ESMTP id 4Pjkhx3qlwz3f8S for ; Sat, 25 Mar 2023 01:13:50 +1100 (AEDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2A1AF11FB; Fri, 24 Mar 2023 07:14:02 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.55.116]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 367B43F71E; Fri, 24 Mar 2023 07:13:16 -0700 (PDT) Date: Fri, 24 Mar 2023 14:13:13 +0000 From: Mark Rutland To: Uros Bizjak Subject: Re: [PATCH 01/10] locking/atomic: Add missing cast to try_cmpxchg() fallbacks Message-ID: References: <20230305205628.27385-1-ubizjak@gmail.com> <20230305205628.27385-2-ubizjak@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230305205628.27385-2-ubizjak@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Peter Zijlstra , Will Deacon , Boqun Feng , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, loongarch@lists.linux.dev, linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Sun, Mar 05, 2023 at 09:56:19PM +0100, Uros Bizjak wrote: > Cast _oldp to the type of _ptr to avoid incompatible-pointer-types warning. Can you give an example of where we are passing an incompatible pointer? That sounds indicative of a bug in the caller, but maybe I'm missing some reason this is necessary due to some indirection. > Fixes: 29f006fdefe6 ("asm-generic/atomic: Add try_cmpxchg() fallbacks") I'm not sure that this needs a fixes tag. Does anything go wrong today, or only later in this series? Thanks, Mark. > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Mark Rutland > Signed-off-by: Uros Bizjak > --- > include/linux/atomic/atomic-arch-fallback.h | 18 +++++++++--------- > scripts/atomic/gen-atomic-fallback.sh | 2 +- > 2 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/include/linux/atomic/atomic-arch-fallback.h b/include/linux/atomic/atomic-arch-fallback.h > index 77bc5522e61c..19debd501ee7 100644 > --- a/include/linux/atomic/atomic-arch-fallback.h > +++ b/include/linux/atomic/atomic-arch-fallback.h > @@ -87,7 +87,7 @@ > #ifndef arch_try_cmpxchg > #define arch_try_cmpxchg(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -98,7 +98,7 @@ > #ifndef arch_try_cmpxchg_acquire > #define arch_try_cmpxchg_acquire(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg_acquire((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -109,7 +109,7 @@ > #ifndef arch_try_cmpxchg_release > #define arch_try_cmpxchg_release(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg_release((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -120,7 +120,7 @@ > #ifndef arch_try_cmpxchg_relaxed > #define arch_try_cmpxchg_relaxed(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg_relaxed((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -157,7 +157,7 @@ > #ifndef arch_try_cmpxchg64 > #define arch_try_cmpxchg64(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg64((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -168,7 +168,7 @@ > #ifndef arch_try_cmpxchg64_acquire > #define arch_try_cmpxchg64_acquire(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg64_acquire((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -179,7 +179,7 @@ > #ifndef arch_try_cmpxchg64_release > #define arch_try_cmpxchg64_release(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg64_release((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -190,7 +190,7 @@ > #ifndef arch_try_cmpxchg64_relaxed > #define arch_try_cmpxchg64_relaxed(_ptr, _oldp, _new) \ > ({ \ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \ > ___r = arch_cmpxchg64_relaxed((_ptr), ___o, (_new)); \ > if (unlikely(___r != ___o)) \ > *___op = ___r; \ > @@ -2456,4 +2456,4 @@ arch_atomic64_dec_if_positive(atomic64_t *v) > #endif > > #endif /* _LINUX_ATOMIC_FALLBACK_H */ > -// b5e87bdd5ede61470c29f7a7e4de781af3770f09 > +// 1b4d4c82ae653389cd1538d5b07170267d9b3837 > diff --git a/scripts/atomic/gen-atomic-fallback.sh b/scripts/atomic/gen-atomic-fallback.sh > index 3a07695e3c89..39f447161108 100755 > --- a/scripts/atomic/gen-atomic-fallback.sh > +++ b/scripts/atomic/gen-atomic-fallback.sh > @@ -171,7 +171,7 @@ cat < #ifndef arch_try_${cmpxchg}${order} > #define arch_try_${cmpxchg}${order}(_ptr, _oldp, _new) \\ > ({ \\ > - typeof(*(_ptr)) *___op = (_oldp), ___o = *___op, ___r; \\ > + typeof(*(_ptr)) *___op = (typeof(_ptr))(_oldp), ___o = *___op, ___r; \\ > ___r = arch_${cmpxchg}${order}((_ptr), ___o, (_new)); \\ > if (unlikely(___r != ___o)) \\ > *___op = ___r; \\ > -- > 2.39.2 >