Skip to content

Commit b50ecc5

Browse files
committed
Merge tag 'perf-tools-for-v6.13-2024-11-24' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
Pull perf tools updates from Namhyung Kim: "perf record: - Enable leader sampling for inherited task events. It was supported only for system-wide events but the kernel started to support such a setup since v6.12. This is to reduce the number of PMU interrupts. The samples of the leader event will contain counts of other events and no samples will be generated for the other member events. $ perf record -e '{cycles,instructions}:S' ${MYPROG} perf report: - Fix --branch-history option to display more branch-related information like prediction, abort and cycles which is available on Intel machines. $ perf record -bg -- perf test -w brstack $ perf report --branch-history ... # # Overhead Source:Line Symbol Shared Object Predicted Abort Cycles IPC [IPC Coverage] # ........ ........................ .............. .................... ......... ..... ...... .................... # 8.17% copy_page_64.S:19 [k] copy_page [kernel.kallsyms] 50.0% 0 5 - - | ---xas_load xarray.h:171 | |--5.68%--xas_load xarray.c:245 (cycles:1) | xas_load xarray.c:242 | xas_load xarray.h:1260 (cycles:1) | xas_descend xarray.c:146 | xas_load xarray.c:244 (cycles:2) | xas_load xarray.c:245 | xas_descend xarray.c:218 (cycles:10) ... perf stat: - Add HWMON PMU support. The HWMON provides various system information like CPU/GPU temperature, fan speed and so on. Expose them as PMU events so that users can see the values using perf stat commands. $ perf stat -e temp_cpu,fan1 true Performance counter stats for 'true': 60.00 'C temp_cpu 0 rpm fan1 0.000745382 seconds time elapsed 0.000883000 seconds user 0.000000000 seconds sys - Display metric threshold in JSON output. Some metrics define thresholds to classify value ranges. It used to be in a different color but it won't work for JSON. Add "metric-threshold" field to the JSON that can be one of "good", "less good", "nearly bad" and "bad". # perf stat -a -M TopdownL1 -j true {"counter-value" : "18693525.000000", "unit" : "", "event" : "TOPDOWN.SLOTS", "event-runtime" : 5552708, "pcnt-running" : 100.00, "metric-value" : "43.226002", "metric-unit" : "% tma_backend_bound", "metric-threshold" : "bad"} {"metric-value" : "29.212267", "metric-unit" : "% tma_frontend_bound", "metric-threshold" : "bad"} {"metric-value" : "7.138972", "metric-unit" : "% tma_bad_speculation", "metric-threshold" : "good"} {"metric-value" : "20.422759", "metric-unit" : "% tma_retiring", "metric-threshold" : "good"} {"counter-value" : "3817732.000000", "unit" : "", "event" : "topdown-retiring", "event-runtime" : 5552708, "pcnt-running" : 100.00, } {"counter-value" : "5472824.000000", "unit" : "", "event" : "topdown-fe-bound", "event-runtime" : 5552708, "pcnt-running" : 100.00, } {"counter-value" : "7984780.000000", "unit" : "", "event" : "topdown-be-bound", "event-runtime" : 5552708, "pcnt-running" : 100.00, } {"counter-value" : "1418181.000000", "unit" : "", "event" : "topdown-bad-spec", "event-runtime" : 5552708, "pcnt-running" : 100.00, } ... perf sched: - Add -P/--pre-migrations option for 'timehist' sub-command to track time a task waited on a run-queue before migrating to a different CPU. $ perf sched timehist -P time cpu task name wait time sch delay run time pre-mig time [tid/pid] (msec) (msec) (msec) (msec) --------------- ------ ------------------------------ --------- --------- --------- --------- 585940.535527 [0000] perf[584885] 0.000 0.000 0.000 0.000 585940.535535 [0000] migration/0[20] 0.000 0.002 0.008 0.000 585940.535559 [0001] perf[584885] 0.000 0.000 0.000 0.000 585940.535563 [0001] migration/1[25] 0.000 0.001 0.004 0.000 585940.535678 [0002] perf[584885] 0.000 0.000 0.000 0.000 585940.535686 [0002] migration/2[31] 0.000 0.002 0.008 0.000 585940.535905 [0001] <idle> 0.000 0.000 0.342 0.000 585940.535938 [0003] perf[584885] 0.000 0.000 0.000 0.000 585940.537048 [0001] sleep[584886] 0.000 0.019 1.142 0.001 585940.537749 [0002] <idle> 0.000 0.000 2.062 0.000 ... Build: - Make libunwind opt-in (LIBUNWIND=1) rather than opt-out. The perf tools are generally built with libelf and libdw which has unwinder functionality. The libunwind support predates it and no need to have duplicate unwinders by default. - Rename NO_DWARF=1 build option to NO_LIBDW=1 in order to clarify it's using libdw for handling DWARF information. Internals: - Do not set exclude_guest bit in the perf_event_attr by default. This was causing a trouble in AMD IBS PMU as it doesn't support the bit. The bit will be set when it's needed later by the fallback logic. Also update the missing feature detection logic to make sure not clear supported bits unnecessarily. - Run perf test in parallel by default and mark flaky tests "exclusive" to run them serially at the end. Some test numbers are changed but the test can complete in less than half the time. JSON vendor events: - Add AMD Zen 5 events and metrics. - Add i.MX91 and i.MX95 DDR metrics - Fix HiSilicon HIP08 Topdown metric name. - Support compat events on PowerPC" * tag 'perf-tools-for-v6.13-2024-11-24' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: (232 commits) perf tests: Fix hwmon parsing with PMU name test perf hwmon_pmu: Ensure hwmon key union is zeroed before use perf tests hwmon_pmu: Remove double evlist__delete() perf/test: fix perf ftrace test on s390 perf bpf-filter: Return -ENOMEM directly when pfi allocation fails perf test: Correct hwmon test PMU detection perf: Remove unused del_perf_probe_events() perf pmu: Move pmu_metrics_table__find and remove ARM override perf jevents: Add map_for_cpu() perf header: Pass a perf_cpu rather than a PMU to get_cpuid_str perf header: Avoid transitive PMU includes perf arm64 header: Use cpu argument in get_cpuid perf header: Refactor get_cpuid to take a CPU for ARM perf header: Move is_cpu_online to numa bench perf jevents: fix breakage when do perf stat on system metric perf test: Add missing __exit calls in tool/hwmon tests perf tests: Make leader sampling test work without branch event perf util: Remove kernel version deadcode perf test shell trace_exit_race: Use --no-comm to avoid cases where COMM isn't resolved perf test shell trace_exit_race: Show what went wrong in verbose mode ...
2 parents 9160b68 + 6d78089 commit b50ecc5

