Re: [PATCH v4 1/6] Add AutoFDO support for Clang build
From: Masahiro Yamada
Date: Sun Oct 20 2024 - 12:33:43 EST
On Tue, Oct 15, 2024 at 6:33 AM Rong Xu <xur@xxxxxxxxxx> wrote:
> +Customization
> +=============
> +
> +You can enable or disable AutoFDO build for individual file and directories by
> +adding a line similar to the following to the respective kernel Makefile:
Perhaps, it might be worth mentioning that kernel space objects are
covered by default.
Then, people would understand ':= y' will be less common than ':= n'.
> +
> +- For enabling a single file (e.g. foo.o) ::
> +
> + AUTOFDO_PROFILE_foo.o := y
> +
> +- For enabling all files in one directory ::
> +
> + AUTOFDO_PROFILE := y
> +
> +- For disabling one file ::
> +
> + AUTOFDO_PROFILE_foo.o := n
> +
> +- For disabling all files in one directory ::
> +
> + AUTOFDO_PROFILE := n
> +
> +3) Run the load tests. The '-c' option in perf specifies the sample
> + event period. We suggest using a suitable prime number, like 500009,
> + for this purpose.
> +
> + - For Intel platforms::
> +
> + $ perf record -e BR_INST_RETIRED.NEAR_TAKEN:k -a -N -b -c <count> -o <perf_file> -- <loadtest>
> +
> + - For AMD platforms: For Intel platforms:
I guess this is a copy-paste mistake.
For AMD platforms: For Intel platforms:
->
For AMD platforms:
> + (https://github.com/google/autofdo), version v0.30.1 or later.
Please one space instead of two after the comma.
> diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo
> new file mode 100644
> index 000000000000..1c9f224bc221
> --- /dev/null
> +++ b/scripts/Makefile.autofdo
> @@ -0,0 +1,23 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# Enable available and selected Clang AutoFDO features.
> +
> +CFLAGS_AUTOFDO_CLANG := -fdebug-info-for-profiling -mllvm -enable-fs-discriminator=true -mllvm -improved-fs-discriminator=true
> +
> +# If CONFIG_DEBUG_INFO is not enabled, set -gmlt option.
Meaningless comment. It explains too obvious code.
> +ifndef CONFIG_DEBUG_INFO
> + CFLAGS_AUTOFDO_CLANG += -gmlt
> +endif
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 01a9f567d5af..e85d6ac31bd9 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -191,6 +191,16 @@ _c_flags += $(if $(patsubst n%,, \
> -D__KCSAN_INSTRUMENT_BARRIERS__)
> endif
>
> +#
> +# Enable Clang's AutoFDO build flags for a file or directory depending on
> +# variables AUTOFDO_PROFILE_obj.o and AUTOFDO_PROFILE.
> +#
This comment would give the wrong understanding that this flag is opt-in.
The comment for KASAN correctly describes that it is enabled by default,
and can be opted out using KASAN_SANITIZE_*.
--
Best Regards
Masahiro Yamada