Skip to content

Commit 56f8145

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.2-1-2023-01-06' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Fix segfault when trying to process tracepoints present in a perf.data file and not linked with libtraceevent. - Fix build on uClibc systems by adding missing sys/types.h include, that was being obtained indirectly which stopped being the case when tools/lib/traceevent was removed. - Don't show commands in 'perf help' that depend on linking with libtraceevent when not building with that library, which is now a possibility since we no longer ship a copy in tools/lib/traceevent. - Fix failure in 'perf test' entry testing the combination of 'perf probe' user space function + 'perf record' + 'perf script' where it expects a backtrace leading to glibc's inet_pton() from 'ping' that now happens more than once with glibc 2.35 for IPv6 addreses. - Fix for the inet_pton perf test on s/390 where 'text_to_binary_address' now appears on the backtrace. - Fix build error on riscv due to missing header for 'struct perf_sample'. - Fix 'make -C tools perf_install' install variant by not propagating the 'subdir' to submakes for the 'install_headers' targets. - Fix handling of unsupported cgroup events when using BPF counters in 'perf stat'. - Count all cgroups, not just the last one when using 'perf stat' and combining --for-each-cgroup with --bpf-counters. This makes the output using BPF counters match the output without using it, which was the intention all along, the output should be the same using --bpf-counters or not. - Fix 'perf lock contention' core dump related to not finding the "__sched_text_end" symbol on s/390. - Fix build failure when HEAD is signed: exclude the signature from the version string. - Add missing closedir() calls to in perf_data__open_dir(), plugging a fd leak. * tag 'perf-tools-fixes-for-v6.2-1-2023-01-06' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf tools: Fix build on uClibc systems by adding missing sys/types.h include perf stat: Fix handling of --for-each-cgroup with --bpf-counters to match non BPF mode perf stat: Fix handling of unsupported cgroup events when using BPF counters perf test record_probe_libc_inet_pton: Fix test on s/390 where 'text_to_binary_address' now appears on the backtrace perf lock contention: Fix core dump related to not finding the "__sched_text_end" symbol on s/390 perf build: Don't propagate subdir to submakes for install_headers perf test record_probe_libc_inet_pton: Fix failure due to extra inet_pton() backtrace in glibc >= 2.35 perf tools: Fix segfault when trying to process tracepoints in perf.data and not linked with libtraceevent perf tools: Don't include signature in version strings perf help: Use HAVE_LIBTRACEEVENT to filter out unsupported commands perf tools riscv: Fix build error on riscv due to missing header for 'struct perf_sample' perf tools: Fix resources leak in perf_data__open_dir()
2 parents d7a0853 + 481028d commit 56f8145

File tree

13 files changed

+70
-32
lines changed

13 files changed

+70
-32
lines changed

tools/perf/Documentation/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ $(OUTPUT)%.xml : %.txt
267267
$(ASCIIDOC) -b docbook -d manpage \
268268
$(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) \
269269
-aperf_date=$(shell git log -1 --pretty="format:%cd" \
270-
--date=short $<) \
270+
--date=short --no-show-signature $<) \
271271
-o $@+ $< && \
272272
mv $@+ $@
273273

tools/perf/Makefile.perf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
819819

820820
$(LIBAPI): FORCE | $(LIBAPI_OUTPUT)
821821
$(Q)$(MAKE) -C $(LIBAPI_DIR) O=$(LIBAPI_OUTPUT) \
822-
DESTDIR=$(LIBAPI_DESTDIR) prefix= \
822+
DESTDIR=$(LIBAPI_DESTDIR) prefix= subdir= \
823823
$@ install_headers
824824

825825
$(LIBAPI)-clean:
@@ -828,7 +828,7 @@ $(LIBAPI)-clean:
828828

829829
$(LIBBPF): FORCE | $(LIBBPF_OUTPUT)
830830
$(Q)$(MAKE) -C $(LIBBPF_DIR) FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) \
831-
O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= \
831+
O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= subdir= \
832832
$@ install_headers
833833

834834
$(LIBBPF)-clean:
@@ -837,7 +837,7 @@ $(LIBBPF)-clean:
837837

