Re: [PATCH v2 4/4] kbuild: Add config to assert profile accuracy for aggressive optimization

From: Han Shen

Date: Tue Oct 14 2025 - 23:38:49 EST


I've verified patches 1-4, with the following configuration on X86_64 systems:

1. autofdo without profile (nothinlto)
2. autofdo with profile (nothinlto)
3. propeller only (noautofdo no thinlto) annotated
4. propeller only optimized (noautofdo nothinlto)

All the kernels boot up successfully.

Thanks,
Han



On Tue, Oct 14, 2025 at 12:12 PM <xur@xxxxxxxxxx> wrote:
>
> From: Rong Xu <xur@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> ---
> 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
>


--
Han Shen | Software Engineer | shenhan@xxxxxxxxxx | Sunnyvale California