File tree

338 files changed

+9483
-4123
lines changed

Some content is hidden

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

338 files changed

+9483
-4123
lines changed

tools/build/Makefile.feature

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ endef
3030
#
3131
FEATURE_TESTS_BASIC := \
3232
backtrace \
33-
dwarf \
34-
dwarf_getlocations \
35-
dwarf_getcfi \
33+
libdw \
3634
eventfd \
3735
fortify-source \
3836
get_current_dir_name \
@@ -61,7 +59,6 @@ FEATURE_TESTS_BASIC := \
6159
reallocarray \
6260
stackprotector-all \
6361
timerfd \
64-
libdw-dwarf-unwind \
6562
zlib \
6663
lzma \
6764
get_cpuid \
@@ -121,8 +118,7 @@ ifeq ($(FEATURE_TESTS),all)
121118
endif
122119

123120
FEATURE_DISPLAY ?= \
124-
dwarf \
125-
dwarf_getlocations \
121+
libdw \
126122
glibc \
127123
libbfd \
128124
libbfd-buildid \
@@ -134,7 +130,6 @@ FEATURE_DISPLAY ?= \
134130
libpython \
135131
libcrypto \
136132
libunwind \
137-
libdw-dwarf-unwind \
138133
libcapstone \
139134
llvm-perf \
140135
zlib \
@@ -234,7 +229,7 @@ endef
234229

