Skip to content

Commit c816f2e

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.0-2022-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Fail the 'perf test record' entry on error, fixing a regression where just setup stuff like allocating memory and not the actual things being tested failed. - Fixup disabling of -Wdeprecated-declarations for the python scripting engine, the previous attempt had a brown paper bag thinko. - Fix branch stack sampling test to include sanity check for branch filter on PowerPC. - Update is_ignored_symbol function to match the kernel ignored list, fixing running the 'perf test' entry that compares resolving symbols from kallsyms to resolving from vmlinux. - Augment the data source type with ARM's neoverse_spe list, the previous code was limited in its search resolving the data source. - Fix some clang 5 variable set but unused cases. - Get a perf cgroup more portably in BPF as the __builtin_preserve_enum_value builtin is not available in older versions of clang. In those cases we can forgo BPF's CO-RE (Compile Once, Run Everywhere). - More Fixes for Intel's hybrid CPU model. * tag 'perf-tools-fixes-for-v6.0-2022-09-29' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf build: Fixup disabling of -Wdeprecated-declarations for the python scripting engine perf tests mmap-basic: Remove unused variable to address clang 15 warning perf parse-events: Ignore clang 15 warning about variable set but unused in bison produced code perf tests record: Fail the test if the 'errs' counter is not zero perf test: Fix test case 87 ("perf record tests") for hybrid systems perf arm-spe: augment the data source type with neoverse_spe list perf tests vmlinux-kallsyms: Update is_ignored_symbol function to match the kernel ignored list perf tests powerpc: Fix branch stack sampling test to include sanity check for branch filter perf parse-events: Remove "not supported" hybrid cache events perf print-events: Fix "perf list" can not display the PMU prefix for some hybrid cache events perf tools: Get a perf cgroup more portably in BPF
2 parents 920541b + 8e8bf60 commit c816f2e

File tree

14 files changed

+92
-58
lines changed

14 files changed

+92
-58
lines changed

tools/perf/tests/mmap-basic.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest
114114

115115
for (i = 0; i < nsyscalls; ++i)
116116
for (j = 0; j < expected_nr_events[i]; ++j) {
117-
int foo = syscalls[i]();
118-
++foo;
117+
syscalls[i]();
119118
}
120119

121120
md = &evlist->mmap[0];

tools/perf/tests/perf-record.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest
332332
out:
333333
if (err == -EACCES)
334334
return TEST_SKIP;
335-
if (err < 0)
335+
if (err < 0 || errs != 0)
336336
return TEST_FAIL;
337337
return TEST_OK;
338338
}

