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 X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3657BC282DD for ; Fri, 10 Jan 2020 17:45:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 141F2206ED for ; Fri, 10 Jan 2020 17:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728540AbgAJRpL (ORCPT ); Fri, 10 Jan 2020 12:45:11 -0500 Received: from foss.arm.com ([217.140.110.172]:49260 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727742AbgAJRpL (ORCPT ); Fri, 10 Jan 2020 12:45:11 -0500 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 8806C30E; Fri, 10 Jan 2020 09:45:10 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 19AB03F6C4; Fri, 10 Jan 2020 09:45:08 -0800 (PST) Date: Fri, 10 Jan 2020 17:45:07 +0000 From: Mark Rutland To: Will Deacon Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kernel-team@android.com, Michael Ellerman , Peter Zijlstra , Linus Torvalds , Segher Boessenkool , Christian Borntraeger , Luc Van Oostenryck , Arnd Bergmann Subject: Re: [RFC PATCH 8/8] arm64: barrier: Use '__unqual_scalar_typeof' for acquire/release macros Message-ID: <20200110174506.GK33536@lakrids.cambridge.arm.com> References: <20200110165636.28035-1-will@kernel.org> <20200110165636.28035-9-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200110165636.28035-9-will@kernel.org> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 10, 2020 at 04:56:36PM +0000, Will Deacon wrote: > Passing volatile-qualified pointers to the arm64 implementations of the > load-acquire/store-release macros results in a re-load from the stack > and a bunch of associated stack-protector churn due to the temporary > result variable inheriting the volatile semantics thanks to the use of > 'typeof()'. > > Define these temporary variables using 'unqual_scalar_typeof' to drop > the volatile qualifier in the case that they are scalar types. > > Cc: Mark Rutland > Cc: Linus Torvalds > Cc: Peter Zijlstra > Cc: Arnd Bergmann > Signed-off-by: Will Deacon Based on my understanding of __unqual_scalar_typeof(), these changes look sound to me: Acked-by: Mark Rutland Mark. > --- > arch/arm64/include/asm/barrier.h | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h > index 7d9cc5ec4971..fb4c27506ef4 100644 > --- a/arch/arm64/include/asm/barrier.h > +++ b/arch/arm64/include/asm/barrier.h > @@ -76,8 +76,8 @@ static inline unsigned long array_index_mask_nospec(unsigned long idx, > #define __smp_store_release(p, v) \ > do { \ > typeof(p) __p = (p); \ > - union { typeof(*p) __val; char __c[1]; } __u = \ > - { .__val = (__force typeof(*p)) (v) }; \ > + union { __unqual_scalar_typeof(*p) __val; char __c[1]; } __u = \ > + { .__val = (__force __unqual_scalar_typeof(*p)) (v) }; \ > compiletime_assert_atomic_type(*p); \ > kasan_check_write(__p, sizeof(*p)); \ > switch (sizeof(*p)) { \ > @@ -110,7 +110,7 @@ do { \ > > #define __smp_load_acquire(p) \ > ({ \ > - union { typeof(*p) __val; char __c[1]; } __u; \ > + union { __unqual_scalar_typeof(*p) __val; char __c[1]; } __u; \ > typeof(p) __p = (p); \ > compiletime_assert_atomic_type(*p); \ > kasan_check_read(__p, sizeof(*p)); \ > @@ -136,33 +136,33 @@ do { \ > : "Q" (*__p) : "memory"); \ > break; \ > } \ > - __u.__val; \ > + (typeof(*p))__u.__val; \ > }) > > #define smp_cond_load_relaxed(ptr, cond_expr) \ > ({ \ > typeof(ptr) __PTR = (ptr); \ > - typeof(*ptr) VAL; \ > + __unqual_scalar_typeof(*ptr) VAL; \ > for (;;) { \ > VAL = READ_ONCE(*__PTR); \ > if (cond_expr) \ > break; \ > __cmpwait_relaxed(__PTR, VAL); \ > } \ > - VAL; \ > + (typeof(*ptr))VAL; \ > }) > > #define smp_cond_load_acquire(ptr, cond_expr) \ > ({ \ > typeof(ptr) __PTR = (ptr); \ > - typeof(*ptr) VAL; \ > + __unqual_scalar_typeof(*ptr) VAL; \ > for (;;) { \ > VAL = smp_load_acquire(__PTR); \ > if (cond_expr) \ > break; \ > __cmpwait_relaxed(__PTR, VAL); \ > } \ > - VAL; \ > + (typeof(*ptr))VAL; \ > }) > > #include > -- > 2.25.0.rc1.283.g88dfdc4193-goog >