public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: xur@google.com
To: "Alexey Gladkov" <legion@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Bill Wendling" <morbo@google.com>,
	"Han Shen" <shenhan@google.com>, "Ingo Molnar" <mingo@kernel.org>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Justin Stitt" <justinstitt@google.com>,
	"Kees Cook" <kees@kernel.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
	"Nicolas Schier" <nicolas.schier@linux.dev>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Tamir Duberstein" <tamird@gmail.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
	"Yabin Cui" <yabinc@google.com>,
	"Sriraman Tallam" <tmsriram@google.com>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	 llvm@lists.linux.dev, Rong Xu <xur@google.com>
Subject: [PATCH v2 4/4] kbuild: Add config to assert profile accuracy for aggressive optimization
Date: Tue, 14 Oct 2025 19:11:56 +0000	[thread overview]
Message-ID: <20251014191156.3836703-5-xur@google.com> (raw)
In-Reply-To: <20251014191156.3836703-1-xur@google.com>

From: Rong Xu <xur@google.com>

Adds a build config to AutoFDO to assert that the generated profile
accurately represents the intended workload. This enables Clang to
perform more aggressive optimizations.

Signed-off-by: Rong Xu <xur@google.com>
---
 arch/Kconfig             | 11 +++++++++++
 scripts/Makefile.autofdo |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/arch/Kconfig b/arch/Kconfig
index ebe08b9186adc..6fdc676cb0fe4 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -886,6 +886,17 @@ config AUTOFDO_CLANG
 
 	  If unsure, say N.
 
+config AUTOFDO_PROFILE_ACCURATE
+	bool "Assert AutoFDO profile is accurate (EXPERIMENTAL)"
+	depends on AUTOFDO_CLANG
+	help
+	  This option asserts that the AutoFDO profile (specified
+	  in CLANG_AUTOFDO_PROFILE) is collected from a representative
+	  workload, allowing the Clang compiler to perform more
+	  aggressive optimizations.
+
+	  If unsure, say N.
+
 config ARCH_SUPPORTS_PROPELLER_CLANG
 	bool
 
diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo
index 5bcfcef273745..36abeae2accdc 100644
--- a/scripts/Makefile.autofdo
+++ b/scripts/Makefile.autofdo
@@ -11,6 +11,9 @@ endif
 ifdef CLANG_AUTOFDO_PROFILE
   CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections
   CFLAGS_AUTOFDO_CLANG += -fsplit-machine-functions
+ifdef CONFIG_AUTOFDO_PROFILE_ACCURATE
+  CFLAGS_AUTOFDO_CLANG += -fprofile-sample-accurate
+endif
 endif
 
 ifdef CONFIG_LTO_CLANG_THIN
-- 
2.51.0.788.g6d19910ace-goog


  parent reply	other threads:[~2025-10-14 19:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 19:11 [PATCH v2 0/4] kbuild: Fixes for AutoFDO and Propeller builds xur
2025-10-14 19:11 ` [PATCH v2 1/4] kbuild: Fix Propeller flags xur
2025-10-14 19:11 ` [PATCH v2 2/4] kbuild: Disable AutoFDO and Propeller flags for kernel modules xur
2025-10-16  1:29   ` kernel test robot
2025-10-16  2:38   ` kernel test robot
2025-10-14 19:11 ` [PATCH v2 3/4] kbuild: Remove MFS flags from Propeller profile generate builds xur
2025-10-14 19:11 ` xur [this message]
2025-10-15  3:38   ` [PATCH v2 4/4] kbuild: Add config to assert profile accuracy for aggressive optimization Han Shen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251014191156.3836703-5-xur@google.com \
    --to=xur@google.com \
    --cc=aliceryhl@google.com \
    --cc=ardb@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=legion@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=mingo@kernel.org \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=nicolas.schier@linux.dev \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=shenhan@google.com \
    --cc=tamird@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=tmsriram@google.com \
    --cc=yabinc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox