Skip to content

Commit be1dd66

Browse files
committed
Merge tag 'perf-tools-fixes-for-v5.10-2020-11-17' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Fix file corruption due to event deletion in 'perf inject'. - Update arch/x86/lib/mem{cpy,set}_64.S copies used in 'perf bench mem memcpy', silencing perf build warning. - Avoid an msan warning in a copied stack in 'perf test'. - Correct tracepoint field name "flags" in ARM's CS-ETM hardware tracing 'perf test' entry. - Update branch sample pattern for cs-etm to cope with excluding guest in userspace counting. - Don't free "lock_seq_stat" if read_count isn't zero in 'perf lock'. * tag 'perf-tools-fixes-for-v5.10-2020-11-17' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf test: Avoid an msan warning in a copied stack. perf inject: Fix file corruption due to event deletion perf test: Update branch sample pattern for cs-etm perf test: Fix a typo in cs-etm testing tools arch: Update arch/x86/lib/mem{cpy,set}_64.S copies used in 'perf bench mem memcpy' perf lock: Don't free "lock_seq_stat" if read_count isn't zero perf lock: Correct field name "flags"
2 parents 9dacf44 + 568beb2 commit be1dd66

9 files changed

Lines changed: 34 additions & 25 deletions

File tree

tools/arch/x86/lib/memcpy_64.S

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* to a jmp to memcpy_erms which does the REP; MOVSB mem copy.
1717
*/
1818

19-
.weak memcpy
20-
2119
/*
2220
* memcpy - Copy a memory block.
2321
*
@@ -30,7 +28,7 @@
3028
* rax original destination
3129
*/
3230
SYM_FUNC_START_ALIAS(__memcpy)
33-
SYM_FUNC_START_LOCAL(memcpy)
31+
SYM_FUNC_START_WEAK(memcpy)
3432
ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
3533
"jmp memcpy_erms", X86_FEATURE_ERMS
3634

@@ -51,14 +49,14 @@ EXPORT_SYMBOL(__memcpy)
5149
* memcpy_erms() - enhanced fast string memcpy. This is faster and
5250
* simpler than memcpy. Use memcpy_erms when possible.
5351
*/
54-
SYM_FUNC_START(memcpy_erms)
52+
SYM_FUNC_START_LOCAL(memcpy_erms)
5553
movq %rdi, %rax
5654
movq %rdx, %rcx
5755
rep movsb
5856
ret
5957
SYM_FUNC_END(memcpy_erms)
6058

61-
SYM_FUNC_START(memcpy_orig)
59+
SYM_FUNC_START_LOCAL(memcpy_orig)
6260
movq %rdi, %rax
6361

6462
cmpq $0x20, %rdx

tools/arch/x86/lib/memset_64.S

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
#include <linux/linkage.h>
55
#include <asm/cpufeatures.h>
66
#include <asm/alternative-asm.h>
7-
8-
.weak memset
7+
#include <asm/export.h>
98

109
/*
1110
* ISO C memset - set a memory block to a byte value. This function uses fast
@@ -18,7 +17,7 @@
1817
*
1918
* rax original destination
2019
*/
21-
SYM_FUNC_START_ALIAS(memset)
20+
SYM_FUNC_START_WEAK(memset)
2221
SYM_FUNC_START(__memset)
2322
/*
2423
* Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
@@ -44,6 +43,8 @@ SYM_FUNC_START(__memset)
4443
ret
4544
SYM_FUNC_END(__memset)
4645
SYM_FUNC_END_ALIAS(memset)
46+
EXPORT_SYMBOL(memset)
47+
EXPORT_SYMBOL(__memset)
4748

4849
/*
4950
* ISO C memset - set a memory block to a byte value. This function uses
@@ -56,7 +57,7 @@ SYM_FUNC_END_ALIAS(memset)
5657
*
5758
* rax original destination
5859
*/
59-
SYM_FUNC_START(memset_erms)
60+
SYM_FUNC_START_LOCAL(memset_erms)
6061
movq %rdi,%r9
6162
movb %sil,%al
6263
movq %rdx,%rcx
@@ -65,7 +66,7 @@ SYM_FUNC_START(memset_erms)
6566
ret
6667
SYM_FUNC_END(memset_erms)
6768

68-
SYM_FUNC_START(memset_orig)
69+
SYM_FUNC_START_LOCAL(memset_orig)
6970
movq %rdi,%r10
7071

7172
/* expand byte value */

