Skip to content

Commit 2cb26c1

Browse files
committed
Merge tag 'perf-tools-fixes-for-v5.13-2021-06-04' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Fix NULL pointer dereference in 'perf probe' when handling DW_AT_const_value when looking for a variable, which is valid. - Fix for capability querying of perf_event_attr.cgroup support in older kernels. - Add missing cloning of evsel->use_config_name. - Honor event config name on --no-merge in 'perf stat'. - Fix some memory leaks found using ASAN. - Fix the perf entry for perf_event_attr setup with make LIBPFM4=1 on s390 z/VM. - Update MIPS UAPI perf_regs.h file. - Fix 'perf stat' BPF counter load return check. * tag 'perf-tools-fixes-for-v5.13-2021-06-04' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf env: Fix memory leak of bpf_prog_info_linear member perf symbol-elf: Fix memory leak by freeing sdt_note.args perf stat: Honor event config name on --no-merge perf evsel: Add missing cloning of evsel->use_config_name perf test: Test 17 fails with make LIBPFM4=1 on s390 z/VM perf stat: Fix error return code in bperf__load() perf record: Move probing cgroup sampling support perf probe: Fix NULL pointer dereference in convert_variable_location() perf tools: Copy uapi/asm/perf_regs.h from the kernel for MIPS
2 parents ff60910 + 67069a1 commit 2cb26c1

File tree

15 files changed

+80
-13
lines changed

15 files changed

+80
-13
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _ASM_MIPS_PERF_REGS_H
3+
#define _ASM_MIPS_PERF_REGS_H
4+
5+
enum perf_event_mips_regs {
6+
PERF_REG_MIPS_PC,
7+
PERF_REG_MIPS_R1,
8+
PERF_REG_MIPS_R2,
9+
PERF_REG_MIPS_R3,
10+
PERF_REG_MIPS_R4,
11+
PERF_REG_MIPS_R5,
12+
PERF_REG_MIPS_R6,
13+
PERF_REG_MIPS_R7,
14+
PERF_REG_MIPS_R8,
15+
PERF_REG_MIPS_R9,
16+
PERF_REG_MIPS_R10,
17+
PERF_REG_MIPS_R11,
18+
PERF_REG_MIPS_R12,
19+
PERF_REG_MIPS_R13,
20+
PERF_REG_MIPS_R14,
21+
PERF_REG_MIPS_R15,
22+
PERF_REG_MIPS_R16,
23+
PERF_REG_MIPS_R17,
24+
PERF_REG_MIPS_R18,
25+
PERF_REG_MIPS_R19,
26+
PERF_REG_MIPS_R20,
27+
PERF_REG_MIPS_R21,
28+
PERF_REG_MIPS_R22,
29+
PERF_REG_MIPS_R23,
30+
PERF_REG_MIPS_R24,
31+
PERF_REG_MIPS_R25,
32+
PERF_REG_MIPS_R26,
33+
PERF_REG_MIPS_R27,
34+
PERF_REG_MIPS_R28,
35+
PERF_REG_MIPS_R29,
36+
PERF_REG_MIPS_R30,
37+
PERF_REG_MIPS_R31,
38+
PERF_REG_MIPS_MAX = PERF_REG_MIPS_R31 + 1,
39+
};
40+
#endif /* _ASM_MIPS_PERF_REGS_H */

tools/perf/Makefile.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ endif
9090
ifeq ($(ARCH),mips)
9191
NO_PERF_REGS := 0
9292
CFLAGS += -I$(OUTPUT)arch/mips/include/generated
93-
CFLAGS += -I../../arch/mips/include/uapi -I../../arch/mips/include/generated/uapi
9493
LIBUNWIND_LIBS = -lunwind -lunwind-mips
9594
endif
9695

tools/perf/builtin-record.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,6 +2714,12 @@ int cmd_record(int argc, const char **argv)
27142714
rec->no_buildid = true;
27152715
}
27162716

2717+
if (rec->opts.record_cgroup && !perf_can_record_cgroup()) {
2718+
pr_err("Kernel has no cgroup sampling support.\n");
2719+
err = -EINVAL;
2720+
goto out_opts;
2721+
}
2722+
27172723
if (rec->opts.kcore)
27182724
rec->data.is_dir = true;
27192725

