Skip to content

Commit c206353

Browse files
committed
Merge tag 'perf-tools-for-v6.5-2-2023-07-06' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next
Pull more perf tools updates from Namhyung Kim: "These are remaining changes and fixes for this cycle. Build: - Allow generating vmlinux.h from BTF using `make GEN_VMLINUX_H=1` and skip if the vmlinux has no BTF. - Replace deprecated clang -target xxx option by --target=xxx. perf record: - Print event attributes with well known type and config symbols in the debug output like below: # perf record -e cycles,cpu-clock -C0 -vv true <SNIP> ------------------------------------------------------------ perf_event_attr: type 0 (PERF_TYPE_HARDWARE) size 136 config 0 (PERF_COUNT_HW_CPU_CYCLES) { sample_period, sample_freq } 4000 sample_type IP|TID|TIME|CPU|PERIOD|IDENTIFIER read_format ID disabled 1 inherit 1 freq 1 sample_id_all 1 exclude_guest 1 ------------------------------------------------------------ sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 5 ------------------------------------------------------------ perf_event_attr: type 1 (PERF_TYPE_SOFTWARE) size 136 config 0 (PERF_COUNT_SW_CPU_CLOCK) { sample_period, sample_freq } 4000 sample_type IP|TID|TIME|CPU|PERIOD|IDENTIFIER read_format ID disabled 1 inherit 1 freq 1 sample_id_all 1 exclude_guest 1 - Update AMD IBS event error message since it now support per-process profiling but no priviledge filters. $ sudo perf record -e ibs_op//k -C 0 Error: AMD IBS doesn't support privilege filtering. Try again without the privilege modifiers (like 'k') at the end. perf lock contention: - Support CSV style output using -x option $ sudo perf lock con -ab -x, sleep 1 # output: contended, total wait, max wait, avg wait, type, caller 19, 194232, 21415, 10222, spinlock, process_one_work+0x1f0 15, 162748, 23843, 10849, rwsem:R, do_user_addr_fault+0x40e 4, 86740, 23415, 21685, rwlock:R, ep_poll_callback+0x2d 1, 84281, 84281, 84281, mutex, iwl_mvm_async_handlers_wk+0x135 8, 67608, 27404, 8451, spinlock, __queue_work+0x174 3, 58616, 31125, 19538, rwsem:W, do_mprotect_pkey+0xff 3, 52953, 21172, 17651, rwlock:W, do_epoll_wait+0x248 2, 30324, 19704, 15162, rwsem:R, do_madvise+0x3ad 1, 24619, 24619, 24619, spinlock, rcu_core+0xd4 - Add --output option to save the data to a file not to be interfered by other debug messages. Test: - Fix event parsing test on ARM where there's no raw PMU nor supports PERF_PMU_CAP_EXTENDED_HW_TYPE. - Update the lock contention test case for CSV output. - Fix a segfault in the daemon command test. Vendor events (JSON): - Add has_event() to check if the given event is available on system at runtime. On Intel machines, some transaction events may not be present when TSC extensions are disabled. - Update Intel event metrics. Misc: - Sort symbols by name using an external array of pointers instead of a rbtree node in the symbol. This will save 16-bytes or 24-bytes per symbol whether the sorting is actually requested or not. - Fix unwinding DWARF callstacks using libdw when --symfs option is used" * tag 'perf-tools-for-v6.5-2-2023-07-06' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next: (38 commits) perf test: Fix event parsing test when PERF_PMU_CAP_EXTENDED_HW_TYPE isn't supported. perf test: Fix event parsing test on Arm perf evsel amd: Fix IBS error message perf: unwind: Fix symfs with libdw perf symbol: Fix uninitialized return value in symbols__find_by_name() perf test: Test perf lock contention CSV output perf lock contention: Add --output option perf lock contention: Add -x option for CSV style output perf lock: Remove stale comments perf vendor events intel: Update tigerlake to 1.13 perf vendor events intel: Update skylakex to 1.31 perf vendor events intel: Update skylake to 57 perf vendor events intel: Update sapphirerapids to 1.14 perf vendor events intel: Update icelakex to 1.21 perf vendor events intel: Update icelake to 1.19 perf vendor events intel: Update cascadelakex to 1.19 perf vendor events intel: Update meteorlake to 1.03 perf vendor events intel: Add rocketlake events/metrics perf vendor metrics intel: Make transaction metrics conditional perf jevents: Support for has_event function ...
2 parents ad8258e + bcd981d commit c206353

File tree

95 files changed

+9361
-493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+9361
-493
lines changed

