From patchwork Mon Jun 26 23:03:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rientjes X-Patchwork-Id: 9810589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AAB4F603D7 for ; Mon, 26 Jun 2017 23:04:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94D6127F88 for ; Mon, 26 Jun 2017 23:04:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 895A4280DE; Mon, 26 Jun 2017 23:04:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E09F227F88 for ; Mon, 26 Jun 2017 23:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=lx8y35N5JlG5D+dzayLjhmhu4XLA5UOXffhMehUywps=; b=HJu8ql7FrhMTYo D5sd1bcKnoJOkjGqdh/SUxhp7jgFJukm5Q7KqD5Q87eusyMenCesY/CsSeyAkQbb4zTcMnjc/nyLx eJ8m4izPtrEO6mnwSW79T9Fex4X6iwEsugRIPQX9mfh+D8IRcW196o2+uFRqp53rZFqOciZ9kvTEA DFJ3q7ewDvhcwL+bkI6Lw0mZr5DQ/z9P/puF1tBUBTgbTVZU7RdzRw4q1yQkxnPHKmzNLlyrJLtLs 2zraMd6AI6mZMcguPeRFvUMXVpYx/I0QIqHq0HtgXDgZQp3wMnseY0oWtNQEbiHxppPd7kZ30gpDG /5SY7voW1g1otfT6GcVw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dPd2y-0004wc-Jx; Mon, 26 Jun 2017 23:03:56 +0000 Received: from mail-pg0-x22d.google.com ([2607:f8b0:400e:c05::22d]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dPd2u-0004vq-Pd for linux-arm-kernel@lists.infradead.org; Mon, 26 Jun 2017 23:03:54 +0000 Received: by mail-pg0-x22d.google.com with SMTP id f127so6721766pgc.0 for ; Mon, 26 Jun 2017 16:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=6eb0oaS8o2/hsFqxR5GYxDqDLlN4Ufs7tMUoW3rZ1ko=; b=fHlq50Pceh6ip9K8TEojmq0U07CwJ2ub80ZLA5/HtFVdJn30kQFsmnBEYQDk7iGx/P 06X+Yed9MK71ZaeOu6Gc2iB3nYWEC3t4t2gqWDIfE6TljNje6PY4Bx6mRQjyxNDTZhQy vqZGqJ597HMTJs+jtMsNymH51nrjMZw8oSw6qDHv6tZ9A5p/68oyZPIFT8T8QgcoDO+j 1MWNzmg06kKSqF8Ur6gMBnqE8JZDjugAJt7Na2nCW0f0C7Yk9LLe2eaciOooj2eU3X5k e8RcfbLcjD5TDykFRggZII8f+mpFuUr8Bet6RnzjBTjCCbk7yFJ1NXsuJyepPWx8376U W+9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:user-agent :mime-version; bh=6eb0oaS8o2/hsFqxR5GYxDqDLlN4Ufs7tMUoW3rZ1ko=; b=ggg1HGP5y9cTTY26rlI5wZHbKa+AdECZiwh14jS8UJ2ArCe3F4gxdyEt3u8Yyz1LpC JnTSRzWKRT3ZDcGh7nCovhxtrgB+bN0fbh7ecEIuDEXNXGYDKtzW/ZcBI8H8M1oI9okf U7ZIOb4otHeK/r6aLVnO/6RoLA6y3FrmQLrL4xcBzGSJ/pystU0DDBSigeWrmMPzWCUH QPsplokYAxiYG+mGkVv5vOR18kywXuMvsoM1jPIc9Ssf8tonLE4xs9yBEaW4TWXBJrFh /1RaTNc6G+Egu5S4LTuDX1T0d2nc3Dq3c5V0t+BS4+B3N3VQA3iyC8GWTsS4yO+ckcBt q8QQ== X-Gm-Message-State: AKS2vOzjEmB3FUpWEWgvKwnxoluS/+3TYj00XrzB+SJz/I2QMTbPP/ly Lk6HnaaJj4YuJ90R X-Received: by 10.84.241.198 with SMTP id t6mr2528198plm.48.1498518211383; Mon, 26 Jun 2017 16:03:31 -0700 (PDT) Received: from [2620:15c:17:3:a951:8b6c:2d2c:fac0] ([2620:15c:17:3:a951:8b6c:2d2c:fac0]) by smtp.gmail.com with ESMTPSA id a29sm2091878pfg.30.2017.06.26.16.03.30 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Jun 2017 16:03:30 -0700 (PDT) Date: Mon, 26 Jun 2017 16:03:29 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton , Sodagudi Prasad Subject: [patch resend 4.12] compiler, clang: always inline when CONFIG_OPTIMIZE_INLINING is disabled Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170626_160352_949668_4838AF5E X-CRM114-Status: GOOD ( 12.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , peterz@infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, Matthias Kaehlcke , mingo@kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The motivation of commit abb2ea7dfd82 ("compiler, clang: suppress warning for unused static inline functions") is to suppress clang's warnings about unused static inline functions. For configs without CONFIG_OPTIMIZE_INLINING enabled, such as any non-x86 architecture, `inline' in the kernel implies that __attribute__((always_inline)) is used. Some code depends on that behavior, see https://lkml.org/lkml/2017/6/13/918: net/built-in.o: In function `__xchg_mb': arch/arm64/include/asm/cmpxchg.h:99: undefined reference to `__compiletime_assert_99' arch/arm64/include/asm/cmpxchg.h:99: undefined reference to `__compiletime_assert_99 The full fix would be to identify these breakages and annotate the functions with __always_inline instead of `inline'. But since we are late in the 4.12-rc cycle, simply carry forward the forced inlining behavior and work toward moving arm64, and other architectures, toward CONFIG_OPTIMIZE_INLINING behavior. Reported-by: Sodagudi Prasad Tested-by: Matthias Kaehlcke Signed-off-by: David Rientjes Tested-by: Sodagudi Prasad --- Resend of http://marc.info/?l=linux-kernel&m=149681501816319 for 4.12 inclusion. Prasad, please add your Tested-by. include/linux/compiler-clang.h | 8 -------- include/linux/compiler-gcc.h | 18 +++++++++++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -15,11 +15,3 @@ * with any version that can compile the kernel */ #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) - -/* - * GCC does not warn about unused static inline functions for - * -Wunused-function. This turns out to avoid the need for complex #ifdef - * directives. Suppress the warning in clang as well. - */ -#undef inline -#define inline inline __attribute__((unused)) notrace diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -66,18 +66,22 @@ /* * Force always-inline if the user requests it so via the .config, - * or if gcc is too old: + * or if gcc is too old. + * GCC does not warn about unused static inline functions for + * -Wunused-function. This turns out to avoid the need for complex #ifdef + * directives. Suppress the warning in clang as well by using "unused" + * function attribute, which is redundant but not harmful for gcc. */ #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) -#define inline inline __attribute__((always_inline)) notrace -#define __inline__ __inline__ __attribute__((always_inline)) notrace -#define __inline __inline __attribute__((always_inline)) notrace +#define inline inline __attribute__((always_inline,unused)) notrace +#define __inline__ __inline__ __attribute__((always_inline,unused)) notrace +#define __inline __inline __attribute__((always_inline,unused)) notrace #else /* A lot of inline functions can cause havoc with function tracing */ -#define inline inline notrace -#define __inline__ __inline__ notrace -#define __inline __inline notrace +#define inline inline __attribute__((unused)) notrace +#define __inline__ __inline__ __attribute__((unused)) notrace +#define __inline __inline __attribute__((unused)) notrace #endif #define __always_inline inline __attribute__((always_inline))