Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

AutoFDO: Enable -ffunction-sections for the AutoFDO build

Enable -ffunction-sections by default for the AutoFDO build.

With -ffunction-sections, the compiler places each function in its own
section named .text.function_name instead of placing all functions in
the .text section. In the AutoFDO build, this allows the linker to
utilize profile information to reorganize functions for improved
utilization of iCache and iTLB.

Co-developed-by: Han Shen <shenhan@google.com>
Signed-off-by: Han Shen <shenhan@google.com>
Signed-off-by: Rong Xu <xur@google.com>
Suggested-by: Sriraman Tallam <tmsriram@google.com>
Tested-by: Yonghong Song <yonghong.song@linux.dev>
Tested-by: Yabin Cui <yabinc@google.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Rong Xu and committed by
Masahiro Yamada
0847420f db0b2991

+10 -3
+9 -2
include/asm-generic/vmlinux.lds.h
··· 95 95 * With LTO_CLANG, the linker also splits sections by default, so we need 96 96 * these macros to combine the sections during the final link. 97 97 * 98 + * With AUTOFDO_CLANG, by default, the linker splits text sections and 99 + * regroups functions into subsections. 100 + * 98 101 * RODATA_MAIN is not used because existing code already defines .rodata.x 99 102 * sections to be brought in with rodata. 100 103 */ 101 - #if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG) 104 + #if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG) || \ 105 + defined(CONFIG_AUTOFDO_CLANG) 102 106 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* 107 + #else 108 + #define TEXT_MAIN .text 109 + #endif 110 + #if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG) 103 111 #define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$L* 104 112 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]* 105 113 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L* 106 114 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..L* .bss..compoundliteral* 107 115 #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* 108 116 #else 109 - #define TEXT_MAIN .text 110 117 #define DATA_MAIN .data 111 118 #define SDATA_MAIN .sdata 112 119 #define RODATA_MAIN .rodata
+1 -1
scripts/Makefile.autofdo
··· 9 9 endif 10 10 11 11 ifdef CLANG_AUTOFDO_PROFILE 12 - CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) 12 + CFLAGS_AUTOFDO_CLANG += -fprofile-sample-use=$(CLANG_AUTOFDO_PROFILE) -ffunction-sections 13 13 endif 14 14 15 15 ifdef CONFIG_LTO_CLANG_THIN