tools/perf/Documentation/perf-config.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ llvm.*::
669669
"$CLANG_OPTIONS $PERF_BPF_INC_OPTIONS $KERNEL_INC_OPTIONS " \
670670
"-Wno-unused-value -Wno-pointer-sign " \
671671
"-working-directory $WORKING_DIR " \
672-
"-c \"$CLANG_SOURCE\" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE"
672+
"-c \"$CLANG_SOURCE\" --target=bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE"
673673

674674
llvm.clang-opt::
675675
Options passed to clang.

tools/perf/Documentation/perf-lock.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ COMMON OPTIONS
3636
--input=<file>::
3737
Input file name. (default: perf.data unless stdin is a fifo)
3838

39+
--output=<file>::
40+
Output file name for perf lock contention and report.
41+
3942
-v::
4043
--verbose::
4144
Be more verbose (show symbol address, etc).
@@ -200,6 +203,11 @@ CONTENTION OPTIONS
200203
Note that it matches the substring so 'rq' would match both 'raw_spin_rq_lock'
201204
and 'irq_enter_rcu'.
202205

206+
-x::
207+
--field-separator=<SEP>::
208+
Show results using a CSV-style output to make it easy to import directly
209+
into spreadsheets. Columns are separated by the string specified in SEP.
210+
203211

204212
SEE ALSO
205213
--------

tools/perf/Makefile.config

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
315315

316316
FEATURE_CHECK_LDFLAGS-libaio = -lrt
317317

318+
FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
319+
FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl
320+
318321
CORE_CFLAGS += -fno-omit-frame-pointer
319322
CORE_CFLAGS += -ggdb3
320323
CORE_CFLAGS += -funwind-tables
@@ -344,8 +347,8 @@ ifneq ($(TCMALLOC),)
344347
endif
345348

346349
ifeq ($(FEATURES_DUMP),)
347-
# We will display at the end of this Makefile.config, using $(call feature_display_entries),
348-
# as we may retry some feature detection here.
350+
# We will display at the end of this Makefile.config, using $(call feature_display_entries)
351+
# As we may retry some feature detection here, see the disassembler-four-args case, for instance
349352
FEATURE_DISPLAY_DEFERRED := 1
350353
include $(srctree)/tools/build/Makefile.feature
351354
else
@@ -680,6 +683,10 @@ ifdef BUILD_BPF_SKEL
680683
CFLAGS += -DHAVE_BPF_SKEL
681684
endif
682685

686+
ifndef GEN_VMLINUX_H
687+
VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h
688+
endif
689+
683690
dwarf-post-unwind := 1
684691
dwarf-post-unwind-text := BUG
685692

@@ -903,9 +910,13 @@ ifdef BUILD_NONDISTRO
903910

904911
ifeq ($(feature-libbfd-liberty), 1)
905912
EXTLIBS += -lbfd -lopcodes -liberty
913+
FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -ldl
914+
FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -ldl
906915
else
907916
ifeq ($(feature-libbfd-liberty-z), 1)
908917
EXTLIBS += -lbfd -lopcodes -liberty -lz
918+
FEATURE_CHECK_LDFLAGS-disassembler-four-args += -liberty -lz -ldl
919+
FEATURE_CHECK_LDFLAGS-disassembler-init-styled += -liberty -lz -ldl
909920
endif
910921
endif
911922
$(call feature_check,disassembler-four-args)
@@ -1329,6 +1340,6 @@ endif
13291340

13301341
# re-generate FEATURE-DUMP as we may have called feature_check, found out
13311342
# extra libraries to add to LDFLAGS of some other test and then redo those
1332-
# tests.
1343+
# tests, see the block about libbfd, disassembler-four-args, for instance.
13331344
$(shell rm -f $(FEATURE_DUMP_FILENAME))
13341345
$(foreach feat,$(FEATURE_TESTS),$(shell echo "$(call feature_assign,$(feat))" >> $(FEATURE_DUMP_FILENAME)))

tools/perf/Makefile.perf

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ include ../scripts/utilities.mak
132132
# Define EXTRA_TESTS to enable building extra tests useful mainly to perf
133133
# developers, such as:
134134
# x86 instruction decoder - new instructions test
135+
#
136+
# Define GEN_VMLINUX_H to generate vmlinux.h from the BTF.
135137

136138
# As per kernel Makefile, avoid funny character set dependencies
137139
unexport LC_ALL
@@ -197,6 +199,7 @@ FLEX ?= flex
197199
BISON ?= bison
198200
STRIP = strip
199201
AWK = awk
202+
READELF ?= readelf
200203

