From patchwork Wed Aug 2 15:06:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Elver X-Patchwork-Id: 130001 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp611216vqx; Wed, 2 Aug 2023 10:23:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPgvA+LHTJYFCnEX/38p0N5Q85hnSJi+bsovMliHr77mX38udDXonDLfwOJ5j93Y+BjLci X-Received: by 2002:a19:6418:0:b0:4f8:6e6e:4100 with SMTP id y24-20020a196418000000b004f86e6e4100mr5072904lfb.52.1690997007018; Wed, 02 Aug 2023 10:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690997006; cv=none; d=google.com; s=arc-20160816; b=bKTAqNl0I0g3YJF7FvwtjhpNagG5wlFqKVVyuuhbLcj0swD2yQ15szqDq1KXb/vZTe KtZjNUJ+kx9Wdx+AUH5trUps9tm6PW/+bgoBVffxgoKd8RIWBIbtcftvKV7LeWMI5s5q IkBNncbVEILlqE3oZSs6ZR0sm7yqk9P1ZO6Ad96jJtOOCF9Eyl5AwGHvjnP9rUtJnVz1 sf5xyzMPtkHgqUa5nvn0siy4PtxGWV6PBw2ZVXgXGTGxo4p59nOMOjTjgOIHQOyWQA1J jbnfB5gVYQWr9+wCnOEVlvDJ2Qhkv+6brp/qprAWgMR6q9nCoxANi9orjOzE64k7/aOP vN0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=ODlQqQRL7j+ioqTq3MDMk7BwHCUeRlM+arLr48y6tNA=; fh=lNGG3jUJkf8aHp9vpCSrpIUZatSpkge/xU1iDADXpuE=; b=PdfJ31rwCXtkIj72qWIvdbTCud45iH5MYXXwVzLjanRlTCWC7/xsluzlboEr94pKx4 ElJOf5wmaL0ZcDp3TSKUnCTr3vMmISYBYsJZZw8/hN99IS1tazUhfTR+B4cPE0SKmmzN iX2aot7gqJbIT+IrtdpvCME/wrLL6s4qmsTNqCgt0+tBKXvXElVWdV+OgS5++N6EfeBz esSDvX09Qu2EiU+oUxOMJ7tK802vslctKOPyDGjOLI5jxUgXejSD1dql7TOIF6DUWjRs /oxP8DAweHgp2dr76EfzFBbWyDG0mrdFB9H66LtCxb8ujWair3b7aCE2GXJMyLjSF3sX U7Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=SlPCrS1x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a50ed8a000000b005223e8841desi10332291edr.173.2023.08.02.10.23.02; Wed, 02 Aug 2023 10:23:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=SlPCrS1x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232766AbjHBPIT (ORCPT + 99 others); Wed, 2 Aug 2023 11:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233979AbjHBPHs (ORCPT ); Wed, 2 Aug 2023 11:07:48 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45BEB2D63 for ; Wed, 2 Aug 2023 08:07:29 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-c647150c254so1841646276.1 for ; Wed, 02 Aug 2023 08:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690988848; x=1691593648; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ODlQqQRL7j+ioqTq3MDMk7BwHCUeRlM+arLr48y6tNA=; b=SlPCrS1xmbnWErc1CKgkJPNCNs7mvtB7anzE5xNQkivhTRzEbUhgWQnPMVMtb3VXh+ ZBtkHFgVBWyYK9aJXUFag88OyruHvsTDz0sROofPxloDejTDL0u7WLbUzdd0bjeB+jSN oTfyPlrZyq9uO50GbK472SiCDM3EoN7lghNrsmGgmy5MZ0QBWWSW/G3ysfDRPCvjzTil jIk0DCPgZI/Khn3fRGwbxbnH3v6fhL+esA/xOgDvjtUUcvHxo0iNIh9aXl4CxUkdcmD8 fJBSw5TBqO8FHGk7VqWk7U50HciveTvD2sCx9Bd9M88m/E0/TJ8dDqT/2Fi+tjLdynkA hc8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690988848; x=1691593648; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ODlQqQRL7j+ioqTq3MDMk7BwHCUeRlM+arLr48y6tNA=; b=KuUvqrPJj0JFxpO8ZScOXBvED6FK/MrEQ7uW9wj+ZkgZeQo3nI+TG1diuUeolmQf75 D/ldGWUYESEbBtOFnOA9AJ9ibduPMFIWyUPg6H9N4Ja3YFKt8Bn139JRos90ktqDONtB MN60HtAYnevSVa9j5oXLHhvhopg096cYDUbpw68gPfY5G5bLufCyuoAgvTn7gzGH5tyG W07K6W1wdNmNRzArtvg+6m87sBHe7JXeod07ITp1gJyRCCHjiFs5gnaE9AucmtYv05EX 8UHu0ojCgFYKTb4HSVxOHPkrskD7t8iShgUoBPsnuj+k+BjOOrVu72YcJzI+m9DJK1fd illA== X-Gm-Message-State: ABy/qLbXflzD6nl/H3qPgsWzIfy64acdgy1hUGNhEYcscEBb7FQUfcEs qPfDTJGU74XD2vEEm3H8Ki377OOxWg== X-Received: from elver.muc.corp.google.com ([2a00:79e0:9c:201:5f73:1fc0:c9fd:f203]) (user=elver job=sendgmr) by 2002:a25:dfc3:0:b0:d15:53b5:509f with SMTP id w186-20020a25dfc3000000b00d1553b5509fmr197192ybg.2.1690988848424; Wed, 02 Aug 2023 08:07:28 -0700 (PDT) Date: Wed, 2 Aug 2023 17:06:37 +0200 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog Message-ID: <20230802150712.3583252-1-elver@google.com> Subject: [PATCH 1/3] Compiler attributes: Introduce the __preserve_most function attribute From: Marco Elver To: elver@google.com, Andrew Morton , Kees Cook Cc: Guenter Roeck , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Miguel Ojeda , Nick Desaulniers , Nathan Chancellor , Tom Rix , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Dmitry Vyukov , Alexander Potapenko , kasan-dev@googlegroups.com, linux-toolchains@vger.kernel.org X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773138877504408456 X-GMAIL-MSGID: 1773138877504408456 [1]: "On X86-64 and AArch64 targets, this attribute changes the calling convention of a function. The preserve_most calling convention attempts to make the code in the caller as unintrusive as possible. This convention behaves identically to the C calling convention on how arguments and return values are passed, but it uses a different set of caller/callee-saved registers. This alleviates the burden of saving and recovering a large register set before and after the call in the caller." [1] https://clang.llvm.org/docs/AttributeReference.html#preserve-most Use of this attribute results in better code generation for calls to very rarely called functions, such as error-reporting functions, or rarely executed slow paths. Introduce the attribute to compiler_attributes.h. Signed-off-by: Marco Elver --- include/linux/compiler_attributes.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index 00efa35c350f..615a63ecfcf6 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -321,6 +321,17 @@ # define __pass_object_size(type) #endif +/* + * Optional: not supported by gcc. + * + * clang: https://clang.llvm.org/docs/AttributeReference.html#preserve-most + */ +#if __has_attribute(__preserve_most__) +# define __preserve_most __attribute__((__preserve_most__)) +#else +# define __preserve_most +#endif + /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute */