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

perf bench: Update the copies of x86's mem{cpy,set}_64.S

And update linux/linkage.h, which requires in turn that we make these
files switch from ENTRY()/ENDPROC() to SYM_FUNC_START()/SYM_FUNC_END():

tools/perf/arch/arm64/tests/regs_load.S
tools/perf/arch/arm/tests/regs_load.S
tools/perf/arch/powerpc/tests/regs_load.S
tools/perf/arch/x86/tests/regs_load.S

We also need to switch SYM_FUNC_START_LOCAL() to SYM_FUNC_START() for
the functions used directly by 'perf bench', and update
tools/perf/check_headers.sh to ignore those changes when checking if the
kernel original files drifted from the copies we carry.

This is to get the changes from:

6dcc5627f6ae ("x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_*")
ef1e03152cb0 ("x86/asm: Make some functions local")
e9b9d020c487 ("x86/asm: Annotate aliases")

And address these tools/perf build warnings:

Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs from latest version at 'arch/x86/lib/memcpy_64.S'
diff -u tools/arch/x86/lib/memcpy_64.S arch/x86/lib/memcpy_64.S
Warning: Kernel ABI header at 'tools/arch/x86/lib/memset_64.S' differs from latest version at 'arch/x86/lib/memset_64.S'
diff -u tools/arch/x86/lib/memset_64.S arch/x86/lib/memset_64.S

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-tay3l8x8k11p7y3qcpqh9qh5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+115 -32
+10 -10
tools/arch/x86/lib/memcpy_64.S
··· 28 28 * Output: 29 29 * rax original destination 30 30 */ 31 - ENTRY(__memcpy) 32 - ENTRY(memcpy) 31 + SYM_FUNC_START_ALIAS(__memcpy) 32 + SYM_FUNC_START_LOCAL(memcpy) 33 33 ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \ 34 34 "jmp memcpy_erms", X86_FEATURE_ERMS 35 35 ··· 41 41 movl %edx, %ecx 42 42 rep movsb 43 43 ret 44 - ENDPROC(memcpy) 45 - ENDPROC(__memcpy) 44 + SYM_FUNC_END(memcpy) 45 + SYM_FUNC_END_ALIAS(__memcpy) 46 46 EXPORT_SYMBOL(memcpy) 47 47 EXPORT_SYMBOL(__memcpy) 48 48 ··· 50 50 * memcpy_erms() - enhanced fast string memcpy. This is faster and 51 51 * simpler than memcpy. Use memcpy_erms when possible. 52 52 */ 53 - ENTRY(memcpy_erms) 53 + SYM_FUNC_START(memcpy_erms) 54 54 movq %rdi, %rax 55 55 movq %rdx, %rcx 56 56 rep movsb 57 57 ret 58 - ENDPROC(memcpy_erms) 58 + SYM_FUNC_END(memcpy_erms) 59 59 60 - ENTRY(memcpy_orig) 60 + SYM_FUNC_START(memcpy_orig) 61 61 movq %rdi, %rax 62 62 63 63 cmpq $0x20, %rdx ··· 182 182 183 183 .Lend: 184 184 retq 185 - ENDPROC(memcpy_orig) 185 + SYM_FUNC_END(memcpy_orig) 186 186 187 187 #ifndef CONFIG_UML 188 188 ··· 193 193 * Note that we only catch machine checks when reading the source addresses. 194 194 * Writes to target are posted and don't generate machine checks. 195 195 */ 196 - ENTRY(__memcpy_mcsafe) 196 + SYM_FUNC_START(__memcpy_mcsafe) 197 197 cmpl $8, %edx 198 198 /* Less than 8 bytes? Go to byte copy loop */ 199 199 jb .L_no_whole_words ··· 260 260 xorl %eax, %eax 261 261 .L_done: 262 262 ret 263 - ENDPROC(__memcpy_mcsafe) 263 + SYM_FUNC_END(__memcpy_mcsafe) 264 264 EXPORT_SYMBOL_GPL(__memcpy_mcsafe) 265 265 266 266 .section .fixup, "ax"
+8 -8
tools/arch/x86/lib/memset_64.S
··· 18 18 * 19 19 * rax original destination 20 20 */ 21 - ENTRY(memset) 22 - ENTRY(__memset) 21 + SYM_FUNC_START_ALIAS(memset) 22 + SYM_FUNC_START(__memset) 23 23 /* 24 24 * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended 25 25 * to use it when possible. If not available, use fast string instructions. ··· 42 42 rep stosb 43 43 movq %r9,%rax 44 44 ret 45 - ENDPROC(memset) 46 - ENDPROC(__memset) 45 + SYM_FUNC_END(__memset) 46 + SYM_FUNC_END_ALIAS(memset) 47 47 48 48 /* 49 49 * ISO C memset - set a memory block to a byte value. This function uses ··· 56 56 * 57 57 * rax original destination 58 58 */ 59 - ENTRY(memset_erms) 59 + SYM_FUNC_START(memset_erms) 60 60 movq %rdi,%r9 61 61 movb %sil,%al 62 62 movq %rdx,%rcx 63 63 rep stosb 64 64 movq %r9,%rax 65 65 ret 66 - ENDPROC(memset_erms) 66 + SYM_FUNC_END(memset_erms) 67 67 68 - ENTRY(memset_orig) 68 + SYM_FUNC_START(memset_orig) 69 69 movq %rdi,%r10 70 70 71 71 /* expand byte value */ ··· 136 136 subq %r8,%rdx 137 137 jmp .Lafter_bad_alignment 138 138 .Lfinal: 139 - ENDPROC(memset_orig) 139 + SYM_FUNC_END(memset_orig)
+2 -2
tools/perf/arch/arm/tests/regs_load.S
··· 37 37 38 38 .text 39 39 .type perf_regs_load,%function 40 - ENTRY(perf_regs_load) 40 + SYM_FUNC_START(perf_regs_load) 41 41 str r0, [r0, #R0] 42 42 str r1, [r0, #R1] 43 43 str r2, [r0, #R2] ··· 56 56 str lr, [r0, #PC] // store pc as lr in order to skip the call 57 57 // to this function 58 58 mov pc, lr 59 - ENDPROC(perf_regs_load) 59 + SYM_FUNC_END(perf_regs_load)
+2 -2
tools/perf/arch/arm64/tests/regs_load.S
··· 7 7 #define LDR_REG(r) ldr x##r, [x0, 8 * r] 8 8 #define SP (8 * 31) 9 9 #define PC (8 * 32) 10 - ENTRY(perf_regs_load) 10 + SYM_FUNC_START(perf_regs_load) 11 11 STR_REG(0) 12 12 STR_REG(1) 13 13 STR_REG(2) ··· 44 44 str x30, [x0, #PC] 45 45 LDR_REG(1) 46 46 ret 47 - ENDPROC(perf_regs_load) 47 + SYM_FUNC_END(perf_regs_load)
+4 -4
tools/perf/arch/x86/tests/regs_load.S
··· 28 28 29 29 .text 30 30 #ifdef HAVE_ARCH_X86_64_SUPPORT 31 - ENTRY(perf_regs_load) 31 + SYM_FUNC_START(perf_regs_load) 32 32 movq %rax, AX(%rdi) 33 33 movq %rbx, BX(%rdi) 34 34 movq %rcx, CX(%rdi) ··· 60 60 movq %r14, R14(%rdi) 61 61 movq %r15, R15(%rdi) 62 62 ret 63 - ENDPROC(perf_regs_load) 63 + SYM_FUNC_END(perf_regs_load) 64 64 #else 65 - ENTRY(perf_regs_load) 65 + SYM_FUNC_START(perf_regs_load) 66 66 push %edi 67 67 movl 8(%esp), %edi 68 68 movl %eax, AX(%edi) ··· 88 88 movl $0, FS(%edi) 89 89 movl $0, GS(%edi) 90 90 ret 91 - ENDPROC(perf_regs_load) 91 + SYM_FUNC_END(perf_regs_load) 92 92 #endif 93 93 94 94 /*
+2 -2
tools/perf/check-headers.sh
··· 110 110 done 111 111 112 112 # diff with extra ignore lines 113 - check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' 114 - check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' 113 + check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memcpy_\(erms\|orig\))"' 114 + check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"' 115 115 check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"' 116 116 check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' 117 117 check include/linux/ctype.h '-I "isdigit("'
+87 -4
tools/perf/util/include/linux/linkage.h
··· 5 5 6 6 /* linkage.h ... for including arch/x86/lib/memcpy_64.S */ 7 7 8 - #define ENTRY(name) \ 9 - .globl name; \ 10 - name: 8 + /* Some toolchains use other characters (e.g. '`') to mark new line in macro */ 9 + #ifndef ASM_NL 10 + #define ASM_NL ; 11 + #endif 11 12 12 - #define ENDPROC(name) 13 + #ifndef __ALIGN 14 + #define __ALIGN .align 4,0x90 15 + #define __ALIGN_STR ".align 4,0x90" 16 + #endif 17 + 18 + /* SYM_T_FUNC -- type used by assembler to mark functions */ 19 + #ifndef SYM_T_FUNC 20 + #define SYM_T_FUNC STT_FUNC 21 + #endif 22 + 23 + /* SYM_A_* -- align the symbol? */ 24 + #define SYM_A_ALIGN ALIGN 25 + 26 + /* SYM_L_* -- linkage of symbols */ 27 + #define SYM_L_GLOBAL(name) .globl name 28 + #define SYM_L_LOCAL(name) /* nothing */ 29 + 30 + #define ALIGN __ALIGN 31 + 32 + /* === generic annotations === */ 33 + 34 + /* SYM_ENTRY -- use only if you have to for non-paired symbols */ 35 + #ifndef SYM_ENTRY 36 + #define SYM_ENTRY(name, linkage, align...) \ 37 + linkage(name) ASM_NL \ 38 + align ASM_NL \ 39 + name: 40 + #endif 41 + 42 + /* SYM_START -- use only if you have to */ 43 + #ifndef SYM_START 44 + #define SYM_START(name, linkage, align...) \ 45 + SYM_ENTRY(name, linkage, align) 46 + #endif 47 + 48 + /* SYM_END -- use only if you have to */ 49 + #ifndef SYM_END 50 + #define SYM_END(name, sym_type) \ 51 + .type name sym_type ASM_NL \ 52 + .size name, .-name 53 + #endif 54 + 55 + /* 56 + * SYM_FUNC_START_ALIAS -- use where there are two global names for one 57 + * function 58 + */ 59 + #ifndef SYM_FUNC_START_ALIAS 60 + #define SYM_FUNC_START_ALIAS(name) \ 61 + SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) 62 + #endif 63 + 64 + /* SYM_FUNC_START -- use for global functions */ 65 + #ifndef SYM_FUNC_START 66 + /* 67 + * The same as SYM_FUNC_START_ALIAS, but we will need to distinguish these two 68 + * later. 69 + */ 70 + #define SYM_FUNC_START(name) \ 71 + SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) 72 + #endif 73 + 74 + /* SYM_FUNC_START_LOCAL -- use for local functions */ 75 + #ifndef SYM_FUNC_START_LOCAL 76 + /* the same as SYM_FUNC_START_LOCAL_ALIAS, see comment near SYM_FUNC_START */ 77 + #define SYM_FUNC_START_LOCAL(name) \ 78 + SYM_START(name, SYM_L_LOCAL, SYM_A_ALIGN) 79 + #endif 80 + 81 + /* SYM_FUNC_END_ALIAS -- the end of LOCAL_ALIASed or ALIASed function */ 82 + #ifndef SYM_FUNC_END_ALIAS 83 + #define SYM_FUNC_END_ALIAS(name) \ 84 + SYM_END(name, SYM_T_FUNC) 85 + #endif 86 + 87 + /* 88 + * SYM_FUNC_END -- the end of SYM_FUNC_START_LOCAL, SYM_FUNC_START, 89 + * SYM_FUNC_START_WEAK, ... 90 + */ 91 + #ifndef SYM_FUNC_END 92 + /* the same as SYM_FUNC_END_ALIAS, see comment near SYM_FUNC_START */ 93 + #define SYM_FUNC_END(name) \ 94 + SYM_END(name, SYM_T_FUNC) 95 + #endif 13 96 14 97 #endif /* PERF_LINUX_LINKAGE_H_ */