Commit 998ccc32 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'perf-tools-fixes-for-v6.18-2-2025-11-16' of...

Merge tag 'perf-tools-fixes-for-v6.18-2-2025-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools

Pull perf tools fixes from Arnaldo Carvalho de Melo:

 - Fix writing bpf_prog (infos|btfs)_cnt to data file, to not generate
   invalid perf.data files in some corner cases.

 - Fix 'perf top' segfault by ensuring libbfd is initialized. This is an
   opt-in feature due to license incompatibilities.

 - Fix segfault in 'perf lock' due to missing kernel map.

 - Fix 'perf lock contention' test.

 - Don't fail fast path detection if binutils-devel isn't available.

 - Sync KVM's vmx.h with the kernel to pick SEAMCALL exit reason.

* tag 'perf-tools-fixes-for-v6.18-2-2025-11-16' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools:
  perf libbfd: Ensure libbfd is initialized prior to use
  perf test: Fix lock contention test
  perf lock: Fix segfault due to missing kernel map
  tools headers UAPI: Sync KVM's vmx.h with the kernel to pick SEAMCALL exit reason
  perf build: Don't fail fast path feature detection when binutils-devel is not available
  perf header: Write bpf_prog (infos|btfs)_cnt to data file
parents 7ba45f15 b72b8132
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@
#define EXIT_REASON_TPAUSE              68
#define EXIT_REASON_BUS_LOCK            74
#define EXIT_REASON_NOTIFY              75
#define EXIT_REASON_SEAMCALL            76
#define EXIT_REASON_TDCALL              77
#define EXIT_REASON_MSR_READ_IMM        84
#define EXIT_REASON_MSR_WRITE_IMM       85
+2 −2
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ all: $(FILES)
__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
  BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
  BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
  BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd
  BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -ldl -lz -llzma -lzstd

__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
  BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
@@ -115,7 +115,7 @@ __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(
###############################

$(OUTPUT)test-all.bin:
	$(BUILD_ALL) || $(BUILD_ALL) -lopcodes -liberty
	$(BUILD_ALL)

$(OUTPUT)test-hello.bin:
	$(BUILD)
+2 −3
Original line number Diff line number Diff line
@@ -354,9 +354,6 @@ FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)

FEATURE_CHECK_LDFLAGS-libaio = -lrt

FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl

CORE_CFLAGS += -fno-omit-frame-pointer
CORE_CFLAGS += -Wall
CORE_CFLAGS += -Wextra
@@ -930,6 +927,8 @@ ifdef BUILD_NONDISTRO

  ifeq ($(feature-libbfd), 1)
    EXTLIBS += -lbfd -lopcodes
    FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
    FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl
  else
    # we are on a system that requires -liberty and (maybe) -lz
    # to link against -lbfd; test each case individually here
+2 −0
Original line number Diff line number Diff line
@@ -1867,6 +1867,7 @@ static int __cmd_report(bool display_info)
	eops.sample		 = process_sample_event;
	eops.comm		 = perf_event__process_comm;
	eops.mmap		 = perf_event__process_mmap;
	eops.mmap2		 = perf_event__process_mmap2;
	eops.namespaces		 = perf_event__process_namespaces;
	eops.tracing_data	 = perf_event__process_tracing_data;
	session = perf_session__new(&data, &eops);
@@ -2023,6 +2024,7 @@ static int __cmd_contention(int argc, const char **argv)
	eops.sample		 = process_sample_event;
	eops.comm		 = perf_event__process_comm;
	eops.mmap		 = perf_event__process_mmap;
	eops.mmap2		 = perf_event__process_mmap2;
	eops.tracing_data	 = perf_event__process_tracing_data;

	perf_env__init(&host_env);
+9 −5
Original line number Diff line number Diff line
@@ -13,15 +13,18 @@ cleanup() {
	rm -f ${perfdata}
	rm -f ${result}
	rm -f ${errout}
	trap - EXIT TERM INT
	trap - EXIT TERM INT ERR
}

trap_cleanup() {
	if (( $? == 139 )); then #SIGSEGV
		err=1
	fi
	echo "Unexpected signal in ${FUNCNAME[1]}"
	cleanup
	exit ${err}
}
trap trap_cleanup EXIT TERM INT
trap trap_cleanup EXIT TERM INT ERR

check() {
	if [ "$(id -u)" != 0 ]; then
@@ -145,7 +148,7 @@ test_aggr_cgroup()
	fi

	# the perf lock contention output goes to the stderr
	perf lock con -a -b -g -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
	perf lock con -a -b --lock-cgroup -E 1 -q -- perf bench sched messaging -p > /dev/null 2> ${result}
	if [ "$(cat "${result}" | wc -l)" != "1" ]; then
		echo "[Fail] BPF result count is not 1:" "$(cat "${result}" | wc -l)"
		err=1
@@ -271,7 +274,7 @@ test_cgroup_filter()
		return
	fi

	perf lock con -a -b -g -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result}
	perf lock con -a -b --lock-cgroup -E 1 -F wait_total -q -- perf bench sched messaging -p > /dev/null 2> ${result}
	if [ "$(cat "${result}" | wc -l)" != "1" ]; then
		echo "[Fail] BPF result should have a cgroup result:" "$(cat "${result}")"
		err=1
@@ -279,7 +282,7 @@ test_cgroup_filter()
	fi

	cgroup=$(cat "${result}" | awk '{ print $3 }')
	perf lock con -a -b -g -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result}
	perf lock con -a -b --lock-cgroup -E 1 -G "${cgroup}" -q -- perf bench sched messaging -p > /dev/null 2> ${result}
	if [ "$(cat "${result}" | wc -l)" != "1" ]; then
		echo "[Fail] BPF result should have a result with cgroup filter:" "$(cat "${cgroup}")"
		err=1
@@ -338,4 +341,5 @@ test_aggr_task_stack_filter
test_cgroup_filter
test_csv_output

cleanup
exit ${err}
Loading