201204
# include Makefile.config by default and rule out
202205
# non-config cases
@@ -1061,7 +1064,7 @@ $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_
10611064
ifdef BUILD_BPF_SKEL
10621065
BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool
10631066
# Get Clang's default includes on this system, as opposed to those seen by
1064-
# '-target bpf'. This fixes "missing" files on some architectures/distros,
1067+
# '--target=bpf'. This fixes "missing" files on some architectures/distros,
10651068
# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc.
10661069
#
10671070
# Use '-idirafter': Don't interfere with include mechanics except where the
@@ -1084,8 +1087,44 @@ $(BPFTOOL): | $(SKEL_TMP_OUT)
10841087
$(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \
10851088
OUTPUT=$(SKEL_TMP_OUT)/ bootstrap
10861089

1087-
$(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) | $(SKEL_TMP_OUT)
1088-
$(QUIET_CLANG)$(CLANG) -g -O2 -target bpf -Wall -Werror $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
1090+
# Paths to search for a kernel to generate vmlinux.h from.
1091+
VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \
1092+
$(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \
1093+
../../vmlinux \
1094+
/boot/vmlinux-$(shell uname -r)
1095+
1096+
# Paths to BTF information.
1097+
VMLINUX_BTF_BTF_PATHS ?= /sys/kernel/btf/vmlinux
1098+
1099+
# Filter out kernels that don't exist or without a BTF section.
1100+
VMLINUX_BTF_ELF_ABSPATHS ?= $(abspath $(wildcard $(VMLINUX_BTF_ELF_PATHS)))
1101+
VMLINUX_BTF_PATHS ?= $(shell for file in $(VMLINUX_BTF_ELF_ABSPATHS); \
1102+
do \
1103+
if [ -f $$file ] && ($(READELF) -S "$$file" | grep -q .BTF); \
1104+
then \
1105+
echo "$$file"; \
1106+
fi; \
1107+
done) \
1108+
$(wildcard $(VMLINUX_BTF_BTF_PATHS))
1109+
1110+
# Select the first as the source of vmlinux.h.
1111+
VMLINUX_BTF ?= $(firstword $(VMLINUX_BTF_PATHS))
1112+
1113+
ifeq ($(VMLINUX_H),)
1114+
ifeq ($(VMLINUX_BTF),)
1115+
$(error Missing bpftool input for generating vmlinux.h)
1116+
endif
1117+
endif
1118+
1119+
$(SKEL_OUT)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL)
1120+
ifeq ($(VMLINUX_H),)
1121+
$(QUIET_GEN)$(BPFTOOL) btf dump file $< format c > $@
1122+
else
1123+
$(Q)cp "$(VMLINUX_H)" $@
1124+
endif
1125+
1126+
$(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h | $(SKEL_TMP_OUT)
1127+
$(QUIET_CLANG)$(CLANG) -g -O2 --target=bpf -Wall -Werror $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \
10891128
-c $(filter util/bpf_skel/%.bpf.c,$^) -o $@
10901129

10911130
$(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL)

tools/perf/arch/x86/util/evsel.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,23 @@ void arch__post_evsel_config(struct evsel *evsel, struct perf_event_attr *attr)
102102
}
103103
}
104104
}
105+
106+
int arch_evsel__open_strerror(struct evsel *evsel, char *msg, size_t size)
107+
{
108+
if (!x86__is_amd_cpu())
109+
return 0;
110+
111+
if (!evsel->core.attr.precise_ip &&
112+
!(evsel->pmu_name && !strncmp(evsel->pmu_name, "ibs", 3)))
113+
return 0;
114+
115+
/* More verbose IBS errors. */
116+
if (evsel->core.attr.exclude_kernel || evsel->core.attr.exclude_user ||
117+
evsel->core.attr.exclude_hv || evsel->core.attr.exclude_idle ||
118+
evsel->core.attr.exclude_host || evsel->core.attr.exclude_guest) {
119+
return scnprintf(msg, size, "AMD IBS doesn't support privilege filtering. Try "
120+
"again without the privilege modifiers (like 'k') at the end.");
121+
}
122+
123+
return 0;
124+
}

tools/perf/builtin-daemon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ int cmd_daemon(int argc, const char **argv)
15241524
if (argc) {
15251525
if (!strcmp(argv[0], "start"))
15261526
ret = __cmd_start(&__daemon, daemon_options, argc, argv);
1527-
if (!strcmp(argv[0], "signal"))
1527+
else if (!strcmp(argv[0], "signal"))
15281528
ret = __cmd_signal(&__daemon, daemon_options, argc, argv);
15291529
else if (!strcmp(argv[0], "stop"))
15301530
ret = __cmd_stop(&__daemon, daemon_options, argc, argv);

tools/perf/builtin-kallsyms.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ int cmd_kallsyms(int argc, const char **argv)
6262
if (argc < 1)
6363
usage_with_options(kallsyms_usage, options);
6464

65-
symbol_conf.sort_by_name = true;
6665
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
6766
if (symbol__init(NULL) < 0)
6867
return -1;

0 commit comments

Comments
 (0)