tools/perf/check-headers.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ arch/x86/lib/x86-opcode-map.txt
3939
arch/x86/tools/gen-insn-attr-x86.awk
4040
arch/arm/include/uapi/asm/perf_regs.h
4141
arch/arm64/include/uapi/asm/perf_regs.h
42+
arch/mips/include/uapi/asm/perf_regs.h
4243
arch/powerpc/include/uapi/asm/perf_regs.h
4344
arch/s390/include/uapi/asm/perf_regs.h
4445
arch/x86/include/uapi/asm/perf_regs.h

tools/perf/tests/attr/base-record

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pinned=0
1616
exclusive=0
1717
exclude_user=0
1818
exclude_kernel=0|1
19-
exclude_hv=0
19+
exclude_hv=0|1
2020
exclude_idle=0
2121
mmap=1
2222
comm=1

tools/perf/util/bpf_counter.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,10 @@ static int bperf__load(struct evsel *evsel, struct target *target)
521521

522522
evsel->bperf_leader_link_fd = bpf_link_get_fd_by_id(entry.link_id);
523523
if (evsel->bperf_leader_link_fd < 0 &&
524-
bperf_reload_leader_program(evsel, attr_map_fd, &entry))
524+
bperf_reload_leader_program(evsel, attr_map_fd, &entry)) {
525+
err = -1;
525526
goto out;
526-
527+
}
527528
/*
528529
* The bpf_link holds reference to the leader program, and the
529530
* leader program holds reference to the maps. Therefore, if
@@ -550,6 +551,7 @@ static int bperf__load(struct evsel *evsel, struct target *target)
550551
/* Step 2: load the follower skeleton */
551552
evsel->follower_skel = bperf_follower_bpf__open();
552553
if (!evsel->follower_skel) {
554+
err = -1;
553555
pr_err("Failed to open follower skeleton\n");
554556
goto out;
555557
}

tools/perf/util/dwarf-aux.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,13 @@ static int __die_find_variable_cb(Dwarf_Die *die_mem, void *data)
975975
if ((tag == DW_TAG_formal_parameter ||
976976
tag == DW_TAG_variable) &&
977977
die_compare_name(die_mem, fvp->name) &&
978-
/* Does the DIE have location information or external instance? */
978+
/*
979+
* Does the DIE have location information or const value
980+
* or external instance?
981+
*/
979982
(dwarf_attr(die_mem, DW_AT_external, &attr) ||
980-
dwarf_attr(die_mem, DW_AT_location, &attr)))
983+
dwarf_attr(die_mem, DW_AT_location, &attr) ||
984+
dwarf_attr(die_mem, DW_AT_const_value, &attr)))
981985
return DIE_FIND_CB_END;
982986
if (dwarf_haspc(die_mem, fvp->addr))
983987
return DIE_FIND_CB_CONTINUE;

tools/perf/util/env.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ static void perf_env__purge_bpf(struct perf_env *env)
144144
node = rb_entry(next, struct bpf_prog_info_node, rb_node);
145145
next = rb_next(&node->rb_node);
146146
rb_erase(&node->rb_node, root);
147+
free(node->info_linear);
147148
free(node);
148149
}
149150

tools/perf/util/evsel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ struct evsel *evsel__clone(struct evsel *orig)
428428
evsel->auto_merge_stats = orig->auto_merge_stats;
429429
evsel->collect_stat = orig->collect_stat;
430430
evsel->weak_group = orig->weak_group;
431+
evsel->use_config_name = orig->use_config_name;
431432

432433
if (evsel__copy_config_terms(evsel, orig) < 0)
433434
goto out_err;

tools/perf/util/evsel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ struct evsel {
8383
bool collect_stat;
8484
bool weak_group;
8585
bool bpf_counter;
86+
bool use_config_name;
8687
int bpf_fd;
8788
struct bpf_object *bpf_obj;
89+
struct list_head config_terms;
8890
};
8991

9092
/*
@@ -116,10 +118,8 @@ struct evsel {
116118
bool merged_stat;
117119
bool reset_group;
118120
bool errored;
119-
bool use_config_name;
120121
struct hashmap *per_pkg_mask;
121122
struct evsel *leader;
122-
struct list_head config_terms;
123123
int err;
124124
int cpu_iter;
125125
struct {

0 commit comments

Comments
 (0)