Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5994484ybe; Tue, 10 Sep 2019 11:53:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0obSLmmxBYn5o8Y2Kn2VUkimMd/SwS+p+5/jRrDbDaavuyBaCCsIaAkw8bcIf/iPapzvU X-Received: by 2002:a17:906:7cc7:: with SMTP id h7mr4255717ejp.204.1568141617550; Tue, 10 Sep 2019 11:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568141617; cv=none; d=google.com; s=arc-20160816; b=BEGJb+LsnqMmIOPIkQU4bY2Ajyg86jfJBcRRU8dHeHRkN3Ha+3T+NV4wY7m76rAP6m geaJVp1zgWB4R/6zm8OIu9NJ7OJmuNFN2rkSf9jRya7ODNsPYYDjmfqCNJweYmBBLLlz mjOJifJUHlKO7KhUutlPyM5kJMkjt8spygypdmKuA7b0Vbk8453G4+wToMSnQt7SdoAu n74LudM0kZTEQaFUirZoAAs4MdLjZWNyOMaYevWlizSVK1Qbbb6zeQSHmBuPqTmW6lYc 7tEpNdDVya4tqm77HBLU5KLclW9UAaCJ3CAD7+QxwneSuFtqqRCwDEfWzC+RLDDRvsL3 1KMg== 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; bh=7BZdQMWt/4gR8KdMEOxeANPATM7+OW7WAKZb9Cg8SzQ=; b=VynaElihsWzOlOJNgjH9OAb+EK/uhvsmhwEFKSDxc5F3sCkpBMhqFQr9kdiVZ7aDbx 4oGFhpGJRmN2g3VjrUeVMF4IbWbYsTpSxNgSVZNmpuSoHNDV3FLaneU+A6LfofGNWWfz r19dIYUzQYijc/qkCnwZrC9rn13MnxCYxGOB8bA5uYd0i5nuVsAJfEjQs/OZP9Rn6fBm wiDA3zkaonQdsBNvN4n59JHN7XmZw5XBdCL4zyIU5RaEIAs6bYPO4FvATbzyw5n3idgd PIaYBA+aN6fVlrsLuDAMi80O0PQWy5a0L3WpphtjLrzlaCSWyqnC9xc0xgyJiMaHQOEP BvlQ== 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 b8si9104002edr.350.2019.09.10.11.53.13; Tue, 10 Sep 2019 11:53: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 S2390199AbfIJJiz (ORCPT + 99 others); Tue, 10 Sep 2019 05:38:55 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:45745 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731249AbfIJJiz (ORCPT ); Tue, 10 Sep 2019 05:38:55 -0400 Received: by mail-qk1-f195.google.com with SMTP id z67so16218660qkb.12 for ; Tue, 10 Sep 2019 02:38:54 -0700 (PDT) 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=7BZdQMWt/4gR8KdMEOxeANPATM7+OW7WAKZb9Cg8SzQ=; b=Z7OGTfQ+LxfKSKU1UavhwtLfodbyShLBUYk+90kGieOQGxSx4WXoI6Re5bs5qOJszO Q3fmX6sF5IU3PaJSQPIfvRsqLWAsOTT+56R7pFvZAJIedd+RmHaY8tVBBswgn28vslGQ ONGRm6mnVlnI57cOsfg9Wm1+tv6hdp5eA+XOIMo0Sud61gvbg4QMxQoGID2ehkMkI/UE t0zplJqCMhv+3xln0xJEndrT6acUNe7v6nVwDbKtfihC3OwpQLv8d3ql3iFOSfGzEP3D ZG+pyZFwVdI0PQbp7ntkfkwVqTdvQOtfgpJ2p3JEAt67Nv1YHGDX/cNbQ/v0AZWTFS8U NpLQ== X-Gm-Message-State: APjAAAUldd7oYZ/fHgwUdLRyyBiYDSaU3HiMUbMkERqKlqWvpj0ObSQd J5DpJATxq6QGUh1HZOvuzwsV2DoIUTCK7T0eI00= X-Received: by 2002:ae9:ee06:: with SMTP id i6mr7667748qkg.3.1568108334116; Tue, 10 Sep 2019 02:38:54 -0700 (PDT) MIME-Version: 1.0 References: <20190909202153.144970-1-arnd@arndb.de> <20190910092324.GI9720@e119886-lin.cambridge.arm.com> In-Reply-To: <20190910092324.GI9720@e119886-lin.cambridge.arm.com> From: Arnd Bergmann Date: Tue, 10 Sep 2019 11:38:37 +0200 Message-ID: Subject: Re: [PATCH] arm64: fix unreachable code issue with cmpxchg To: Andrew Murray Cc: Catalin Marinas , Will Deacon , Mark Rutland , Linux ARM , "linux-kernel@vger.kernel.org" , clang-built-linux 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 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. > 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