235230
#
236231
# generates feature value assignment for name, like:
237-
# $(call feature_assign,dwarf) == feature-dwarf=1
232+
# $(call feature_assign,libdw) == feature-libdw=1
238233
#
239234
feature_assign = feature-$(1)=$(feature-$(1))
240235

tools/build/feature/Makefile

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ FILES= \
55
test-all.bin \
66
test-backtrace.bin \
77
test-bionic.bin \
8-
test-dwarf.bin \
9-
test-dwarf_getlocations.bin \
10-
test-dwarf_getcfi.bin \
8+
test-libdw.bin \
119
test-eventfd.bin \
1210
test-fortify-source.bin \
1311
test-get_current_dir_name.bin \
@@ -53,7 +51,6 @@ FILES= \
5351
test-pthread-barrier.bin \
5452
test-stackprotector-all.bin \
5553
test-timerfd.bin \
56-
test-libdw-dwarf-unwind.bin \
5754
test-libbabeltrace.bin \
5855
test-libcapstone.bin \
5956
test-compile-32.bin \
@@ -169,9 +166,9 @@ $(OUTPUT)test-libopencsd.bin:
169166
$(BUILD) # -lopencsd_c_api -lopencsd provided by
170167
# $(FEATURE_CHECK_LDFLAGS-libopencsd)
171168

172-
DWARFLIBS := -ldw
169+
DWLIBS := -ldw
173170
ifeq ($(findstring -static,${LDFLAGS}),-static)
174-
DWARFLIBS += -lelf -lz -llzma -lbz2 -lzstd
171+
DWLIBS += -lelf -lz -llzma -lbz2 -lzstd
175172

176173
LIBDW_VERSION := $(shell $(PKG_CONFIG) --modversion libdw).0.0
177174
LIBDW_VERSION_1 := $(word 1, $(subst ., ,$(LIBDW_VERSION)))
@@ -180,21 +177,15 @@ ifeq ($(findstring -static,${LDFLAGS}),-static)
180177
# Elfutils merged libebl.a into libdw.a starting from version 0.177,
181178
# Link libebl.a only if libdw is older than this version.
182179
ifeq ($(shell test $(LIBDW_VERSION_2) -lt 177; echo $$?),0)
183-
DWARFLIBS += -lebl
180+
DWLIBS += -lebl
184181
endif
185182

186183
# Must put -ldl after -lebl for dependency
187184
DWARFLIBS += -ldl
188185
endif
189186

190-
$(OUTPUT)test-dwarf.bin:
191-
$(BUILD) $(DWARFLIBS)
192-
193-
$(OUTPUT)test-dwarf_getlocations.bin:
194-
$(BUILD) $(DWARFLIBS)
195-
196-
$(OUTPUT)test-dwarf_getcfi.bin:
197-
$(BUILD) $(DWARFLIBS)
187+
$(OUTPUT)test-libdw.bin:
188+
$(BUILD) $(DWLIBS)
198189

199190
$(OUTPUT)test-libelf-getphdrnum.bin:
200191
$(BUILD) -lelf
@@ -321,9 +312,6 @@ $(OUTPUT)test-backtrace.bin:
321312
$(OUTPUT)test-timerfd.bin:
322313
$(BUILD)
323314

