Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5981178ybe; Tue, 10 Sep 2019 11:41:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEVD0g6pq5iCFhZAh+Vqg22g5EJvnaAXkwmqxC1iy3wse7W0snps8GQCBNRD3emGRJTM// X-Received: by 2002:a50:935d:: with SMTP id n29mr32386055eda.294.1568140878502; Tue, 10 Sep 2019 11:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568140878; cv=none; d=google.com; s=arc-20160816; b=m+vWhSamWfvPF6zZeZUNLcabbjvo3sgURFp1y0IeFHgOz4vO+oxup35pCKXLpP0bBZ zXIoomd/4TtknZo1Ji9jS3Z15VjXcTvEVyAfCbtsNh7ga9yoK5D1xzPg+GD6RObl4MZb 2slL9VB6IZF5IxOsBp/QRxaEWVfQyNrJgBgXp+lW79ORAGswoVCdUuQLfeeblBIohHJQ DZ1CMQW0Ie3l8e4y10gzLGjJ7TDogiTSEkjkwUEHEpY17w7R73md6iDUFB65BMUCBO9C cTDKWtijjpwnXhg6QdslINYgqc84goiL0MIS2rjsreNXZxldwlD+rBgc6yPWKadOT+Fu Rj7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=AWfChiuUJemWX/xDu17NLd8EQGs1u1yuvhrocXkkuOg=; b=MXZSUS1TQLdEIy+OtseiZE6W80x25f5n3PCCg+dLGdT2fc6SoQVOzHc863OPK5TaN7 cZtAdtmpcUOgKmtsRMVNIW6xEF2wneLul/CnKgHXqo3EDz/FkLMv32QA7oIn4AVTCHLh aE4FLrkrD2dhj8uV2gcj4Wy9bD5Gx3U+FZT8x0V3j1IoB961NPPFqnvfWvLIONFkr2ec LV4daBcw6YyoX92NVz28Mi2i6YlmzrjbpsB9DbbPr3Z17j3aWwza4u6QWAh5k/n5HEYp YrWoxNC1RhtfHm8G527MoeIxn+3PVpGoAz6+6B8XoE7tGF7KkZe5XeDFdh2W4ahayWC8 kCVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HooNS6Li; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c38si11234652eda.46.2019.09.10.11.40.54; Tue, 10 Sep 2019 11:41:18 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=HooNS6Li; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391850AbfIIVgC (ORCPT + 99 others); Mon, 9 Sep 2019 17:36:02 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39610 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728565AbfIIVgB (ORCPT ); Mon, 9 Sep 2019 17:36:01 -0400 Received: by mail-pl1-f195.google.com with SMTP id bd8so7279702plb.6 for ; Mon, 09 Sep 2019 14:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AWfChiuUJemWX/xDu17NLd8EQGs1u1yuvhrocXkkuOg=; b=HooNS6LiLAXvF9NxFE+eZmqZRW7ToWinYSCthOx4HHhPgE/cRzd5jeOMn2yr5WiqfB WWlxDcwln3c9YsBFYGXWBlVEZ5flrg0DIwF8uyiFU1xecYdg0iM3B7HAOOG9dPpQXnQb xfeUvSxsNN2yfg5eHVNBw2aaE7XZvNv+LAE2fZb99cS3FC30B+OOmiFzjSvTfmOEPbul kmLdtJfpkj1ewRj4T47B1pgiuWnCGu/mCYZHCfP+iFQNfDHLyi3eGGgCva+7KRCA2qQk 9XUmCDuEPWSrnKjgUXKCem2BUmdBQUY9f3Cq7S8+c4ZB7mK1YvHTvKzeO5bcxg9HomkM KujQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AWfChiuUJemWX/xDu17NLd8EQGs1u1yuvhrocXkkuOg=; b=a05KEQqQk3dnQWw6oGqyCnntcRn+MKXCU/wr7PbKyH2IPU/sgKkrErIPBXt9bDR5pa JwWUvAFLH9I/MKBklaKqs2XGChrCHnBakl9sbkzi+u/cnJqIOQeHE3ThUf9RAXEu2PFV um+jBjMpJHZP9BD6nk25AAMy1FTx3hB8MGZpo6MbwDJueYPju/8N3sO8wyt6jcWR7hsk MqLeN9b+fTq2QUlNRSai54HZ2r9uUo/tpngpPwLwM3deqc6aEgUj4+ueFQyGKwk6tred po5fexiGLyxbKZjgFNG2jDI1+M0Ake06GdOaA67dExu9cnZz9+BslKCbbnjGhOmiljV+ +3hg== X-Gm-Message-State: APjAAAXF5ZzU6RYriSESG73MY5dZlI6BzW/y5azxj84Kqa0qTS/S9hkb 9oPMVd+21VpLRE5/nLdlTTlTso+/m5LVQnj3uH2PRA== X-Received: by 2002:a17:902:8484:: with SMTP id c4mr26519733plo.223.1568064960627; Mon, 09 Sep 2019 14:36:00 -0700 (PDT) MIME-Version: 1.0 References: <20190909202153.144970-1-arnd@arndb.de> In-Reply-To: From: Nick Desaulniers Date: Mon, 9 Sep 2019 14:35:49 -0700 Message-ID: Subject: Re: [PATCH] arm64: fix unreachable code issue with cmpxchg To: Arnd Bergmann Cc: Catalin Marinas , Will Deacon , Andrew Murray , Mark Rutland , Linux ARM , LKML , clang-built-linux , Nathan Chancellor Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 9, 2019 at 2:06 PM Nick Desaulniers wrote: > > On Mon, Sep 9, 2019 at 1:21 PM Arnd Bergmann wrote: > > > > On arm64 build with clang, sometimes the __cmpxchg_mb is not inlined > > when CONFIG_OPTIMIZE_INLINING is set. > > Clang then fails a compile-time assertion, because it cannot tell at > > compile time what the size of the argument is: > > > > mm/memcontrol.o: In function `__cmpxchg_mb': > > memcontrol.c:(.text+0x1a4c): undefined reference to `__compiletime_assert_175' > > memcontrol.c:(.text+0x1a4c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `__compiletime_assert_175' > > > > Mark all of the cmpxchg() style functions as __always_inline to > > ensure that the compiler can see the result. > > Acked-by: Nick Desaulniers Also, I think a Link tag may be appropriate as I believe it fixes this report: Reported-by: Nathan Chancellor Link: https://github.com/ClangBuiltLinux/linux/issues/648 > > > > > Signed-off-by: Arnd Bergmann > > --- > > 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)\ > > { \ > > u##sz ret; \ > > unsigned long tmp; \ > > @@ -62,7 +62,7 @@ __XCHG_CASE( , , mb_, 64, dmb ish, nop, , a, l, "memory") > > #undef __XCHG_CASE > > > > #define __XCHG_GEN(sfx) \ > > -static inline unsigned long __xchg##sfx(unsigned long x, \ > > +static __always_inline unsigned long __xchg##sfx(unsigned long x, \ > > volatile void *ptr, \ > > int size) \ > > { \ > > @@ -103,8 +103,9 @@ __XCHG_GEN(_mb) > > #define arch_xchg_release(...) __xchg_wrapper(_rel, __VA_ARGS__) > > #define arch_xchg(...) __xchg_wrapper( _mb, __VA_ARGS__) > > > > -#define __CMPXCHG_CASE(name, sz) \ > > -static inline u##sz __cmpxchg_case_##name##sz(volatile void *ptr, \ > > +#define __CMPXCHG_CASE(name, sz) \ > > +static __always_inline u##sz \ > > +__cmpxchg_case_##name##sz(volatile void *ptr, \ > > u##sz old, \ > > u##sz new) \ > > { \ > > @@ -148,7 +149,7 @@ __CMPXCHG_DBL(_mb) > > #undef __CMPXCHG_DBL > > > > #define __CMPXCHG_GEN(sfx) \ > > -static inline unsigned long __cmpxchg##sfx(volatile void *ptr, \ > > +static __always_inline unsigned long __cmpxchg##sfx(volatile void *ptr, \ > > unsigned long old, \ > > unsigned long new, \ > > int size) \ > > @@ -230,7 +231,7 @@ __CMPXCHG_GEN(_mb) > > }) > > > > #define __CMPWAIT_CASE(w, sfx, sz) \ > > -static inline void __cmpwait_case_##sz(volatile void *ptr, \ > > +static __always_inline void __cmpwait_case_##sz(volatile void *ptr, \ > > unsigned long val) \ > > { \ > > unsigned long tmp; \ > > @@ -255,7 +256,7 @@ __CMPWAIT_CASE( , , 64); > > #undef __CMPWAIT_CASE > > > > #define __CMPWAIT_GEN(sfx) \ > > -static inline void __cmpwait##sfx(volatile void *ptr, \ > > +static __always_inline void __cmpwait##sfx(volatile void *ptr, \ > > unsigned long val, \ > > int size) \ > > { \ > > -- > > 2.20.0 > > > > -- > > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20190909202153.144970-1-arnd%40arndb.de. > > > > -- > Thanks, > ~Nick Desaulniers -- Thanks, ~Nick Desaulniers