tools/perf/arch/x86/tests/dwarf-unwind.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ static int sample_ustack(struct perf_sample *sample,
3838
stack_size = stack_size > STACK_SIZE ? STACK_SIZE : stack_size;
3939

4040
memcpy(buf, (void *) sp, stack_size);
41+
#ifdef MEMORY_SANITIZER
42+
/*
43+
* Copying the stack may copy msan poison, avoid false positives in the
44+
* unwinder by removing the poison here.
45+
*/
46+
__msan_unpoison(buf, stack_size);
47+
#endif
4148
stack->data = (char *) buf;
4249
stack->size = stack_size;
4350
return 0;

tools/perf/bench/mem-memcpy-x86-64-asm.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
/* Various wrappers to make the kernel .S file build in user-space: */
44

5+
// memcpy_orig and memcpy_erms are being defined as SYM_L_LOCAL but we need it
6+
#define SYM_FUNC_START_LOCAL(name) \
7+
SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
58
#define memcpy MEMCPY /* don't hide glibc's memcpy() */
69
#define altinstr_replacement text
710
#define globl p2align 4; .globl

tools/perf/bench/mem-memset-x86-64-asm.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
2+
// memset_orig and memset_erms are being defined as SYM_L_LOCAL but we need it
3+
#define SYM_FUNC_START_LOCAL(name) \
4+
SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)
25
#define memset MEMSET /* don't hide glibc's memset() */
36
#define altinstr_replacement text
47
#define globl p2align 4; .globl

tools/perf/builtin-inject.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -779,25 +779,15 @@ static int __cmd_inject(struct perf_inject *inject)
779779
dsos__hit_all(session);
780780
/*
781781
* The AUX areas have been removed and replaced with
782-
* synthesized hardware events, so clear the feature flag and
783-
* remove the evsel.
782+
* synthesized hardware events, so clear the feature flag.
784783
*/
785784
if (inject->itrace_synth_opts.set) {
786-
struct evsel *evsel;
787-
788785
perf_header__clear_feat(&session->header,
789786
HEADER_AUXTRACE);
790787
if (inject->itrace_synth_opts.last_branch ||
791788
inject->itrace_synth_opts.add_last_branch)
792789
perf_header__set_feat(&session->header,
793790
HEADER_BRANCH_STACK);
794-
evsel = perf_evlist__id2evsel_strict(session->evlist,
795-
inject->aux_id);
796-
if (evsel) {
797-
pr_debug("Deleting %s\n", evsel__name(evsel));
798-
evlist__remove(session->evlist, evsel);
799-
evsel__delete(evsel);
800-
}
801791
}
802792
session->header.data_offset = output_data_offset;
803793
session->header.data_size = inject->bytes_written;

tools/perf/builtin-lock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static int report_lock_acquire_event(struct evsel *evsel,
406406
struct lock_seq_stat *seq;
407407
const char *name = evsel__strval(evsel, sample, "name");
408408
u64 tmp = evsel__intval(evsel, sample, "lockdep_addr");
409-
int flag = evsel__intval(evsel, sample, "flag");
409+
int flag = evsel__intval(evsel, sample, "flags");
410410

411411
memcpy(&addr, &tmp, sizeof(void *));
412412

@@ -621,7 +621,7 @@ static int report_lock_release_event(struct evsel *evsel,
621621
case SEQ_STATE_READ_ACQUIRED:
622622
seq->read_count--;
623623
BUG_ON(seq->read_count < 0);
624-
if (!seq->read_count) {
624+
if (seq->read_count) {
625625
ls->nr_release++;
626626
goto end;
627627
}

tools/perf/tests/shell/test_arm_coresight.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ perf_script_branch_samples() {
4444
# touch 6512 1 branches:u: ffffb22082e0 strcmp+0xa0 (/lib/aarch64-linux-gnu/ld-2.27.so)
4545
# touch 6512 1 branches:u: ffffb2208320 strcmp+0xe0 (/lib/aarch64-linux-gnu/ld-2.27.so)
4646
perf script -F,-time -i ${perfdata} | \
47-
egrep " +$1 +[0-9]+ .* +branches:([u|k]:)? +"
47+
egrep " +$1 +[0-9]+ .* +branches:(.*:)? +"
4848
}
4949

5050
perf_report_branch_samples() {
@@ -105,7 +105,7 @@ arm_cs_iterate_devices() {
105105
# `> device_name = 'tmc_etf0'
106106
device_name=$(basename $path)
107107

108-
if is_device_sink $path $devce_name; then
108+
if is_device_sink $path $device_name; then
109109

110110
record_touch_file $device_name $2 &&
111111
perf_script_branch_samples touch &&

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
/* SYM_L_* -- linkage of symbols */
2727
#define SYM_L_GLOBAL(name) .globl name
28+
#define SYM_L_WEAK(name) .weak name
2829
#define SYM_L_LOCAL(name) /* nothing */
2930

3031
#define ALIGN __ALIGN
@@ -84,6 +85,12 @@
8485
SYM_END(name, SYM_T_FUNC)
8586
#endif
8687

88+
/* SYM_FUNC_START_WEAK -- use for weak functions */
89+
#ifndef SYM_FUNC_START_WEAK
90+
#define SYM_FUNC_START_WEAK(name) \
91+
SYM_START(name, SYM_L_WEAK, SYM_A_ALIGN)
92+
#endif
93+
8794
/*
8895
* SYM_FUNC_END -- the end of SYM_FUNC_START_LOCAL, SYM_FUNC_START,
8996
* SYM_FUNC_START_WEAK, ...

0 commit comments

Comments
 (0)