tools/perf/tests/shell/record.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test_register_capture() {
6161
echo "Register capture test [Skipped missing registers]"
6262
return
6363
fi
64-
if ! perf record -o - --intr-regs=di,r8,dx,cx -e cpu/br_inst_retired.near_call/p \
64+
if ! perf record -o - --intr-regs=di,r8,dx,cx -e br_inst_retired.near_call:p \
6565
-c 1000 --per-thread true 2> /dev/null \
6666
| perf script -F ip,sym,iregs -i - 2> /dev/null \
6767
| egrep -q "DI:"

tools/perf/tests/shell/test_brstack.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ if ! [ -x "$(command -v cc)" ]; then
1212
fi
1313

1414
# skip the test if the hardware doesn't support branch stack sampling
15-
perf record -b -o- -B true > /dev/null 2>&1 || exit 2
15+
# and if the architecture doesn't support filter types: any,save_type,u
16+
perf record -b -o- -B --branch-filter any,save_type,u true > /dev/null 2>&1 || exit 2
1617

1718
TMPDIR=$(mktemp -d /tmp/__perf_test.program.XXXXX)
1819

tools/perf/tests/vmlinux-kallsyms.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ static bool is_ignored_symbol(const char *name, char type)
4343
/* Symbol names that begin with the following are ignored.*/
4444
static const char * const ignored_prefixes[] = {
4545
"$", /* local symbols for ARM, MIPS, etc. */
46-
".LASANPC", /* s390 kasan local symbols */
46+
".L", /* local labels, .LBB,.Ltmpxxx,.L__unnamed_xx,.LASANPC, etc. */
4747
"__crc_", /* modversions */
4848
"__efistub_", /* arm64 EFI stub namespace */
49-
"__kvm_nvhe_", /* arm64 non-VHE KVM namespace */
49+
"__kvm_nvhe_$", /* arm64 local symbols in non-VHE KVM namespace */
50+
"__kvm_nvhe_.L", /* arm64 local symbols in non-VHE KVM namespace */
5051
"__AArch64ADRPThunk_", /* arm64 lld */
5152
"__ARMV5PILongThunk_", /* arm lld */
5253
"__ARMV7PILongThunk_",

tools/perf/util/Build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ CFLAGS_expr-flex.o += $(flex_flags)
269269
bison_flags := -DYYENABLE_NLS=0
270270
BISON_GE_35 := $(shell expr $(shell $(BISON) --version | grep bison | sed -e 's/.\+ \([0-9]\+\).\([0-9]\+\)/\1\2/g') \>\= 35)
271271
ifeq ($(BISON_GE_35),1)
272-
bison_flags += -Wno-unused-parameter -Wno-nested-externs -Wno-implicit-function-declaration -Wno-switch-enum
272+
bison_flags += -Wno-unused-parameter -Wno-nested-externs -Wno-implicit-function-declaration -Wno-switch-enum -Wno-unused-but-set-variable -Wno-unknown-warning-option
273273
else
274274
bison_flags += -w
275275
endif

tools/perf/util/arm-spe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static void arm_spe__synth_data_source_generic(const struct arm_spe_record *reco
498498
static u64 arm_spe__synth_data_source(const struct arm_spe_record *record, u64 midr)
499499
{
500500
union perf_mem_data_src data_src = { 0 };
501-
bool is_neoverse = is_midr_in_range(midr, neoverse_spe);
501+
bool is_neoverse = is_midr_in_range_list(midr, neoverse_spe);
502502

503503
if (record->op == ARM_SPE_LD)
504504
data_src.mem_op = PERF_MEM_OP_LOAD;

tools/perf/util/bpf_skel/bperf_cgroup.bpf.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const volatile __u32 num_cpus = 1;
4848

4949
int enabled = 0;
5050
int use_cgroup_v2 = 0;
51+
int perf_subsys_id = -1;
5152

5253
static inline int get_cgroup_v1_idx(__u32 *cgrps, int size)
5354
{
@@ -58,7 +59,15 @@ static inline int get_cgroup_v1_idx(__u32 *cgrps, int size)
5859
int level;
5960
int cnt;
6061

61-
cgrp = BPF_CORE_READ(p, cgroups, subsys[perf_event_cgrp_id], cgroup);
62+
if (perf_subsys_id == -1) {
63+
#if __has_builtin(__builtin_preserve_enum_value)
64+
perf_subsys_id = bpf_core_enum_value(enum cgroup_subsys_id,
65+
perf_event_cgrp_id);
66+
#else
67+
perf_subsys_id = perf_event_cgrp_id;
68+
#endif
69+
}
70+
cgrp = BPF_CORE_READ(p, cgroups, subsys[perf_subsys_id], cgroup);
6271
level = BPF_CORE_READ(cgrp, level);
6372

6473
for (cnt = 0; i < MAX_LEVELS; i++) {

tools/perf/util/bpf_skel/off_cpu.bpf.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ const volatile bool has_prev_state = false;
9494
const volatile bool needs_cgroup = false;
9595
const volatile bool uses_cgroup_v1 = false;
9696

97+
int perf_subsys_id = -1;
98+
9799
/*
98100
* Old kernel used to call it task_struct->state and now it's '__state'.
99101
* Use BPF CO-RE "ignored suffix rule" to deal with it like below:
@@ -119,11 +121,19 @@ static inline __u64 get_cgroup_id(struct task_struct *t)
119121
{
120122
struct cgroup *cgrp;
121123

122-
if (uses_cgroup_v1)
123-
cgrp = BPF_CORE_READ(t, cgroups, subsys[perf_event_cgrp_id], cgroup);
124-
else
125-
cgrp = BPF_CORE_READ(t, cgroups, dfl_cgrp);
124+
if (!uses_cgroup_v1)
125+
return BPF_CORE_READ(t, cgroups, dfl_cgrp, kn, id);
126+
127+
if (perf_subsys_id == -1) {
128+
#if __has_builtin(__builtin_preserve_enum_value)
129+
perf_subsys_id = bpf_core_enum_value(enum cgroup_subsys_id,
130+
perf_event_cgrp_id);
131+
#else
132+
perf_subsys_id = perf_event_cgrp_id;
133+
#endif
134+
}
126135

136+
cgrp = BPF_CORE_READ(t, cgroups, subsys[perf_subsys_id], cgroup);
127137
return BPF_CORE_READ(cgrp, kn, id);
128138
}
129139

tools/perf/util/parse-events-hybrid.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static void config_hybrid_attr(struct perf_event_attr *attr,
3333
* If the PMU type ID is 0, the PERF_TYPE_RAW will be applied.
3434
*/
3535
attr->type = type;
36-
attr->config = attr->config | ((__u64)pmu_type << PERF_PMU_TYPE_SHIFT);
36+
attr->config = (attr->config & PERF_HW_EVENT_MASK) |
37+
((__u64)pmu_type << PERF_PMU_TYPE_SHIFT);
3738
}
3839

3940
static int create_event_hybrid(__u32 config_type, int *idx,
@@ -48,13 +49,25 @@ static int create_event_hybrid(__u32 config_type, int *idx,
4849
__u64 config = attr->config;
4950

5051
config_hybrid_attr(attr, config_type, pmu->type);
52+
53+
/*
54+
* Some hybrid hardware cache events are only available on one CPU
55+
* PMU. For example, the 'L1-dcache-load-misses' is only available
56+
* on cpu_core, while the 'L1-icache-loads' is only available on
57+
* cpu_atom. We need to remove "not supported" hybrid cache events.
58+
*/
59+
if (attr->type == PERF_TYPE_HW_CACHE
60+
&& !is_event_supported(attr->type, attr->config))
61+
return 0;
62+
5163
evsel = parse_events__add_event_hybrid(list, idx, attr, name, metric_id,
5264
pmu, config_terms);
53-
if (evsel)
65+
if (evsel) {
5466
evsel->pmu_name = strdup(pmu->name);
55-
else
67+
if (!evsel->pmu_name)
68+
return -ENOMEM;
69+
} else
5670
return -ENOMEM;
57-
5871
attr->type = type;
5972
attr->config = config;
6073
return 0;

0 commit comments

Comments
 (0)