Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp67644ybe; Thu, 12 Sep 2019 15:48:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBhU6DqjfYay3Aw0HTHVSEny057kRXjqBTu8zKtBYdIG9WjmbyjQDW+SgJLYRqHtInpWWQ X-Received: by 2002:a17:906:560d:: with SMTP id f13mr10883270ejq.168.1568328532983; Thu, 12 Sep 2019 15:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568328532; cv=none; d=google.com; s=arc-20160816; b=qtaf//WKZHxlHyjflPEgsPfFoCGK/GmC/j4RkVowem0tGLyZLebD3jLeOQRELV18DZ NDEAQMbfJnkp7cJZOt1rqSF3OUtsW2XQYIhsy+Do88sfNigRct1AvVet31Qa1ncuE5c2 9GxUSGz9Qm/2gXESqVN3sM07RnFXjEWkMp3sYqUaV//kM3cqVWy0b1U5chbMT6/Eo7Cj A+dBO8pWZe4yHnxTwzli7/0Dt+/g2yiqC5eA8JRvf3y2roJ5+IqjdmZ6RbCdrsQ4ps8k KMARYyD+NA+bbaTWqcD93jlAqmRh0ml5AuBCTb4KJqh3eNST2RZWT7cJ7PUh6K+UDrCG epCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bHXzwTj1CMARSN6ZAcRX363CWyTLc803EsOjz2eKDbI=; b=nH+IVyLyiQwSWT7hZhYIuXtkAJCeWDw4VBEs1sKZtu+V7Y6iIIfRrVfP18zVwQIVFm fpto4PEfd5sYis9H4ILRK5chm6xxvQZGjtZrRBCZdWulJA3b0Pl9JARRlAd9NXz07sku L4dUzBMZVi6J2fCC6WnXTYu+USOrFFVpNVcImLqeNNBRwdmsQthtD9hYoeWuw7Nrmiu4 Zeu7yKyDUSIaL8G6DnvZZZ+2L17xmgzdTITNxoCgYchVQlXCQXu8BJzxRFLGKFIfsJQ8 FzQhstPFGpmS+IhemP4mvFKndGbyw9W3wbz5njbZrfLH0qSWJ4bBEnEJ0x2rLQztEfJr 7hxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=eLXiAiv+; 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 d12si3377534ejj.369.2019.09.12.15.48.29; Thu, 12 Sep 2019 15:48:52 -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=@rasmusvillemoes.dk header.s=google header.b=eLXiAiv+; 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 S1729529AbfILWTx (ORCPT + 99 others); Thu, 12 Sep 2019 18:19:53 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:41032 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726706AbfILWTs (ORCPT ); Thu, 12 Sep 2019 18:19:48 -0400 Received: by mail-ed1-f67.google.com with SMTP id z9so25311540edq.8 for ; Thu, 12 Sep 2019 15:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bHXzwTj1CMARSN6ZAcRX363CWyTLc803EsOjz2eKDbI=; b=eLXiAiv+V7up87LlulNtqY4d4BZgs3RzhC/be0fNEvGibz4p4JUS7ZH+GQLzrI3xxk DSEjaPDX4yw0tRaSG8uwhdrBke3YQEil0BmmQSid+1R8bpWmSowayCBe3oAyNHhkorYX HLU2i7iXfKcwMwSw3vOIZ9+9HaR9e6afqVfJ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bHXzwTj1CMARSN6ZAcRX363CWyTLc803EsOjz2eKDbI=; b=oWg21UhJ29Nlg1LHYnuJ0A+JY6JxpLy9D1K19CRJqnjaKj8LgtoUEQqtHPmk8GZbff +lXXMmuZ8s9mhrhH+jfKWBOGED8V1eHADspkSLJ/MVIv3kHFNr+rA6spMsNUdA4m0JFQ B+1kngWlKimcFyavFhamk1oxtDd1CmrIuBxeFP7Pu5HYo5IvRvvAynvWXQRTEyM+8Qzk 7tgE7wRxfvEXkOtv8yEfjF4vbOTuVQgh6Q7BNRkyOhqN/eJM9chyu/fg8qDIMO7VCI1F UhCgrs4A7rQc2ApPf2rCgR7/6mPp8bspgDpcybjdgNRhTVgojubEGM0PsqAgNtQ2U7Po YKQA== X-Gm-Message-State: APjAAAWAz8Zkt0QLl071qxMGM4Urb93Uzzhj+fSsjtY0vN03UcaWNrY1 LYLS7xrqbcHL2bqzj2hGcSiS74cgL5Wdlr7w X-Received: by 2002:a17:906:4c2:: with SMTP id g2mr9548279eja.38.1568326786987; Thu, 12 Sep 2019 15:19:46 -0700 (PDT) Received: from prevas-ravi.prevas.se (ip-5-186-115-35.cgn.fibianet.dk. [5.186.115.35]) by smtp.gmail.com with ESMTPSA id 36sm4305228edz.92.2019.09.12.15.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2019 15:19:46 -0700 (PDT) From: Rasmus Villemoes To: Miguel Ojeda , ndesaulniers@google.com, Masahiro Yamada Cc: Greg Kroah-Hartman , Ingo Molnar , Linus Torvalds , Nadav Amit , x86@kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Rasmus Villemoes Subject: [PATCH v3 4/6] compiler-types.h: add asm_inline definition Date: Fri, 13 Sep 2019 00:19:25 +0200 Message-Id: <20190912221927.18641-5-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190912221927.18641-1-linux@rasmusvillemoes.dk> References: <20190830231527.22304-1-linux@rasmusvillemoes.dk> <20190912221927.18641-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds an asm_inline macro which expands to "asm inline" [1] when the compiler supports it. This is currently gcc 9.1+, gcc 8.3 and (once released) gcc 7.5 [2]. It expands to just "asm" for other compilers. Using asm inline("foo") instead of asm("foo") overrules gcc's heuristic estimate of the size of the code represented by the asm() statement, and makes gcc use the minimum possible size instead. That can in turn affect gcc's inlining decisions. I wasn't sure whether to make this a function-like macro or not - this way, it can be combined with volatile as asm_inline volatile() but perhaps we'd prefer to spell that asm_inline_volatile() anyway. The Kconfig logic is taken from an RFC patch by Masahiro Yamada [3]. [1] Technically, asm __inline, since both inline and __inline__ are macros that attach various attributes, making gcc barf if one literally does "asm inline()". However, the third spelling __inline is available for referring to the bare keyword. [2] https://lore.kernel.org/lkml/20190907001411.GG9749@gate.crashing.org/ [3] https://lore.kernel.org/lkml/1544695154-15250-1-git-send-email-yamada.masahiro@socionext.com/ Signed-off-by: Rasmus Villemoes --- include/linux/compiler_types.h | 6 ++++++ init/Kconfig | 3 +++ 2 files changed, 9 insertions(+) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index ee49be6d6088..2bf316fe0a20 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -198,6 +198,12 @@ struct ftrace_likely_data { #define asm_volatile_goto(x...) asm goto(x) #endif +#ifdef CONFIG_CC_HAS_ASM_INLINE +#define asm_inline asm __inline +#else +#define asm_inline asm +#endif + #ifndef __no_fgcse # define __no_fgcse #endif diff --git a/init/Kconfig b/init/Kconfig index bd7d650d4a99..7fee5978dd73 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -30,6 +30,9 @@ config CC_CAN_LINK config CC_HAS_ASM_GOTO def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) +config CC_HAS_ASM_INLINE + def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null) + config CC_HAS_WARN_MAYBE_UNINITIALIZED def_bool $(cc-option,-Wmaybe-uninitialized) help -- 2.20.1