324-
$(OUTPUT)test-libdw-dwarf-unwind.bin:
325-
$(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
326-
327315
$(OUTPUT)test-libbabeltrace.bin:
328316
$(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
329317

tools/build/feature/test-all.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@
3838
# include "test-glibc.c"
3939
#undef main
4040

41-
#define main main_test_dwarf
42-
# include "test-dwarf.c"
43-
#undef main
44-
45-
#define main main_test_dwarf_getlocations
46-
# include "test-dwarf_getlocations.c"
41+
#define main main_test_libdw
42+
# include "test-libdw.c"
4743
#undef main
4844

4945
#define main main_test_eventfd
@@ -98,10 +94,6 @@
9894
# include "test-stackprotector-all.c"
9995
#undef main
10096

101-
#define main main_test_libdw_dwarf_unwind
102-
# include "test-libdw-dwarf-unwind.c"
103-
#undef main
104-
10597
#define main main_test_zlib
10698
# include "test-zlib.c"
10799
#undef main
@@ -187,8 +179,7 @@ int main(int argc, char *argv[])
187179
main_test_get_current_dir_name();
188180
main_test_gettid();
189181
main_test_glibc();
190-
main_test_dwarf();
191-
main_test_dwarf_getlocations();
182+
main_test_libdw();
192183
main_test_eventfd();
193184
main_test_libelf_getphdrnum();
194185
main_test_libelf_gelf_getnote();
@@ -202,7 +193,6 @@ int main(int argc, char *argv[])
202193
main_test_numa_num_possible_cpus();
203194
main_test_timerfd();
204195
main_test_stackprotector_all();
205-
main_test_libdw_dwarf_unwind();
206196
main_test_zlib();
207197
main_test_pthread_attr_setaffinity_np();
208198
main_test_pthread_barrier();

tools/build/feature/test-dwarf.c

Lines changed: 0 additions & 11 deletions
This file was deleted.

tools/build/feature/test-dwarf_getcfi.c

Lines changed: 0 additions & 9 deletions
This file was deleted.

tools/build/feature/test-dwarf_getlocations.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

tools/build/feature/test-libdw-dwarf-unwind.c

Lines changed: 0 additions & 14 deletions
This file was deleted.

tools/build/feature/test-libdw.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#include <stdlib.h>
3+
#include <dwarf.h>
4+
#include <elfutils/libdw.h>
5+
#include <elfutils/libdwfl.h>
6+
#include <elfutils/version.h>
7+
8+
int test_libdw(void)
9+
{
10+
Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
11+
12+
return (long)dbg;
13+
}
14+
15+
int test_libdw_unwind(void)
16+
{
17+
/*
18+
* This function is guarded via: __nonnull_attribute__ (1, 2).
19+
* Passing '1' as arguments value. This code is never executed,
20+
* only compiled.
21+
*/
22+
dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
23+
return 0;
24+
}
25+
26+
int test_libdw_getlocations(void)
27+
{
28+
Dwarf_Addr base, start, end;
29+
Dwarf_Attribute attr;
30+
Dwarf_Op *op;
31+
size_t nops;
32+
ptrdiff_t offset = 0;
33+
34+
return (int)dwarf_getlocations(&attr, offset, &base, &start, &end, &op, &nops);
35+
}
36+
37+
int test_libdw_getcfi(void)
38+
{
39+
Dwarf *dwarf = NULL;
40+
41+
return dwarf_getcfi(dwarf) == NULL;
42+
}
43+
44+
int test_elfutils(void)
45+
{
46+
Dwarf_CFI *cfi = NULL;
47+
48+
dwarf_cfi_end(cfi);
49+
return 0;
50+
}
51+
52+
int main(void)
53+
{
54+
return test_libdw() + test_libdw_unwind() + test_libdw_getlocations() +
55+
test_libdw_getcfi() + test_elfutils();
56+
}

tools/build/feature/test-libtraceevent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#include <traceevent/trace-seq.h>
2+
#include <trace-seq.h>
33

44
int main(void)
55
{

tools/lib/api/io.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ static inline ssize_t io__getdelim(struct io *io, char **line_out, size_t *line_
189189
err_out:
190190
free(line);
191191
*line_out = NULL;
192+
*line_len_out = 0;
192193
return -ENOMEM;
193194
}
194195

0 commit comments

Comments
 (0)