Skip to content

Commit bd5c6b8

Browse files
committed
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: 6dcc562 ("x86/asm: Change all ENTRY+ENDPROC to SYM_FUNC_*") ef1e031 ("x86/asm: Make some functions local") e9b9d02 ("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>
1 parent 77b91c1 commit bd5c6b8

7 files changed

Lines changed: 114 additions & 31 deletions

File tree

‎tools/arch/x86/lib/memcpy_64.S‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
* Output:
2929
* rax original destination
3030
*/
31-
ENTRY(__memcpy)
32-
ENTRY(memcpy)
31+
SYM_FUNC_START_ALIAS(__memcpy)
32+
SYM_FUNC_START_LOCAL(memcpy)
3333
ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
3434
"jmp memcpy_erms", X86_FEATURE_ERMS
3535

@@ -41,23 +41,23 @@ ENTRY(memcpy)
4141
movl %edx, %ecx
4242
rep movsb
4343
ret
44-
ENDPROC(memcpy)
45-
ENDPROC(__memcpy)
44+
SYM_FUNC_END(memcpy)
45+
SYM_FUNC_END_ALIAS(__memcpy)
4646
EXPORT_SYMBOL(memcpy)
4747
EXPORT_SYMBOL(__memcpy)
4848

4949
/*
5050
* memcpy_erms() - enhanced fast string memcpy. This is faster and
5151
* simpler than memcpy. Use memcpy_erms when possible.
5252
*/
53-
ENTRY(memcpy_erms)
53+
SYM_FUNC_START(memcpy_erms)
5454
movq %rdi, %rax
5555
movq %rdx, %rcx
5656
rep movsb
5757
ret
58-
ENDPROC(memcpy_erms)
58+
SYM_FUNC_END(memcpy_erms)
5959

60-
ENTRY(memcpy_orig)
60+
SYM_FUNC_START(memcpy_orig)
6161
movq %rdi, %rax
6262

6363
cmpq $0x20, %rdx
@@ -182,7 +182,7 @@ ENTRY(memcpy_orig)
182182

183183
.Lend:
184184
retq
185-
ENDPROC(memcpy_orig)
185+
SYM_FUNC_END(memcpy_orig)
186186

187187
#ifndef CONFIG_UML
188188

@@ -193,7 +193,7 @@ MCSAFE_TEST_CTL
193193
* Note that we only catch machine checks when reading the source addresses.
194194
* Writes to target are posted and don't generate machine checks.
195195
*/
196-
ENTRY(__memcpy_mcsafe)
196+
SYM_FUNC_START(__memcpy_mcsafe)
197197
cmpl $8, %edx
198198
/* Less than 8 bytes? Go to byte copy loop */
199199
jb .L_no_whole_words
@@ -260,7 +260,7 @@ ENTRY(__memcpy_mcsafe)
260260
xorl %eax, %eax
261261
.L_done:
262262
ret
263-
ENDPROC(__memcpy_mcsafe)
263+
SYM_FUNC_END(__memcpy_mcsafe)
264264
EXPORT_SYMBOL_GPL(__memcpy_mcsafe)
265265

266266
.section .fixup, "ax"

‎tools/arch/x86/lib/memset_64.S‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*
1919
* rax original destination
2020
*/
21-
ENTRY(memset)
22-
ENTRY(__memset)
21+
SYM_FUNC_START_ALIAS(memset)
22+
SYM_FUNC_START(__memset)
2323
/*
2424
* Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
2525
* to use it when possible. If not available, use fast string instructions.
@@ -42,8 +42,8 @@ ENTRY(__memset)
4242
rep stosb
4343
movq %r9,%rax
4444
ret
45-
ENDPROC(memset)
46-
ENDPROC(__memset)
45+
SYM_FUNC_END(__memset)
46+
SYM_FUNC_END_ALIAS(memset)
4747

4848
/*
4949
* ISO C memset - set a memory block to a byte value. This function uses
@@ -56,16 +56,16 @@ ENDPROC(__memset)
5656
*
5757
* rax original destination
5858
*/
59-
ENTRY(memset_erms)
59+
SYM_FUNC_START(memset_erms)
6060
movq %rdi,%r9
6161
movb %sil,%al
6262
movq %rdx,%rcx
6363
rep stosb
6464
movq %r9,%rax
6565
ret
66-
ENDPROC(memset_erms)
66+
SYM_FUNC_END(memset_erms)
6767

68-
ENTRY(memset_orig)
68+
SYM_FUNC_START(memset_orig)
6969
movq %rdi,%r10
7070

7171
/* expand byte value */
@@ -136,4 +136,4 @@ ENTRY(memset_orig)
136136
subq %r8,%rdx
137137
jmp .Lafter_bad_alignment
138138
.Lfinal:
139-
ENDPROC(memset_orig)
139+
SYM_FUNC_END(memset_orig)

‎tools/perf/arch/arm/tests/regs_load.S‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
.text
3939
.type perf_regs_load,%function
40-
ENTRY(perf_regs_load)
40+
SYM_FUNC_START(perf_regs_load)
4141
str r0, [r0, #R0]
4242
str r1, [r0, #R1]
4343
str r2, [r0, #R2]
@@ -56,4 +56,4 @@ ENTRY(perf_regs_load)
5656
str lr, [r0, #PC] // store pc as lr in order to skip the call
5757
// to this function
5858
mov pc, lr
59-
ENDPROC(perf_regs_load)
59+
SYM_FUNC_END(perf_regs_load)

‎tools/perf/arch/arm64/tests/regs_load.S‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define LDR_REG(r) ldr x##r, [x0, 8 * r]
88
#define SP (8 * 31)
99
#define PC (8 * 32)
10-
ENTRY(perf_regs_load)
10+
SYM_FUNC_START(perf_regs_load)
1111
STR_REG(0)
1212
STR_REG(1)
1313
STR_REG(2)
@@ -44,4 +44,4 @@ ENTRY(perf_regs_load)
4444
str x30, [x0, #PC]
4545
LDR_REG(1)
4646
ret
47-
ENDPROC(perf_regs_load)
47+
SYM_FUNC_END(perf_regs_load)

‎tools/perf/arch/x86/tests/regs_load.S‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
.text
3030
#ifdef HAVE_ARCH_X86_64_SUPPORT
31-
ENTRY(perf_regs_load)
31+
SYM_FUNC_START(perf_regs_load)
3232
movq %rax, AX(%rdi)
3333
movq %rbx, BX(%rdi)
3434
movq %rcx, CX(%rdi)
@@ -60,9 +60,9 @@ ENTRY(perf_regs_load)
6060
movq %r14, R14(%rdi)
6161
movq %r15, R15(%rdi)
6262
ret
63-
ENDPROC(perf_regs_load)
63+
SYM_FUNC_END(perf_regs_load)
6464
#else
65-
ENTRY(perf_regs_load)
65+
SYM_FUNC_START(perf_regs_load)
6666
push %edi
6767
movl 8(%esp), %edi
6868
movl %eax, AX(%edi)
@@ -88,7 +88,7 @@ ENTRY(perf_regs_load)
8888
movl $0, FS(%edi)
8989
movl $0, GS(%edi)
9090
ret
91-
ENDPROC(perf_regs_load)
91+
SYM_FUNC_END(perf_regs_load)
9292
#endif
9393

9494
/*

‎tools/perf/check-headers.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ for i in $FILES; do
110110
done
111111

112112
# 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\))"'
115115
check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"'
116116
check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"'
117117
check include/linux/ctype.h '-I "isdigit("'

‎tools/perf/util/include/linux/linkage.h‎

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,93 @@
55

66
/* linkage.h ... for including arch/x86/lib/memcpy_64.S */
77

8-
#define ENTRY(name) \
9-
.globl 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
12+
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 \
1039
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
1186

12-
#define ENDPROC(name)
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
1396

1497
#endif /* PERF_LINUX_LINKAGE_H_ */

0 commit comments

Comments
 (0)