From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35465C49EA4 for ; Mon, 21 Jun 2021 23:18:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E6C761245 for ; Mon, 21 Jun 2021 23:18:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231739AbhFUXVJ (ORCPT ); Mon, 21 Jun 2021 19:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbhFUXVH (ORCPT ); Mon, 21 Jun 2021 19:21:07 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6317C061574 for ; Mon, 21 Jun 2021 16:18:52 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id a2-20020ad441c20000b0290251bb08ce61so14506405qvq.19 for ; Mon, 21 Jun 2021 16:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=EuIcmSw5KPdPoDKod6astx8c5RujtZWXcqBmQqWg68Y=; b=Rl2f+IVFqR4FXBxc4YAH9IgPYaLlI0oYo4anxkuLff4uba+ORx0p7N9irHcgqyQ+9M hmodRj/mKufcXYD11r2VSZ5hDKLyMvdLLLmobp3968Q8QfOqiRIMD5DcevQhK1EJCWRO n7YxcGY/61Wgt9WwsRSZ6z3H5yImCbKhYTohLAKNS6nyOkyj4osBjSTdvq78hw1W4QDD gvjHiARt6uW5acWJ7Fc8Qw3tqcAV19/d9odEv831VqpKPsvASivqCZg122/+MYAhLcWF fQIf8W7RIKXiSmMlSEyeiG7Yu61ytddyLALZ9ISgnTlBZNRvqmVKf3y9TnrsFOaIwbNE v2Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=EuIcmSw5KPdPoDKod6astx8c5RujtZWXcqBmQqWg68Y=; b=q9wutJ4DHJ0rBkJ+OSlig84Kpv5oPjKfITqyMBvWZLqVzZnWeXRQkBL5yM4SBD0N6n gZeYjiwVVH9t0h1Z8a0A0NpmJLN3QBMaungG3AlsLTXCiE1q1ahK/VhXhK/ykGQlgpW7 TsfOCmh+G3QZEUpJZj2iIxQThx9723g7UfPVqdVFUWKACTghCd21vfdFXS8tjVGd4mvI iM5on1wN96M5TAlWGWxpptAyrBGrz2PFBV50Q/zstDz30AYw0IZa51gf4zo4ycDxlAIv lWIl9DQzzHw7/j1+Lxiz/FXHyDUa6vTHQR1e8nHLA59ZYTQc0AoGllFh3KVWP1kw1lf/ XkGw== X-Gm-Message-State: AOAM5318/WdwhfQrRsBp3IGcxyps0qnjegt9J83Wq9WuZDndeT1eoyM2 A1ouDz/jrCQzdUf8TShw8Xrov7eSAKk/os0R1lk= X-Google-Smtp-Source: ABdhPJwXV3AaUVj/zGKNnPsDnVTnkVqvyKrfM+eSMD0ScbK7e4btiOXMggCYiTefAq5RSnQMsJmgFBuwAnoE5CW3OBg= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:dfd:ebf9:4ec7:1783]) (user=ndesaulniers job=sendgmr) by 2002:a25:3749:: with SMTP id e70mr789717yba.53.1624317531803; Mon, 21 Jun 2021 16:18:51 -0700 (PDT) Date: Mon, 21 Jun 2021 16:18:19 -0700 Message-Id: <20210621231822.2848305-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog Subject: [PATCH v2 0/3] no_profile fn attr and Kconfig for GCOV+PGO From: Nick Desaulniers To: Kees Cook Cc: Peter Zijlstra , Bill Wendling , Sami Tolvanen , Peter Oberparleiter , Masahiro Yamada , Miguel Ojeda , Nathan Chancellor , Luc Van Oostenryck , Ard Biesheuvel , Will Deacon , Arnd Bergmann , Andrew Morton , Rasmus Villemoes , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, x86@kernel.org, Borislav Petkov , Martin Liska , Marco Elver , Jonathan Corbet , Fangrui Song , linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, Dmitry Vyukov , johannes.berg@intel.com, linux-toolchains@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-s390@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel has been using noinstr for correctness to politely request that the compiler avoid adding various forms of instrumentation to certain functions. GCOV and PGO can both instrument functions, yet the function attribute to disable such instrumentation (no_profile_instrument_function) was not being used to suppress such implementation. Also, clang only just recently gained support for no_profile_instrument_function. GCC has supported that since 7.1+. Add a new function annotation __no_profile that expands to __attribute__((__no_profile_instrument_function__)) and Kconfig values CC_HAS_NO_PROFILE_FN_ATTR and ARCH_WANTS_NO_INSTR. Make GCOV and PGO depend on either !ARCH_WANTS_NO_INSTR or CC_HAS_NO_PROFILE_FN_ATTR. Changes V1 -> V2: * s/no_profile/no_profile_instrument_function/ * fix trailing double underscore on GCC 4 define, as per Fangrui+Miguel. * Pick up Fangrui + Miguel's reviewed-by tag. * Add link to GCC's doc. * Fix clang's doc format; will appear once clang-13 is released. * New cleanup patch 2/3. Orthogonal to the series, but while I'm here... Base is https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=for-next/clang/pgo. Nick Desaulniers (3): compiler_attributes.h: define __no_profile, add to noinstr compiler_attributes.h: cleanups for GCC 4.9+ Kconfig: add ARCH_WANTS_NO_INSTR+CC_HAS_NO_PROFILE_FN_ATTR, depend on for GCOV and PGO arch/Kconfig | 7 +++++++ arch/arm64/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/x86/Kconfig | 1 + include/linux/compiler_attributes.h | 19 ++++++++++++++++--- include/linux/compiler_types.h | 2 +- init/Kconfig | 3 +++ kernel/gcov/Kconfig | 1 + kernel/pgo/Kconfig | 3 ++- 9 files changed, 33 insertions(+), 5 deletions(-) base-commit: 4356bc4c0425c81e204f561acf4dd0095544a6cb -- 2.32.0.288.g62a8d224e6-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0410C4743C for ; Mon, 21 Jun 2021 23:21:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F070611BD for ; Mon, 21 Jun 2021 23:21:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F070611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id: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=+OqknQOVt5Gh1rawdPCjvHtgA9hkt3uIIc5aqrzwYcA=; b=nqq HO4CrSbphpuvve+JAIngSW8G3GwSa3GUuZXFYsTkXKBHweqGDJTFabV/k23DcxJhW62Oy8n6EfYnU IOHsOHhy62wT+1+6yJOKRjN51xfnvZbZjjXMhFuCPj4Tjy4rBemYD8aEU7rhVSEKUTdpJTgt8sk9h 9GfIIxxWrHUn2UUjdyWVO9+OXN9uDS8PvYJ/RMFddVf+l8iSmubg5KX/D9IJcb+DOg920hQwGqtSI 2gL2Mh2q1dKe0Qvl72PIdThdS5M/cNm7b0qSRZ+9KXuoNmrJ0RnfbK7Cu+0OnSKJazU+5tkDkBCha yo9Uqbdsmne+j2O8NkwTg06FNMLttfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvTBy-0054Ly-JP; Mon, 21 Jun 2021 23:18:58 +0000 Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvTBt-0054K8-TH for linux-arm-kernel@lists.infradead.org; Mon, 21 Jun 2021 23:18:55 +0000 Received: by mail-qt1-x84a.google.com with SMTP id 5-20020ac859450000b029024ba4a903ccso5929625qtz.6 for ; Mon, 21 Jun 2021 16:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=EuIcmSw5KPdPoDKod6astx8c5RujtZWXcqBmQqWg68Y=; b=Rl2f+IVFqR4FXBxc4YAH9IgPYaLlI0oYo4anxkuLff4uba+ORx0p7N9irHcgqyQ+9M hmodRj/mKufcXYD11r2VSZ5hDKLyMvdLLLmobp3968Q8QfOqiRIMD5DcevQhK1EJCWRO n7YxcGY/61Wgt9WwsRSZ6z3H5yImCbKhYTohLAKNS6nyOkyj4osBjSTdvq78hw1W4QDD gvjHiARt6uW5acWJ7Fc8Qw3tqcAV19/d9odEv831VqpKPsvASivqCZg122/+MYAhLcWF fQIf8W7RIKXiSmMlSEyeiG7Yu61ytddyLALZ9ISgnTlBZNRvqmVKf3y9TnrsFOaIwbNE v2Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=EuIcmSw5KPdPoDKod6astx8c5RujtZWXcqBmQqWg68Y=; b=XKSjbHxk3gh5QWDbhcrLtt9WIAEBh3HhKwocgveZdL47wWK1WG0nWTX73sHJORbVI9 FjPPvKL2KX8FTZ/8Tt1d/Tm2lyYJT6lPF6rtYno8nAefvjNDGgtMopocz+3BAqoyRYfI BM+uckOXnQtD6zZPYgiIduzAeVkkg+mqIFH4VqKTvkVnEopJJicb7c7Gt1rHpjkPPvcm GMLJ8fIsAQIkv9CXUpTnlzoEJGMF0jyofopH7sp+2IhDgtUw8Wrww3bYi7Kp+ixHPDSh sipTRUe7Ll2oY6qCSr22hAJGJfFO814EIbzkC6W5Wk2u+gR+bEM0WOOZjMZ6PqIG+JdC +Okg== X-Gm-Message-State: AOAM5305G+NXzZM2mWAJMNz8jO44GaebbB9ZsonHRO0N7PWt4j2pVSgK M+EORnviHrfmRIu+CR16XlZqPrUwyrNbPcRLNps= X-Google-Smtp-Source: ABdhPJwXV3AaUVj/zGKNnPsDnVTnkVqvyKrfM+eSMD0ScbK7e4btiOXMggCYiTefAq5RSnQMsJmgFBuwAnoE5CW3OBg= X-Received: from ndesaulniers1.mtv.corp.google.com ([2620:15c:211:202:dfd:ebf9:4ec7:1783]) (user=ndesaulniers job=sendgmr) by 2002:a25:3749:: with SMTP id e70mr789717yba.53.1624317531803; Mon, 21 Jun 2021 16:18:51 -0700 (PDT) Date: Mon, 21 Jun 2021 16:18:19 -0700 Message-Id: <20210621231822.2848305-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog Subject: [PATCH v2 0/3] no_profile fn attr and Kconfig for GCOV+PGO From: Nick Desaulniers To: Kees Cook Cc: Peter Zijlstra , Bill Wendling , Sami Tolvanen , Peter Oberparleiter , Masahiro Yamada , Miguel Ojeda , Nathan Chancellor , Luc Van Oostenryck , Ard Biesheuvel , Will Deacon , Arnd Bergmann , Andrew Morton , Rasmus Villemoes , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, x86@kernel.org, Borislav Petkov , Martin Liska , Marco Elver , Jonathan Corbet , Fangrui Song , linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, Dmitry Vyukov , johannes.berg@intel.com, linux-toolchains@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Christian Borntraeger , linux-s390@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Nick Desaulniers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210621_161854_009130_3BA9B019 X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The kernel has been using noinstr for correctness to politely request that the compiler avoid adding various forms of instrumentation to certain functions. GCOV and PGO can both instrument functions, yet the function attribute to disable such instrumentation (no_profile_instrument_function) was not being used to suppress such implementation. Also, clang only just recently gained support for no_profile_instrument_function. GCC has supported that since 7.1+. Add a new function annotation __no_profile that expands to __attribute__((__no_profile_instrument_function__)) and Kconfig values CC_HAS_NO_PROFILE_FN_ATTR and ARCH_WANTS_NO_INSTR. Make GCOV and PGO depend on either !ARCH_WANTS_NO_INSTR or CC_HAS_NO_PROFILE_FN_ATTR. Changes V1 -> V2: * s/no_profile/no_profile_instrument_function/ * fix trailing double underscore on GCC 4 define, as per Fangrui+Miguel. * Pick up Fangrui + Miguel's reviewed-by tag. * Add link to GCC's doc. * Fix clang's doc format; will appear once clang-13 is released. * New cleanup patch 2/3. Orthogonal to the series, but while I'm here... Base is https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=for-next/clang/pgo. Nick Desaulniers (3): compiler_attributes.h: define __no_profile, add to noinstr compiler_attributes.h: cleanups for GCC 4.9+ Kconfig: add ARCH_WANTS_NO_INSTR+CC_HAS_NO_PROFILE_FN_ATTR, depend on for GCOV and PGO arch/Kconfig | 7 +++++++ arch/arm64/Kconfig | 1 + arch/s390/Kconfig | 1 + arch/x86/Kconfig | 1 + include/linux/compiler_attributes.h | 19 ++++++++++++++++--- include/linux/compiler_types.h | 2 +- init/Kconfig | 3 +++ kernel/gcov/Kconfig | 1 + kernel/pgo/Kconfig | 3 ++- 9 files changed, 33 insertions(+), 5 deletions(-) base-commit: 4356bc4c0425c81e204f561acf4dd0095544a6cb -- 2.32.0.288.g62a8d224e6-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel