diff --git a/Documentation/dev-tools/autofdo.rst b/Documentation/dev-tools/autofdo.rst index bcf06e7d6ffa..ae03c4dfedc1 100644 --- a/Documentation/dev-tools/autofdo.rst +++ b/Documentation/dev-tools/autofdo.rst @@ -61,6 +61,9 @@ process consists of the following steps: the AutoFDO profile via offline tools. The support requires a Clang compiler LLVM 17 or later. +Current supported architectures include x86/x86_64 (via LBR) and +arm64 (via SPE or ETM). + Preparation =========== @@ -141,6 +144,35 @@ Here is an example workflow for AutoFDO kernel: $ perf record --pfm-events RETIRED_TAKEN_BRANCH_INSTRUCTIONS:k -a -N -b -c -o -- + - For arm64 with SPE: + + There are a few kernel features that must be enabled to collect SPE profiles on Arm. + Below is a list of the required features: + + - CONFIG_ARM_SPE_PMU=y + - CONFIG_PID_IN_CONTEXTIDR=y + - kpti=off + + Use the following command to generate SPE perf data file:: + + $ perf record -e ' arm_spe_0/branch_filter=1,load_filter=0,store_filter=0/' -a -c -N --no-switch-events -o -- + + - For arm64 with ETM trace: + + Follow the instructions in `Linaro OpenCSD document + `_ + to record ETM traces for AutoFDO:: + + $ perf record -e cs_etm/@tmc_etr0/k -a -o -- + $ perf inject -i -o --itrace=i500009il + + For ARM platforms running Android, follow the instructions in `Android simpleperf + document `_ + to record ETM traces for AutoFDO:: + + $ simpleperf record -e cs-etm:k -a -o -- + $ simpleperf inject -i -o --symdir + 4) (Optional) Download the raw perf file to the host machine. 5) To generate an AutoFDO profile, two offline tools are available: @@ -162,6 +194,15 @@ Here is an example workflow for AutoFDO kernel: $ llvm-profdata merge -o ... + For arm64 SPE, use the following command:: + + $ create_llvm_prof --binary= --profile= --profiler=perf_spe --format=extbinary --out= + + For arm64 ETM, use the following command:: + + $ create_llvm_prof --binary= --profile= --profiler=text -format=extbinary -out= + + 6) Rebuild the kernel using the AutoFDO profile file with the same config as step 1, (Note CONFIG_AUTOFDO_CLANG needs to be enabled):: diff --git a/arch/Kconfig b/arch/Kconfig index 0848932d1c8e..5e878924939a 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -879,12 +879,8 @@ config LTO_CLANG_THIN_DIST module-specific compiler options, and simplifies debugging. endchoice -config ARCH_SUPPORTS_AUTOFDO_CLANG - bool - config AUTOFDO_CLANG bool "Enable Clang's AutoFDO build (EXPERIMENTAL)" - depends on ARCH_SUPPORTS_AUTOFDO_CLANG depends on CC_IS_CLANG help This option enables Clang’s AutoFDO build. When diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index f3f7cb01d69d..10bf3984102e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -130,7 +130,6 @@ config X86 select ARCH_SUPPORTS_LTO_CLANG select ARCH_SUPPORTS_LTO_CLANG_THIN select ARCH_SUPPORTS_RT - select ARCH_SUPPORTS_AUTOFDO_CLANG select ARCH_SUPPORTS_PROPELLER_CLANG if X86_64 select ARCH_USE_BUILTIN_BSWAP select ARCH_USE_CMPXCHG_LOCKREF if X86_CX8