838838
$(LIBPERF): FORCE | $(LIBPERF_OUTPUT)
839839
$(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(LIBPERF_OUTPUT) \
840-
DESTDIR=$(LIBPERF_DESTDIR) prefix= \
840+
DESTDIR=$(LIBPERF_DESTDIR) prefix= subdir= \
841841
$@ install_headers
842842

843843
$(LIBPERF)-clean:
@@ -846,7 +846,7 @@ $(LIBPERF)-clean:
846846

847847
$(LIBSUBCMD): FORCE | $(LIBSUBCMD_OUTPUT)
848848
$(Q)$(MAKE) -C $(LIBSUBCMD_DIR) O=$(LIBSUBCMD_OUTPUT) \
849-
DESTDIR=$(LIBSUBCMD_DESTDIR) prefix= \
849+
DESTDIR=$(LIBSUBCMD_DESTDIR) prefix= subdir= \
850850
$@ install_headers
851851

852852
$(LIBSUBCMD)-clean:
@@ -855,7 +855,7 @@ $(LIBSUBCMD)-clean:
855855

856856
$(LIBSYMBOL): FORCE | $(LIBSYMBOL_OUTPUT)
857857
$(Q)$(MAKE) -C $(LIBSYMBOL_DIR) O=$(LIBSYMBOL_OUTPUT) \
858-
DESTDIR=$(LIBSYMBOL_DESTDIR) prefix= \
858+
DESTDIR=$(LIBSYMBOL_DESTDIR) prefix= subdir= \
859859
$@ install_headers
860860

861861
$(LIBSYMBOL)-clean:

tools/perf/arch/riscv/util/unwind-libdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <elfutils/libdwfl.h>
55
#include "../../util/unwind-libdw.h"
66
#include "../../util/perf_regs.h"
7-
#include "../../util/event.h"
7+
#include "../../util/sample.h"
88

99
bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
1010
{

tools/perf/builtin-lock.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,7 @@ static int __cmd_report(bool display_info)
16701670

16711671
/* for lock function check */
16721672
symbol_conf.sort_by_name = true;
1673+
symbol_conf.allow_aliases = true;
16731674
symbol__init(&session->header.env);
16741675

16751676
if (!data.is_pipe) {
@@ -1757,6 +1758,7 @@ static int __cmd_contention(int argc, const char **argv)
17571758

17581759
/* for lock function check */
17591760
symbol_conf.sort_by_name = true;
1761+
symbol_conf.allow_aliases = true;
17601762
symbol__init(&session->header.env);
17611763

17621764
if (use_bpf) {

tools/perf/command-list.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ perf-ftrace mainporcelain common
1616
perf-inject mainporcelain common
1717
perf-iostat mainporcelain common
1818
perf-kallsyms mainporcelain common
19-
perf-kmem mainporcelain common
19+
perf-kmem mainporcelain traceevent
2020
perf-kvm mainporcelain common
21-
perf-kwork mainporcelain common
21+
perf-kwork mainporcelain traceevent
2222
perf-list mainporcelain common
23-
perf-lock mainporcelain common
23+
perf-lock mainporcelain traceevent
2424
perf-mem mainporcelain common
2525
perf-probe mainporcelain full
2626
perf-record mainporcelain common
2727
perf-report mainporcelain common
28-
perf-sched mainporcelain common
28+
perf-sched mainporcelain traceevent
2929
perf-script mainporcelain common
3030
perf-stat mainporcelain common
3131
perf-test mainporcelain common
32-
perf-timechart mainporcelain common
32+
perf-timechart mainporcelain traceevent
3333
perf-top mainporcelain common
3434
perf-trace mainporcelain audit
3535
perf-version mainporcelain common

tools/perf/tests/shell/record+probe_libc_inet_pton.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ trace_libc_inet_pton_backtrace() {
3737
case "$(uname -m)" in
3838
s390x)
3939
eventattr='call-graph=dwarf,max-stack=4'
40+
echo "text_to_binary_address.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
4041
echo "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
4142
echo "(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$" >> $expected
4243
echo "main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" >> $expected
@@ -57,7 +58,7 @@ trace_libc_inet_pton_backtrace() {
5758
perf_data=`mktemp -u /tmp/perf.data.XXX`
5859
perf_script=`mktemp -u /tmp/perf.script.XXX`
5960
perf record -e $event_name/$eventattr/ -o $perf_data ping -6 -c 1 ::1 > /dev/null 2>&1
60-
perf script -i $perf_data > $perf_script
61+
perf script -i $perf_data | tac | grep -m1 ^ping -B9 | tac > $perf_script
6162

6263
exec 3<$perf_script
6364
exec 4<$expected

tools/perf/util/PERF-VERSION-GEN

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ TAG=
1919
if test -d ../../.git -o -f ../../.git
2020
then
2121
TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
22-
CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
22+
CID=$(git log -1 --abbrev=12 --pretty=format:"%h" --no-show-signature 2>/dev/null) && CID="-g$CID"
2323
elif test -f ../../PERF-VERSION-FILE
2424
then
2525
TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')

tools/perf/util/bpf_counter_cgroup.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,19 @@ static int bperf_load_program(struct evlist *evlist)
116116

117117
/* open single copy of the events w/o cgroup */
118118
err = evsel__open_per_cpu(evsel, evsel->core.cpus, -1);
119-
if (err) {
120-
pr_err("Failed to open first cgroup events\n");
121-
goto out;
122-
}
119+
if (err == 0)
120+
evsel->supported = true;
123121

124122
map_fd = bpf_map__fd(skel->maps.events);
125123
perf_cpu_map__for_each_cpu(cpu, j, evsel->core.cpus) {
126124
int fd = FD(evsel, j);
127125
__u32 idx = evsel->core.idx * total_cpus + cpu.cpu;
128126

129-
err = bpf_map_update_elem(map_fd, &idx, &fd,
130-
BPF_ANY);
131-
if (err < 0) {
132-
pr_err("Failed to update perf_event fd\n");
133-
goto out;
134-
}
127+
bpf_map_update_elem(map_fd, &idx, &fd, BPF_ANY);
135128
}
136129

137130
evsel->cgrp = leader_cgrp;
138131
}
139-
evsel->supported = true;
140132

141133
if (evsel->cgrp == cgrp)
142134
continue;

tools/perf/util/cgroup.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,19 @@ static int add_cgroup_name(const char *fpath, const struct stat *sb __maybe_unus
224224
return 0;
225225
}
226226

227+
static int check_and_add_cgroup_name(const char *fpath)
228+
{
229+
struct cgroup_name *cn;
230+
231+
list_for_each_entry(cn, &cgroup_list, list) {
232+
if (!strcmp(cn->name, fpath))
233+
return 0;
234+
}
235+
236+
/* pretend if it's added by ftw() */
237+
return add_cgroup_name(fpath, NULL, FTW_D, NULL);
238+
}
239+
227240
static void release_cgroup_list(void)
228241
{
229242
struct cgroup_name *cn;
@@ -242,7 +255,7 @@ static int list_cgroups(const char *str)
242255
struct cgroup_name *cn;
243256
char *s;
244257

245-
/* use given name as is - for testing purpose */
258+
/* use given name as is when no regex is given */
246259
for (;;) {
247260
p = strchr(str, ',');
248261
e = p ? p : eos;
@@ -253,13 +266,13 @@ static int list_cgroups(const char *str)
253266
s = strndup(str, e - str);
254267
if (!s)
255268
return -1;
256-
/* pretend if it's added by ftw() */
257-
ret = add_cgroup_name(s, NULL, FTW_D, NULL);
269+
270+
ret = check_and_add_cgroup_name(s);
258271
free(s);
259-
if (ret)
272+
if (ret < 0)
260273
return -1;
261274
} else {
262-
if (add_cgroup_name("", NULL, FTW_D, NULL) < 0)
275+
if (check_and_add_cgroup_name("/") < 0)
263276
return -1;
264277
}
265278

tools/perf/util/data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ int perf_data__open_dir(struct perf_data *data)
132132
file->size = st.st_size;
133133
}
134134

135+
closedir(dir);
135136
if (!files)
136137
return -EINVAL;
137138

@@ -140,6 +141,7 @@ int perf_data__open_dir(struct perf_data *data)
140141
return 0;
141142

142143
out_err:
144+
closedir(dir);
143145
close_dir(files, nr);
144146
return ret;
145147
}

0 commit comments

Comments
 (0)