Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5996645ybe; Tue, 10 Sep 2019 11:55:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqytQQt8oJ8Rlw51ZS/PhV2mZUk6uHa88OfEkyepfiLyfaFt92gOPqs+BEoJO69gsif6mBze X-Received: by 2002:a05:6402:1606:: with SMTP id f6mr25329763edv.92.1568141737273; Tue, 10 Sep 2019 11:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568141737; cv=none; d=google.com; s=arc-20160816; b=Oh8dZQZ//Vq+kQ1d2jhsPECvQ3QihJDPgwNK0k9OBAugkWepZwFh9aIVuozcIaD4MZ jy8AKjeRkGYbU1fT3FmPbP0R4dBZDyBuYw0pLLtfIaiYTyf7p4/M0Gz1iFKvACOjgMBL llf0mhojfFN77dJj3RvLW8ldV1ocwtKovQV63ST0OYCBtJ4vQzJ3HSR0BsDU5sKSdLCz 4vvlM24jSbjjjltdYZB8yKSKoULdumU6aCuUvUZ3oLxRnif2EFLaZ+sniYSz2w/ap/pe +VY6aAsaV0nkYxzqoGfoLflwJ0/WX0vfTR96PYMOjNaqEOqYP10v/CcKZazP4Zes1oK0 WIFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ASXuikZ+zU5zUL0YiF7CDzSFypLvGx0hXaR7BKy5hpU=; b=gXtn6qpEJPr+z4eHTj1LJrFjAOXtJiJO3m4k+jDXlBN3sbVZ49awhNaz//4pe25xZ7 GhyONBnFDRNDbkFOq+BTy5gYfaiCGQgzc6yq13wwcWuwVpaGeMF5iSGbc+O+X6OE16dZ QIL0d2FUe3TutTauMUbl49Nfh2GjA3Ifj/k+FHWjXoalO5izMOLQXKVMT3jlMUvtpQai grRIx6/dglGwg68tuBMd1bdNvL8ylziiYcZTx6xX2sY0M1EU//PocMZi10avGQpVpTG/ qTdG0CrSEFuMdlKqdXPmdlmENGxFSlCS/vHCL6mAM//YJrAA7EN8/5Exy75KiRO8CBLP nGQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n23si9145059edt.228.2019.09.10.11.55.13; Tue, 10 Sep 2019 11:55:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729545AbfIJKZC (ORCPT + 99 others); Tue, 10 Sep 2019 06:25:02 -0400 Received: from foss.arm.com ([217.140.110.172]:60660 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726960AbfIJKZB (ORCPT ); Tue, 10 Sep 2019 06:25:01 -0400 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 45E591000; Tue, 10 Sep 2019 03:25:01 -0700 (PDT) Received: from localhost (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B154C3F59C; Tue, 10 Sep 2019 03:25:00 -0700 (PDT) Date: Tue, 10 Sep 2019 11:24:59 +0100 From: Andrew Murray To: Arnd Bergmann Cc: Catalin Marinas , Will Deacon , Mark Rutland , Linux ARM , "linux-kernel@vger.kernel.org" , clang-built-linux Subject: Re: [PATCH] arm64: fix unreachable code issue with cmpxchg Message-ID: <20190910102458.GJ9720@e119886-lin.cambridge.arm.com> References: <20190909202153.144970-1-arnd@arndb.de> <20190910092324.GI9720@e119886-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1+81 (426a6c1) (2018-08-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 10, 2019 at 11:38:37AM +0200, Arnd Bergmann wrote: > On Tue, Sep 10, 2019 at 11:23 AM Andrew Murray wrote: > > > > > > arch/arm64/include/asm/cmpxchg.h | 15 ++++++++------- > > > 1 file changed, 8 insertions(+), 7 deletions(-) > > > > > > diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h > > > index a1398f2f9994..fd64dc8a235f 100644 > > > --- a/arch/arm64/include/asm/cmpxchg.h > > > +++ b/arch/arm64/include/asm/cmpxchg.h > > > @@ -19,7 +19,7 @@ > > > * acquire+release for the latter. > > > */ > > > #define __XCHG_CASE(w, sfx, name, sz, mb, nop_lse, acq, acq_lse, rel, cl) \ > > > -static inline u##sz __xchg_case_##name##sz(u##sz x, volatile void *ptr) \ > > > +static __always_inline u##sz __xchg_case_##name##sz(u##sz x, volatile void *ptr)\ > > > > This hunk isn't needed, there is no BUILD_BUG here. > > Right, I noticed this, but it seemed like a good idea regardless given the small > size of the function compared with the overhead of a function call. We clearly > want these to be inlined all the time. > > Same for the others. I'm not so sure - isn't the point of something like OPTIMIZE_INLINING to give more freedom to the tooling (and by virtue of the option - the user)? Surely any decent optimising compiler will do the right thing by inlining small trivial functions that are annotated with inline? And if not, the compiler should be fixed not the kernel - unless of course it causes an issue - and then we should fix those specific cases. There must be dozens of trivial functions that are marked with __inline, I don't think it would make sense to mark those as __always_inline. For example the atomics in atomic_lse.h are trivial but only marked inline. We obviously want them inline, though I don't think we should babysit the compiler to do the right thing. (Also the commit message implies that all the hunks are required to fix this particular issue which they are not). Thanks, Andrew Murray > > > Alternatively is it possible to replace the BUILD_BUG's with something else? > > > > I think because we use BUILD_BUG at the end of a switch statement, we make > > the assumption that size is known at compile time, for this reason we should > > ensure the function containing the BUILD_BUG is __always_inline. > > > > Looking across the kernel where BUILD_BUG is used as a default in a switch > > statment ($ git grep -B 3 BUILD_BUG\( | grep default), most instances are > > within macros, but many are found in an __always_inline function: > > > > arch/x86/kvm/cpuid.h > > mm/kasan/generic.c > > > > Though some are not: > > > > include/linux/signal.h > > arch/arm64/include/asm/arm_dsu/pmu.h > > > > I wonder if there may be a latent mole ready to whack with pmu.h? > > Right, it can't hurt to annotate those as well. I actually have another > fixup for linux/signal.h that I would have to revisit at some point. > See https://bugs.llvm.org/show_bug.cgi?id=38789, I think this is > fixed with clang-9 now, but maybe not with clang-8. > > Arnd