Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf build: Use libtraceevent from the system

Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.

If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.

This also disables CONFIG_TRACE that controls "perf trace".

CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.

Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".

Committer notes:

Fixed up a tools/perf/util/Build reject and added:

#include <traceevent/event-parse.h>

to tools/perf/util/scripting-engines/trace-event-perl.c.

Committer testing:

$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$

Default build:

$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$

# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#

Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.

Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:

- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y

- perf-$(CONFIG_LIBTRACEEVENT) += scripts/

- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y

- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.

Building without libtraceevent-devel installed uncovered more build
failures:

- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.

- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.

From Athira:

<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>

Then, ditto for arm64 and s390, detected by container cross build tests.

- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.

Also from Athira:

<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>

Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
378ef0f5 40769665

+355 -184
+12 -8
tools/perf/Build
··· 5 5 perf-y += builtin-evlist.o 6 6 perf-y += builtin-ftrace.o 7 7 perf-y += builtin-help.o 8 - perf-y += builtin-sched.o 9 8 perf-y += builtin-buildid-list.o 10 9 perf-y += builtin-buildid-cache.o 11 10 perf-y += builtin-kallsyms.o ··· 12 13 perf-y += builtin-record.o 13 14 perf-y += builtin-report.o 14 15 perf-y += builtin-stat.o 15 - perf-y += builtin-timechart.o 16 16 perf-y += builtin-top.o 17 17 perf-y += builtin-script.o 18 - perf-y += builtin-kmem.o 19 - perf-y += builtin-lock.o 20 18 perf-y += builtin-kvm.o 21 19 perf-y += builtin-inject.o 22 20 perf-y += builtin-mem.o ··· 21 25 perf-y += builtin-version.o 22 26 perf-y += builtin-c2c.o 23 27 perf-y += builtin-daemon.o 24 - perf-y += builtin-kwork.o 25 28 26 - perf-$(CONFIG_TRACE) += builtin-trace.o 29 + perf-$(CONFIG_LIBTRACEEVENT) += builtin-kmem.o 30 + perf-$(CONFIG_LIBTRACEEVENT) += builtin-kwork.o 31 + perf-$(CONFIG_LIBTRACEEVENT) += builtin-lock.o 32 + perf-$(CONFIG_LIBTRACEEVENT) += builtin-sched.o 33 + perf-$(CONFIG_LIBTRACEEVENT) += builtin-timechart.o 34 + 35 + ifeq ($(CONFIG_LIBTRACEEVENT),y) 36 + perf-$(CONFIG_TRACE) += builtin-trace.o 37 + perf-$(CONFIG_TRACE) += trace/beauty/ 38 + endif 39 + 27 40 perf-$(CONFIG_LIBELF) += builtin-probe.o 28 41 29 42 perf-y += bench/ ··· 56 51 perf-y += util/ 57 52 perf-y += arch/ 58 53 perf-y += ui/ 59 - perf-y += scripts/ 60 - perf-$(CONFIG_TRACE) += trace/beauty/ 54 + perf-$(CONFIG_LIBTRACEEVENT) += scripts/ 61 55 62 56 gtk-y += ui/gtk/
+19 -18
tools/perf/Makefile.config
··· 763 763 EXTLIBS += $(EXTLIBS_LIBUNWIND) 764 764 endif 765 765 766 - ifeq ($(NO_SYSCALL_TABLE),0) 767 - $(call detected,CONFIG_TRACE) 768 - else 769 - ifndef NO_LIBAUDIT 770 - $(call feature_check,libaudit) 771 - ifneq ($(feature-libaudit), 1) 772 - msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); 773 - NO_LIBAUDIT := 1 774 - else 775 - CFLAGS += -DHAVE_LIBAUDIT_SUPPORT 776 - EXTLIBS += -laudit 777 - $(call detected,CONFIG_TRACE) 766 + ifneq ($(NO_LIBTRACEEVENT),1) 767 + ifeq ($(NO_SYSCALL_TABLE),0) 768 + $(call detected,CONFIG_TRACE) 769 + else 770 + ifndef NO_LIBAUDIT 771 + $(call feature_check,libaudit) 772 + ifneq ($(feature-libaudit), 1) 773 + msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); 774 + NO_LIBAUDIT := 1 775 + else 776 + CFLAGS += -DHAVE_LIBAUDIT_SUPPORT 777 + EXTLIBS += -laudit 778 + $(call detected,CONFIG_TRACE) 779 + endif 778 780 endif 779 781 endif 780 782 endif ··· 1184 1182 endif 1185 1183 endif 1186 1184 1187 - ifdef LIBTRACEEVENT_DYNAMIC 1185 + # libtraceevent is a recommended dependency picked up from the system. 1186 + ifneq ($(NO_LIBTRACEEVENT),1) 1188 1187 $(call feature_check,libtraceevent) 1189 1188 ifeq ($(feature-libtraceevent), 1) 1189 + CFLAGS += -DHAVE_LIBTRACEEVENT 1190 1190 EXTLIBS += -ltraceevent 1191 1191 LIBTRACEEVENT_VERSION := $(shell $(PKG_CONFIG) --modversion libtraceevent) 1192 1192 LIBTRACEEVENT_VERSION_1 := $(word 1, $(subst ., ,$(LIBTRACEEVENT_VERSION))) ··· 1196 1192 LIBTRACEEVENT_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEEVENT_VERSION))) 1197 1193 LIBTRACEEVENT_VERSION_CPP := $(shell expr $(LIBTRACEEVENT_VERSION_1) \* 255 \* 255 + $(LIBTRACEEVENT_VERSION_2) \* 255 + $(LIBTRACEEVENT_VERSION_3)) 1198 1194 CFLAGS += -DLIBTRACEEVENT_VERSION=$(LIBTRACEEVENT_VERSION_CPP) 1195 + $(call detected,CONFIG_LIBTRACEEVENT) 1199 1196 else 1200 - dummy := $(error Error: No libtraceevent devel library found, please install libtraceevent-devel); 1197 + dummy := $(warning Warning: libtraceevent is missing limiting functionality, please install libtraceevent-dev/libtraceevent-devel) 1201 1198 endif 1202 - endif 1203 1199 1204 - ifdef LIBTRACEFS_DYNAMIC 1205 1200 $(call feature_check,libtracefs) 1206 1201 ifeq ($(feature-libtracefs), 1) 1207 1202 EXTLIBS += -ltracefs ··· 1210 1207 LIBTRACEFS_VERSION_3 := $(word 3, $(subst ., ,$(LIBTRACEFS_VERSION))) 1211 1208 LIBTRACEFS_VERSION_CPP := $(shell expr $(LIBTRACEFS_VERSION_1) \* 255 \* 255 + $(LIBTRACEFS_VERSION_2) \* 255 + $(LIBTRACEFS_VERSION_3)) 1212 1209 CFLAGS += -DLIBTRACEFS_VERSION=$(LIBTRACEFS_VERSION_CPP) 1213 - else 1214 - dummy := $(error Error: No libtracefs devel library found, please install libtracefs-dev); 1215 1210 endif 1216 1211 endif 1217 1212
+10 -94
tools/perf/Makefile.perf
··· 128 128 # 129 129 # Define BUILD_BPF_SKEL to enable BPF skeletons 130 130 # 131 - # Define LIBTRACEEVENT_DYNAMIC to enable libtraceevent dynamic linking 132 - # 133 - # Define LIBTRACEFS_DYNAMIC to enable libtracefs dynamic linking 134 - # 135 131 136 132 # As per kernel Makefile, avoid funny character set dependencies 137 133 unexport LC_ALL ··· 238 242 else # force_fixdep 239 243 240 244 LIBAPI_DIR = $(srctree)/tools/lib/api/ 241 - ifndef LIBTRACEEVENT_DYNAMIC 242 - LIBTRACEEVENT_DIR = $(srctree)/tools/lib/traceevent/ 243 - LIBTRACEEVENT_PLUGINS_DIR = $(LIBTRACEEVENT_DIR)/plugins 244 - endif 245 245 LIBBPF_DIR = $(srctree)/tools/lib/bpf/ 246 246 LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/ 247 247 LIBSYMBOL_DIR = $(srctree)/tools/lib/symbol/ ··· 286 294 287 295 grep-libs = $(filter -l%,$(1)) 288 296 strip-libs = $(filter-out -l%,$(1)) 289 - 290 - ifndef LIBTRACEEVENT_DYNAMIC 291 - ifneq ($(OUTPUT),) 292 - LIBTRACEEVENT_OUTPUT = $(abspath $(OUTPUT))/libtraceevent 293 - else 294 - LIBTRACEEVENT_OUTPUT = $(CURDIR)/libtraceevent 295 - endif 296 - LIBTRACEEVENT_PLUGINS_OUTPUT = $(LIBTRACEEVENT_OUTPUT)_plugins 297 - LIBTRACEEVENT_DESTDIR = $(LIBTRACEEVENT_OUTPUT) 298 - LIBTRACEEVENT_PLUGINS_DESTDIR = $(LIBTRACEEVENT_PLUGINS_OUTPUT) 299 - LIBTRACEEVENT_INCLUDE = $(LIBTRACEEVENT_DESTDIR)/include 300 - LIBTRACEEVENT = $(LIBTRACEEVENT_OUTPUT)/libtraceevent.a 301 - export LIBTRACEEVENT 302 - LIBTRACEEVENT_DYNAMIC_LIST = $(LIBTRACEEVENT_PLUGINS_OUTPUT)/libtraceevent-dynamic-list 303 - CFLAGS += -I$(LIBTRACEEVENT_OUTPUT)/include 304 - # 305 - # The static build has no dynsym table, so this does not work for 306 - # static build. Looks like linker starts to scream about that now 307 - # (in Fedora 26) so we need to switch it off for static build. 308 - DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST) 309 - LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS)) 310 - else 311 - LIBTRACEEVENT_DYNAMIC_LIST = 312 - LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = 313 - endif 314 297 315 298 ifneq ($(OUTPUT),) 316 299 LIBAPI_OUTPUT = $(abspath $(OUTPUT))/libapi ··· 347 380 348 381 python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so 349 382 350 - PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) 351 - ifndef LIBTRACEEVENT_DYNAMIC 352 - PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI) 383 + ifeq ($(CONFIG_LIBTRACEEVENT),y) 384 + PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) 353 385 else 354 - PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBAPI) 386 + PYTHON_EXT_SRCS := $(shell grep -v '^\#\|util/trace-event.c' util/python-ext-sources) 355 387 endif 388 + 389 + PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBAPI) 356 390 357 391 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) 358 392 ··· 397 429 ifndef LIBBPF_DYNAMIC 398 430 PERFLIBS += $(LIBBPF) 399 431 endif 400 - endif 401 - ifndef LIBTRACEEVENT_DYNAMIC 402 - PERFLIBS += $(LIBTRACEEVENT) 403 432 endif 404 433 405 434 # We choose to avoid "if .. else if .. else .. endif endif" ··· 647 682 # Create python binding output directory if not already present 648 683 _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') 649 684 650 - $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) $(LIBPERF) 685 + $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBPERF) 651 686 $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \ 652 - CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \ 687 + CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' \ 653 688 $(PYTHON_WORD) util/setup.py \ 654 689 --quiet build_ext; \ 655 690 cp $(PYTHON_EXTBUILD_LIB)perf*.so $(OUTPUT)python/ ··· 675 710 $(PMU_EVENTS_IN): FORCE prepare 676 711 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events 677 712 678 - $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) $(LIBTRACEEVENT_DYNAMIC_LIST) 679 - $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \ 713 + $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $(PMU_EVENTS_IN) 714 + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \ 680 715 $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@ 681 716 682 717 $(GTK_IN): FORCE prepare ··· 762 797 $(LIBSYMBOL) \ 763 798 bpf-skel 764 799 765 - ifndef LIBTRACEEVENT_DYNAMIC 766 - prepare: $(LIBTRACEEVENT) 767 - endif 768 - 769 800 $(OUTPUT)%.o: %.c prepare FORCE 770 801 $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ 771 802 ··· 816 855 endif 817 856 818 857 $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h) 819 - 820 - ifndef LIBTRACEEVENT_DYNAMIC 821 - LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(filter-out -static,$(LDFLAGS))' 822 - 823 - $(LIBTRACEEVENT): FORCE | $(LIBTRACEEVENT_OUTPUT) 824 - $(Q)$(MAKE) -C $(LIBTRACEEVENT_DIR) O=$(LIBTRACEEVENT_OUTPUT) \ 825 - DESTDIR=$(LIBTRACEEVENT_DESTDIR) prefix= \ 826 - $@ install_headers 827 - 828 - $(LIBTRACEEVENT)-clean: 829 - $(call QUIET_CLEAN, libtraceevent) 830 - $(Q)$(RM) -r -- $(LIBTRACEEVENT_OUTPUT) 831 - 832 - libtraceevent_plugins: FORCE | $(LIBTRACEEVENT_PLUGINS_OUTPUT) 833 - $(Q)$(MAKE) -C $(LIBTRACEEVENT_PLUGINS_DIR) O=$(LIBTRACEEVENT_PLUGINS_OUTPUT) \ 834 - DESTDIR=$(LIBTRACEEVENT_PLUGINS_DESTDIR) prefix= \ 835 - plugins 836 - 837 - libtraceevent_plugins-clean: 838 - $(call QUIET_CLEAN, libtraceevent_plugins) 839 - $(Q)$(RM) -r -- $(LIBTRACEEVENT_PLUGINS_OUTPUT) 840 - 841 - $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins 842 - $(Q)$(MAKE) -C $(LIBTRACEEVENT_PLUGINS_DIR) O=$(LIBTRACEEVENT_PLUGINS_OUTPUT) \ 843 - DESTDIR=$(LIBTRACEEVENT_PLUGINS_DESTDIR) prefix= \ 844 - $(LIBTRACEEVENT_FLAGS) $@ 845 - 846 - install-traceevent-plugins: libtraceevent_plugins 847 - $(Q)$(MAKE) -C $(LIBTRACEEVENT_PLUGINS_DIR) O=$(LIBTRACEEVENT_PLUGINS_OUTPUT) \ 848 - DESTDIR=$(DESTDIR_SQ)$(prefix) prefix= \ 849 - $(LIBTRACEEVENT_FLAGS) install 850 - endif 851 858 852 859 $(LIBAPI): FORCE | $(LIBAPI_OUTPUT) 853 860 $(Q)$(MAKE) -C $(LIBAPI_DIR) O=$(LIBAPI_OUTPUT) \ ··· 1024 1095 1025 1096 install-bin: install-tools install-tests 1026 1097 1027 - ifndef LIBTRACEEVENT_DYNAMIC 1028 - install-bin: install-traceevent-plugins 1029 - endif 1030 - 1031 1098 install: install-bin try-install-man 1032 1099 1033 1100 install-python_ext: ··· 1048 1123 1049 1124 $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): 1050 1125 $(Q)$(MKDIR) -p $@ 1051 - 1052 - ifndef LIBTRACEEVENT_DYNAMIC 1053 - $(LIBTRACEEVENT_OUTPUT) $(LIBTRACEEVENT_PLUGINS_OUTPUT): 1054 - $(Q)$(MKDIR) -p $@ 1055 - endif 1056 1126 1057 1127 ifdef BUILD_BPF_SKEL 1058 1128 BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool ··· 1131 1211 $(call QUIET_CLEAN, Documentation) \ 1132 1212 $(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null 1133 1213 1134 - ifndef LIBTRACEEVENT_DYNAMIC 1135 - clean:: $(LIBTRACEEVENT)-clean libtraceevent_plugins-clean 1136 - endif 1137 - 1138 1214 # 1139 1215 # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY) 1140 1216 # file if defined, with no further action. ··· 1148 1232 .PHONY: all install clean config-clean strip install-gtk 1149 1233 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell 1150 1234 .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare 1151 - .PHONY: libtraceevent_plugins archheaders 1235 + .PHONY: archheaders 1152 1236 1153 1237 endif # force_fixdep
+1 -1
tools/perf/arch/arm64/util/Build
··· 3 3 perf-y += perf_regs.o 4 4 perf-y += tsc.o 5 5 perf-y += pmu.o 6 - perf-y += kvm-stat.o 6 + perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o 7 7 perf-$(CONFIG_DWARF) += dwarf-regs.o 8 8 perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o 9 9 perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
+1 -1
tools/perf/arch/powerpc/util/Build
··· 1 1 perf-y += header.o 2 - perf-y += kvm-stat.o 2 + perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o 3 3 perf-y += perf_regs.o 4 4 perf-y += mem-events.o 5 5 perf-y += sym-handling.o
+1 -1
tools/perf/arch/s390/util/Build
··· 1 1 perf-y += header.o 2 - perf-y += kvm-stat.o 2 + perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o 3 3 perf-y += perf_regs.o 4 4 5 5 perf-$(CONFIG_DWARF) += dwarf-regs.o
+1 -1
tools/perf/arch/x86/util/Build
··· 1 1 perf-y += header.o 2 2 perf-y += tsc.o 3 3 perf-y += pmu.o 4 - perf-y += kvm-stat.o 4 + perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o 5 5 perf-y += perf_regs.o 6 6 perf-y += topdown.o 7 7 perf-y += machine.o
+4
tools/perf/arch/x86/util/intel-pt.c
··· 418 418 return 0; 419 419 } 420 420 421 + #ifdef HAVE_LIBTRACEEVENT 421 422 static int intel_pt_track_switches(struct evlist *evlist) 422 423 { 423 424 const char *sched_switch = "sched:sched_switch"; ··· 440 439 441 440 return 0; 442 441 } 442 + #endif 443 443 444 444 static void intel_pt_valid_str(char *str, size_t len, u64 valid) 445 445 { ··· 831 829 ptr->have_sched_switch = 2; 832 830 } 833 831 } else { 832 + #ifdef HAVE_LIBTRACEEVENT 834 833 err = intel_pt_track_switches(evlist); 835 834 if (err == -EPERM) 836 835 pr_debug2("Unable to select sched:sched_switch\n"); ··· 839 836 return err; 840 837 else 841 838 ptr->have_sched_switch = 1; 839 + #endif 842 840 } 843 841 } 844 842
+2
tools/perf/builtin-annotate.c
··· 499 499 .namespaces = perf_event__process_namespaces, 500 500 .attr = perf_event__process_attr, 501 501 .build_id = perf_event__process_build_id, 502 + #ifdef HAVE_LIBTRACEEVENT 502 503 .tracing_data = perf_event__process_tracing_data, 504 + #endif 503 505 .id_index = perf_event__process_id_index, 504 506 .auxtrace_info = perf_event__process_auxtrace_info, 505 507 .auxtrace = perf_event__process_auxtrace,
+3 -2
tools/perf/builtin-data.c
··· 78 78 return bt_convert__perf2json(input_name, to_json, &opts); 79 79 80 80 if (to_ctf) { 81 - #ifdef HAVE_LIBBABELTRACE_SUPPORT 81 + #if defined(HAVE_LIBBABELTRACE_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 82 82 return bt_convert__perf2ctf(input_name, to_ctf, &opts); 83 83 #else 84 84 pr_err("The libbabeltrace support is not compiled in. perf should be " 85 85 "compiled with environment variables LIBBABELTRACE=1 and " 86 - "LIBBABELTRACE_DIR=/path/to/libbabeltrace/\n"); 86 + "LIBBABELTRACE_DIR=/path/to/libbabeltrace/.\n" 87 + "Check also if libbtraceevent devel files are available.\n"); 87 88 return -1; 88 89 #endif 89 90 }
+8
tools/perf/builtin-inject.c
··· 607 607 return err; 608 608 } 609 609 610 + #ifdef HAVE_LIBTRACEEVENT 610 611 static int perf_event__repipe_tracing_data(struct perf_session *session, 611 612 union perf_event *event) 612 613 { ··· 615 614 616 615 return perf_event__process_tracing_data(session, event); 617 616 } 617 + #endif 618 618 619 619 static int dso__read_build_id(struct dso *dso) 620 620 { ··· 809 807 return 0; 810 808 } 811 809 810 + #ifdef HAVE_LIBTRACEEVENT 812 811 static int perf_inject__sched_stat(struct perf_tool *tool, 813 812 union perf_event *event __maybe_unused, 814 813 struct perf_sample *sample, ··· 839 836 build_id__mark_dso_hit(tool, event_sw, &sample_sw, evsel, machine); 840 837 return perf_event__repipe(tool, event_sw, &sample_sw, machine); 841 838 } 839 + #endif 842 840 843 841 static struct guest_vcpu *guest_session__vcpu(struct guest_session *gs, u32 vcpu) 844 842 { ··· 1965 1961 inject->tool.mmap = perf_event__repipe_mmap; 1966 1962 inject->tool.mmap2 = perf_event__repipe_mmap2; 1967 1963 inject->tool.fork = perf_event__repipe_fork; 1964 + #ifdef HAVE_LIBTRACEEVENT 1968 1965 inject->tool.tracing_data = perf_event__repipe_tracing_data; 1966 + #endif 1969 1967 } 1970 1968 1971 1969 output_data_offset = perf_session__data_offset(session->evlist); ··· 1990 1984 evsel->handler = perf_inject__sched_switch; 1991 1985 } else if (!strcmp(name, "sched:sched_process_exit")) 1992 1986 evsel->handler = perf_inject__sched_process_exit; 1987 + #ifdef HAVE_LIBTRACEEVENT 1993 1988 else if (!strncmp(name, "sched:sched_stat_", 17)) 1994 1989 evsel->handler = perf_inject__sched_stat; 1990 + #endif 1995 1991 } 1996 1992 } else if (inject->itrace_synth_opts.vm_time_correlation) { 1997 1993 session->itrace_synth_opts = &inject->itrace_synth_opts;
+1
tools/perf/builtin-kmem.c
··· 35 35 #include <regex.h> 36 36 37 37 #include <linux/ctype.h> 38 + #include <traceevent/event-parse.h> 38 39 39 40 static int kmem_slab; 40 41 static int kmem_page;
+6 -6
tools/perf/builtin-kvm.c
··· 63 63 return filename; 64 64 } 65 65 66 - #ifdef HAVE_KVM_STAT_SUPPORT 66 + #if defined(HAVE_KVM_STAT_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 67 67 68 68 void exit_event_get_key(struct evsel *evsel, 69 69 struct perf_sample *sample, ··· 654 654 pr_info("\nLost events: %" PRIu64 "\n\n", kvm->lost_events); 655 655 } 656 656 657 - #ifdef HAVE_TIMERFD_SUPPORT 657 + #if defined(HAVE_TIMERFD_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 658 658 static int process_lost_event(struct perf_tool *tool, 659 659 union perf_event *event __maybe_unused, 660 660 struct perf_sample *sample __maybe_unused, ··· 742 742 return true; 743 743 } 744 744 745 - #ifdef HAVE_TIMERFD_SUPPORT 745 + #if defined(HAVE_TIMERFD_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 746 746 /* keeping the max events to a modest level to keep 747 747 * the processing of samples per mmap smooth. 748 748 */ ··· 1290 1290 return kvm_events_report_vcpu(kvm); 1291 1291 } 1292 1292 1293 - #ifdef HAVE_TIMERFD_SUPPORT 1293 + #if defined(HAVE_TIMERFD_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 1294 1294 static struct evlist *kvm_live_event_list(void) 1295 1295 { 1296 1296 struct evlist *evlist; ··· 1507 1507 if (strlen(argv[1]) > 2 && strstarts("report", argv[1])) 1508 1508 return kvm_events_report(&kvm, argc - 1 , argv + 1); 1509 1509 1510 - #ifdef HAVE_TIMERFD_SUPPORT 1510 + #if defined(HAVE_TIMERFD_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 1511 1511 if (!strncmp(argv[1], "live", 4)) 1512 1512 return kvm_events_live(&kvm, argc - 1 , argv + 1); 1513 1513 #endif ··· 1644 1644 return cmd_top(argc, argv); 1645 1645 else if (strlen(argv[0]) > 2 && strstarts("buildid-list", argv[0])) 1646 1646 return __cmd_buildid_list(file_name, argc, argv); 1647 - #ifdef HAVE_KVM_STAT_SUPPORT 1647 + #if defined(HAVE_KVM_STAT_SUPPORT) && defined(HAVE_LIBTRACEEVENT) 1648 1648 else if (strlen(argv[0]) > 2 && strstarts("stat", argv[0])) 1649 1649 return kvm_cmd_stat(file_name, argc, argv); 1650 1650 #endif
+1
tools/perf/builtin-kwork.c
··· 23 23 24 24 #include <subcmd/pager.h> 25 25 #include <subcmd/parse-options.h> 26 + #include <traceevent/event-parse.h> 26 27 27 28 #include <errno.h> 28 29 #include <inttypes.h>
+2
tools/perf/builtin-record.c
··· 1701 1701 if (rec->no_buildid) 1702 1702 perf_header__clear_feat(&session->header, HEADER_BUILD_ID); 1703 1703 1704 + #ifdef HAVE_LIBTRACEEVENT 1704 1705 if (!have_tracepoints(&rec->evlist->core.entries)) 1705 1706 perf_header__clear_feat(&session->header, HEADER_TRACING_DATA); 1707 + #endif 1706 1708 1707 1709 if (!rec->opts.branch_stack) 1708 1710 perf_header__clear_feat(&session->header, HEADER_BRANCH_STACK);
+8 -1
tools/perf/builtin-report.c
··· 67 67 #include <unistd.h> 68 68 #include <linux/mman.h> 69 69 70 + #ifdef HAVE_LIBTRACEEVENT 71 + #include <traceevent/event-parse.h> 72 + #endif 73 + 70 74 struct report { 71 75 struct perf_tool tool; 72 76 struct perf_session *session; ··· 1203 1199 .lost = perf_event__process_lost, 1204 1200 .read = process_read_event, 1205 1201 .attr = process_attr, 1202 + #ifdef HAVE_LIBTRACEEVENT 1206 1203 .tracing_data = perf_event__process_tracing_data, 1204 + #endif 1207 1205 .build_id = perf_event__process_build_id, 1208 1206 .id_index = perf_event__process_id_index, 1209 1207 .auxtrace_info = perf_event__process_auxtrace_info, ··· 1666 1660 report.range_num); 1667 1661 } 1668 1662 1663 + #ifdef HAVE_LIBTRACEEVENT 1669 1664 if (session->tevent.pevent && 1670 1665 tep_set_function_resolver(session->tevent.pevent, 1671 1666 machine__resolve_kernel_addr, ··· 1675 1668 __func__); 1676 1669 return -1; 1677 1670 } 1678 - 1671 + #endif 1679 1672 sort__setup_elide(stdout); 1680 1673 1681 1674 ret = __cmd_report(&report);
+15 -4
tools/perf/builtin-script.c
··· 62 62 #include "perf.h" 63 63 64 64 #include <linux/ctype.h> 65 + #ifdef HAVE_LIBTRACEEVENT 66 + #include <traceevent/event-parse.h> 67 + #endif 65 68 66 69 static char const *script_name; 67 70 static char const *generate_script_lang; ··· 2157 2154 perf_sample__fprintf_bts(sample, evsel, thread, al, addr_al, machine, fp); 2158 2155 return; 2159 2156 } 2160 - 2157 + #ifdef HAVE_LIBTRACEEVENT 2161 2158 if (PRINT_FIELD(TRACE) && sample->raw_data) { 2162 2159 event_format__fprintf(evsel->tp_format, sample->cpu, 2163 2160 sample->raw_data, sample->raw_size, fp); 2164 2161 } 2165 - 2162 + #endif 2166 2163 if (attr->type == PERF_TYPE_SYNTH && PRINT_FIELD(SYNTH)) 2167 2164 perf_sample__fprintf_synth(sample, evsel, fp); 2168 2165 ··· 2286 2283 2287 2284 static void setup_scripting(void) 2288 2285 { 2286 + #ifdef HAVE_LIBTRACEEVENT 2289 2287 setup_perl_scripting(); 2290 2288 setup_python_scripting(); 2289 + #endif 2291 2290 } 2292 2291 2293 2292 static int flush_scripting(void) ··· 3789 3784 .fork = perf_event__process_fork, 3790 3785 .attr = process_attr, 3791 3786 .event_update = perf_event__process_event_update, 3787 + #ifdef HAVE_LIBTRACEEVENT 3792 3788 .tracing_data = perf_event__process_tracing_data, 3789 + #endif 3793 3790 .feature = process_feature_event, 3794 3791 .build_id = perf_event__process_build_id, 3795 3792 .id_index = perf_event__process_id_index, ··· 4222 4215 else 4223 4216 symbol_conf.use_callchain = false; 4224 4217 4218 + #ifdef HAVE_LIBTRACEEVENT 4225 4219 if (session->tevent.pevent && 4226 4220 tep_set_function_resolver(session->tevent.pevent, 4227 4221 machine__resolve_kernel_addr, ··· 4231 4223 err = -1; 4232 4224 goto out_delete; 4233 4225 } 4234 - 4226 + #endif 4235 4227 if (generate_script_lang) { 4236 4228 struct stat perf_stat; 4237 4229 int input; ··· 4267 4259 err = -ENOENT; 4268 4260 goto out_delete; 4269 4261 } 4270 - 4262 + #ifdef HAVE_LIBTRACEEVENT 4271 4263 err = scripting_ops->generate_script(session->tevent.pevent, 4272 4264 "perf-script"); 4265 + #else 4266 + err = scripting_ops->generate_script(NULL, "perf-script"); 4267 + #endif 4273 4268 goto out_delete; 4274 4269 } 4275 4270
+1
tools/perf/builtin-timechart.c
··· 38 38 #include "util/string2.h" 39 39 #include "util/tracepoint.h" 40 40 #include <linux/err.h> 41 + #include <traceevent/event-parse.h> 41 42 42 43 #ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE 43 44 FILE *open_memstream(char **ptr, size_t *sizeloc);
+4 -1
tools/perf/builtin-trace.c
··· 15 15 */ 16 16 17 17 #include "util/record.h" 18 - #include <traceevent/event-parse.h> 19 18 #include <api/fs/tracing_path.h> 20 19 #include <bpf/bpf.h> 21 20 #include "util/bpf_map.h" ··· 78 79 79 80 #include <linux/ctype.h> 80 81 #include <perf/mmap.h> 82 + 83 + #ifdef HAVE_LIBTRACEEVENT 84 + #include <traceevent/event-parse.h> 85 + #endif 81 86 82 87 #ifndef O_CLOEXEC 83 88 # define O_CLOEXEC 02000000
+1
tools/perf/builtin-version.c
··· 82 82 STATUS(HAVE_AIO_SUPPORT, aio); 83 83 STATUS(HAVE_ZSTD_SUPPORT, zstd); 84 84 STATUS(HAVE_LIBPFM, libpfm4); 85 + STATUS(HAVE_LIBTRACEEVENT, libtraceevent); 85 86 } 86 87 87 88 int cmd_version(int argc, const char **argv)
+18 -6
tools/perf/perf.c
··· 70 70 { "report", cmd_report, 0 }, 71 71 { "bench", cmd_bench, 0 }, 72 72 { "stat", cmd_stat, 0 }, 73 + #ifdef HAVE_LIBTRACEEVENT 73 74 { "timechart", cmd_timechart, 0 }, 75 + #endif 74 76 { "top", cmd_top, 0 }, 75 77 { "annotate", cmd_annotate, 0 }, 76 78 { "version", cmd_version, 0 }, 77 79 { "script", cmd_script, 0 }, 80 + #ifdef HAVE_LIBTRACEEVENT 78 81 { "sched", cmd_sched, 0 }, 82 + #endif 79 83 #ifdef HAVE_LIBELF_SUPPORT 80 84 { "probe", cmd_probe, 0 }, 81 85 #endif 86 + #ifdef HAVE_LIBTRACEEVENT 82 87 { "kmem", cmd_kmem, 0 }, 83 88 { "lock", cmd_lock, 0 }, 89 + #endif 84 90 { "kvm", cmd_kvm, 0 }, 85 91 { "test", cmd_test, 0 }, 86 - #if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT) 92 + #if defined(HAVE_LIBTRACEEVENT) && (defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT)) 87 93 { "trace", cmd_trace, 0 }, 88 94 #endif 89 95 { "inject", cmd_inject, 0 }, ··· 97 91 { "data", cmd_data, 0 }, 98 92 { "ftrace", cmd_ftrace, 0 }, 99 93 { "daemon", cmd_daemon, 0 }, 94 + #ifdef HAVE_LIBTRACEEVENT 100 95 { "kwork", cmd_kwork, 0 }, 96 + #endif 101 97 }; 102 98 103 99 struct pager_config { ··· 508 500 argv[0] = cmd; 509 501 } 510 502 if (strstarts(cmd, "trace")) { 511 - #if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT) 512 - setup_path(); 513 - argv[0] = "trace"; 514 - return cmd_trace(argc, argv); 515 - #else 503 + #ifndef HAVE_LIBTRACEEVENT 504 + fprintf(stderr, 505 + "trace command not available: missing libtraceevent devel package at build time.\n"); 506 + goto out; 507 + #elif !defined(HAVE_LIBAUDIT_SUPPORT) && !defined(HAVE_SYSCALL_TABLE_SUPPORT) 516 508 fprintf(stderr, 517 509 "trace command not available: missing audit-libs devel package at build time.\n"); 518 510 goto out; 511 + #else 512 + setup_path(); 513 + argv[0] = "trace"; 514 + return cmd_trace(argc, argv); 519 515 #endif 520 516 } 521 517 /* Look for flags.. */
+1 -1
tools/perf/scripts/python/Perf-Trace-Util/Build
··· 1 - perf-y += Context.o 1 + perf-$(CONFIG_LIBTRACEEVENT) += Context.o 2 2 3 3 CFLAGS_Context.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs
+6 -6
tools/perf/tests/Build
··· 6 6 perf-y += dso-data.o 7 7 perf-y += attr.o 8 8 perf-y += vmlinux-kallsyms.o 9 - perf-y += openat-syscall.o 10 - perf-y += openat-syscall-all-cpus.o 11 - perf-y += openat-syscall-tp-fields.o 12 - perf-y += mmap-basic.o 9 + perf-$(CONFIG_LIBTRACEEVENT) += openat-syscall.o 10 + perf-$(CONFIG_LIBTRACEEVENT) += openat-syscall-all-cpus.o 11 + perf-$(CONFIG_LIBTRACEEVENT) += openat-syscall-tp-fields.o 12 + perf-$(CONFIG_LIBTRACEEVENT) += mmap-basic.o 13 13 perf-y += perf-record.o 14 14 perf-y += evsel-roundtrip-name.o 15 - perf-y += evsel-tp-sched.o 15 + perf-$(CONFIG_LIBTRACEEVENT) += evsel-tp-sched.o 16 16 perf-y += fdarray.o 17 17 perf-y += pmu.o 18 18 perf-y += pmu-events.o ··· 30 30 perf-y += sw-clock.o 31 31 perf-y += mmap-thread-lookup.o 32 32 perf-y += thread-maps-share.o 33 - perf-y += switch-tracking.o 33 + perf-$(CONFIG_LIBTRACEEVENT) += switch-tracking.o 34 34 perf-y += keep-tracking.o 35 35 perf-y += code-reading.o 36 36 perf-y += sample-parsing.o
+6
tools/perf/tests/builtin-test.c
··· 38 38 39 39 static struct test_suite *generic_tests[] = { 40 40 &suite__vmlinux_matches_kallsyms, 41 + #ifdef HAVE_LIBTRACEEVENT 41 42 &suite__openat_syscall_event, 42 43 &suite__openat_syscall_event_on_all_cpus, 43 44 &suite__basic_mmap, 45 + #endif 44 46 &suite__mem, 45 47 &suite__parse_events, 46 48 &suite__expr, ··· 53 51 &suite__dso_data_cache, 54 52 &suite__dso_data_reopen, 55 53 &suite__perf_evsel__roundtrip_name_test, 54 + #ifdef HAVE_LIBTRACEEVENT 56 55 &suite__perf_evsel__tp_sched_test, 57 56 &suite__syscall_openat_tp_fields, 57 + #endif 58 58 &suite__attr, 59 59 &suite__hists_link, 60 60 &suite__python_use, ··· 75 71 &suite__thread_maps_share, 76 72 &suite__hists_output, 77 73 &suite__hists_cumulate, 74 + #ifdef HAVE_LIBTRACEEVENT 78 75 &suite__switch_tracking, 76 + #endif 79 77 &suite__fdarray__filter, 80 78 &suite__fdarray__add, 81 79 &suite__kmod_path__parse,
+22 -1
tools/perf/tests/parse-events.c
··· 20 20 #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \ 21 21 PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) 22 22 23 + #ifdef HAVE_LIBTRACEEVENT 24 + 23 25 #if defined(__s390x__) 24 26 /* Return true if kvm module is available and loaded. Test this 25 27 * and return success when trace point kvm_s390_create_vm ··· 78 76 } 79 77 return TEST_OK; 80 78 } 79 + #endif /* HAVE_LIBTRACEEVENT */ 81 80 82 81 static int test__checkevent_raw(struct evlist *evlist) 83 82 { ··· 225 222 return TEST_OK; 226 223 } 227 224 225 + #ifdef HAVE_LIBTRACEEVENT 228 226 static int test__checkevent_tracepoint_modifier(struct evlist *evlist) 229 227 { 230 228 struct evsel *evsel = evlist__first(evlist); ··· 256 252 257 253 return test__checkevent_tracepoint_multi(evlist); 258 254 } 255 + #endif /* HAVE_LIBTRACEEVENT */ 259 256 260 257 static int test__checkevent_raw_modifier(struct evlist *evlist) 261 258 { ··· 458 453 return TEST_OK; 459 454 } 460 455 456 + #ifdef HAVE_LIBTRACEEVENT 461 457 static int test__checkevent_list(struct evlist *evlist) 462 458 { 463 459 struct evsel *evsel = evlist__first(evlist); ··· 497 491 498 492 return TEST_OK; 499 493 } 494 + #endif 500 495 501 496 static int test__checkevent_pmu_name(struct evlist *evlist) 502 497 { ··· 769 762 return TEST_OK; 770 763 } 771 764 765 + #ifdef HAVE_LIBTRACEEVENT 772 766 static int test__group3(struct evlist *evlist __maybe_unused) 773 767 { 774 768 struct evsel *evsel, *leader; ··· 861 853 862 854 return TEST_OK; 863 855 } 856 + #endif 864 857 865 858 static int test__group4(struct evlist *evlist __maybe_unused) 866 859 { ··· 1469 1460 return TEST_OK; 1470 1461 } 1471 1462 1463 + #ifdef HAVE_LIBTRACEEVENT 1472 1464 static int count_tracepoints(void) 1473 1465 { 1474 1466 struct dirent *events_ent; ··· 1523 1513 1524 1514 return test__checkevent_tracepoint_multi(evlist); 1525 1515 } 1516 + #endif /* HAVE_LIBTRACEVENT */ 1526 1517 1527 1518 static int test__hybrid_hw_event_with_pmu(struct evlist *evlist) 1528 1519 { ··· 1653 1642 }; 1654 1643 1655 1644 static const struct evlist_test test__events[] = { 1645 + #ifdef HAVE_LIBTRACEEVENT 1656 1646 { 1657 1647 .name = "syscalls:sys_enter_openat", 1658 1648 .check = test__checkevent_tracepoint, ··· 1664 1652 .check = test__checkevent_tracepoint_multi, 1665 1653 /* 1 */ 1666 1654 }, 1655 + #endif 1667 1656 { 1668 1657 .name = "r1a", 1669 1658 .check = test__checkevent_raw, ··· 1715 1702 .check = test__checkevent_breakpoint_w, 1716 1703 /* 1 */ 1717 1704 }, 1705 + #ifdef HAVE_LIBTRACEEVENT 1718 1706 { 1719 1707 .name = "syscalls:sys_enter_openat:k", 1720 1708 .check = test__checkevent_tracepoint_modifier, ··· 1726 1712 .check = test__checkevent_tracepoint_multi_modifier, 1727 1713 /* 3 */ 1728 1714 }, 1715 + #endif 1729 1716 { 1730 1717 .name = "r1a:kp", 1731 1718 .check = test__checkevent_raw_modifier, ··· 1772 1757 .check = test__checkevent_breakpoint_w_modifier, 1773 1758 /* 2 */ 1774 1759 }, 1760 + #ifdef HAVE_LIBTRACEEVENT 1775 1761 { 1776 1762 .name = "r1,syscalls:sys_enter_openat:k,1:1:hp", 1777 1763 .check = test__checkevent_list, 1778 1764 /* 3 */ 1779 1765 }, 1766 + #endif 1780 1767 { 1781 1768 .name = "instructions:G", 1782 1769 .check = test__checkevent_exclude_host_modifier, ··· 1809 1792 .check = test__group2, 1810 1793 /* 9 */ 1811 1794 }, 1795 + #ifdef HAVE_LIBTRACEEVENT 1812 1796 { 1813 1797 .name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", 1814 1798 .check = test__group3, 1815 1799 /* 0 */ 1816 1800 }, 1801 + #endif 1817 1802 { 1818 1803 .name = "{cycles:u,instructions:kp}:p", 1819 1804 .check = test__group4, ··· 1826 1807 .check = test__group5, 1827 1808 /* 2 */ 1828 1809 }, 1810 + #ifdef HAVE_LIBTRACEEVENT 1829 1811 { 1830 1812 .name = "*:*", 1831 1813 .check = test__all_tracepoints, 1832 1814 /* 3 */ 1833 1815 }, 1816 + #endif 1834 1817 { 1835 1818 .name = "{cycles,cache-misses:G}:H", 1836 1819 .check = test__group_gh1, ··· 1888 1867 .check = test__checkevent_breakpoint_len_rw_modifier, 1889 1868 /* 4 */ 1890 1869 }, 1891 - #if defined(__s390x__) 1870 + #if defined(__s390x__) && defined(HAVE_LIBTRACEEVENT) 1892 1871 { 1893 1872 .name = "kvm-s390:kvm_s390_create_vm", 1894 1873 .check = test__checkevent_tracepoint,
+14 -7
tools/perf/util/Build
··· 69 69 perf-y += comm.o 70 70 perf-y += thread.o 71 71 perf-y += thread_map.o 72 - perf-y += trace-event-parse.o 73 72 perf-y += parse-events-flex.o 74 73 perf-y += parse-events-bison.o 75 74 perf-y += pmu.o ··· 76 77 perf-y += pmu-flex.o 77 78 perf-y += pmu-bison.o 78 79 perf-y += pmu-hybrid.o 79 - perf-y += trace-event-read.o 80 - perf-y += trace-event-info.o 81 - perf-y += trace-event-scripting.o 82 - perf-y += trace-event.o 83 80 perf-y += svghelper.o 81 + perf-$(CONFIG_LIBTRACEEVENT) += trace-event-info.o 82 + perf-$(CONFIG_LIBTRACEEVENT) += trace-event-scripting.o 83 + perf-$(CONFIG_LIBTRACEEVENT) += trace-event.o 84 + perf-$(CONFIG_LIBTRACEEVENT) += trace-event-parse.o 85 + perf-$(CONFIG_LIBTRACEEVENT) += trace-event-read.o 84 86 perf-y += sort.o 85 87 perf-y += hist.o 86 88 perf-y += util.o ··· 153 153 perf-$(CONFIG_PERF_BPF_SKEL) += bpf_counter_cgroup.o 154 154 perf-$(CONFIG_PERF_BPF_SKEL) += bpf_ftrace.o 155 155 perf-$(CONFIG_PERF_BPF_SKEL) += bpf_off_cpu.o 156 - perf-$(CONFIG_PERF_BPF_SKEL) += bpf_kwork.o 157 156 perf-$(CONFIG_PERF_BPF_SKEL) += bpf_lock_contention.o 157 + 158 + ifeq ($(CONFIG_LIBTRACEEVENT),y) 159 + perf-$(CONFIG_PERF_BPF_SKEL) += bpf_kwork.o 160 + endif 161 + 158 162 perf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o 159 163 perf-$(CONFIG_LIBELF) += symbol-elf.o 160 164 perf-$(CONFIG_LIBELF) += probe-file.o ··· 193 189 perf-$(CONFIG_LIBUNWIND_X86) += libunwind/x86_32.o 194 190 perf-$(CONFIG_LIBUNWIND_AARCH64) += libunwind/arm64.o 195 191 196 - perf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o 192 + ifeq ($(CONFIG_LIBTRACEEVENT),y) 193 + perf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o 194 + endif 195 + 197 196 perf-y += data-convert-json.o 198 197 199 198 perf-y += scripting-engines/
+4 -1
tools/perf/util/data-convert-bt.c
··· 19 19 #include <babeltrace/ctf-writer/event-fields.h> 20 20 #include <babeltrace/ctf-ir/utils.h> 21 21 #include <babeltrace/ctf/events.h> 22 - #include <traceevent/event-parse.h> 23 22 #include "asm/bug.h" 24 23 #include "data-convert.h" 25 24 #include "session.h" ··· 34 35 #include "util.h" 35 36 #include "clockid.h" 36 37 #include "util/sample.h" 38 + 39 + #ifdef HAVE_LIBTRACEEVENT 40 + #include <traceevent/event-parse.h> 41 + #endif 37 42 38 43 #define pr_N(n, fmt, ...) \ 39 44 eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__)
+8 -1
tools/perf/util/data-convert-json.c
··· 27 27 #include "util/thread.h" 28 28 #include "util/tool.h" 29 29 30 + #ifdef HAVE_LIBTRACEEVENT 31 + #include <traceevent/event-parse.h> 32 + #endif 33 + 30 34 struct convert_json { 31 35 struct perf_tool tool; 32 36 FILE *out; ··· 221 217 } 222 218 output_json_format(out, false, 3, "]"); 223 219 220 + #ifdef HAVE_LIBTRACEEVENT 224 221 if (sample->raw_data) { 225 222 int i; 226 223 struct tep_format_field **fields; ··· 241 236 free(fields); 242 237 } 243 238 } 244 - 239 + #endif 245 240 output_json_format(out, false, 2, "}"); 246 241 return 0; 247 242 } ··· 318 313 .exit = perf_event__process_exit, 319 314 .fork = perf_event__process_fork, 320 315 .lost = perf_event__process_lost, 316 + #ifdef HAVE_LIBTRACEEVENT 321 317 .tracing_data = perf_event__process_tracing_data, 318 + #endif 322 319 .build_id = perf_event__process_build_id, 323 320 .id_index = perf_event__process_id_index, 324 321 .auxtrace_info = perf_event__process_auxtrace_info,
+5 -1
tools/perf/util/evlist.c
··· 290 290 return evsel; 291 291 } 292 292 293 + #ifdef HAVE_LIBTRACEEVENT 293 294 struct evsel *evlist__add_sched_switch(struct evlist *evlist, bool system_wide) 294 295 { 295 296 struct evsel *evsel = evsel__newtp_idx("sched", "sched_switch", 0); ··· 306 305 307 306 evlist__add(evlist, evsel); 308 307 return evsel; 309 - }; 308 + } 309 + #endif 310 310 311 311 int evlist__add_attrs(struct evlist *evlist, struct perf_event_attr *attrs, size_t nr_attrs) 312 312 { ··· 378 376 return NULL; 379 377 } 380 378 379 + #ifdef HAVE_LIBTRACEEVENT 381 380 int evlist__add_newtp(struct evlist *evlist, const char *sys, const char *name, void *handler) 382 381 { 383 382 struct evsel *evsel = evsel__newtp(sys, name); ··· 390 387 evlist__add(evlist, evsel); 391 388 return 0; 392 389 } 390 + #endif 393 391 394 392 struct evlist_cpu_iterator evlist__cpu_begin(struct evlist *evlist, struct affinity *affinity) 395 393 {
+4
tools/perf/util/evlist.h
··· 127 127 { 128 128 return evlist__add_aux_dummy(evlist, true); 129 129 } 130 + #ifdef HAVE_LIBTRACEEVENT 130 131 struct evsel *evlist__add_sched_switch(struct evlist *evlist, bool system_wide); 132 + #endif 131 133 132 134 int evlist__add_sb_event(struct evlist *evlist, struct perf_event_attr *attr, 133 135 evsel__sb_cb_t cb, void *data); ··· 137 135 int evlist__start_sb_thread(struct evlist *evlist, struct target *target); 138 136 void evlist__stop_sb_thread(struct evlist *evlist); 139 137 138 + #ifdef HAVE_LIBTRACEEVENT 140 139 int evlist__add_newtp(struct evlist *evlist, const char *sys, const char *name, void *handler); 140 + #endif 141 141 142 142 int __evlist__set_tracepoints_handlers(struct evlist *evlist, 143 143 const struct evsel_str_handler *assocs,
+10 -1
tools/perf/util/evsel.c
··· 12 12 #include <linux/bitops.h> 13 13 #include <api/fs/fs.h> 14 14 #include <api/fs/tracing_path.h> 15 - #include <traceevent/event-parse.h> 16 15 #include <linux/hw_breakpoint.h> 17 16 #include <linux/perf_event.h> 18 17 #include <linux/compiler.h> ··· 55 56 #include <internal/threadmap.h> 56 57 57 58 #include <linux/ctype.h> 59 + 60 + #ifdef HAVE_LIBTRACEEVENT 61 + #include <traceevent/event-parse.h> 62 + #endif 58 63 59 64 struct perf_missing_features perf_missing_features; 60 65 ··· 442 439 goto out_err; 443 440 } 444 441 evsel->cgrp = cgroup__get(orig->cgrp); 442 + #ifdef HAVE_LIBTRACEEVENT 445 443 evsel->tp_format = orig->tp_format; 444 + #endif 446 445 evsel->handler = orig->handler; 447 446 evsel->core.leader = orig->core.leader; 448 447 ··· 484 479 /* 485 480 * Returns pointer with encoded error via <linux/err.h> interface. 486 481 */ 482 + #ifdef HAVE_LIBTRACEEVENT 487 483 struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx) 488 484 { 489 485 struct evsel *evsel = zalloc(perf_evsel__object.size); ··· 522 516 out_err: 523 517 return ERR_PTR(err); 524 518 } 519 + #endif 525 520 526 521 const char *const evsel__hw_names[PERF_COUNT_HW_MAX] = { 527 522 "cycles", ··· 2765 2758 return size; 2766 2759 } 2767 2760 2761 + #ifdef HAVE_LIBTRACEEVENT 2768 2762 struct tep_format_field *evsel__field(struct evsel *evsel, const char *name) 2769 2763 { 2770 2764 return tep_find_field(evsel->tp_format, name); ··· 2839 2831 2840 2832 return field ? format_field__intval(field, sample, evsel->needs_swap) : 0; 2841 2833 } 2834 + #endif 2842 2835 2843 2836 bool evsel__fallback(struct evsel *evsel, int err, char *msg, size_t msgsize) 2844 2837 {
+11 -1
tools/perf/util/evsel.h
··· 72 72 char *name; 73 73 char *group_name; 74 74 const char *pmu_name; 75 + #ifdef HAVE_LIBTRACEEVENT 75 76 struct tep_event *tp_format; 77 + #endif 76 78 char *filter; 77 79 unsigned long max_events; 78 80 double scale; ··· 225 223 } 226 224 227 225 struct evsel *evsel__clone(struct evsel *orig); 228 - struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx); 229 226 230 227 int copy_config_terms(struct list_head *dst, struct list_head *src); 231 228 void free_config_terms(struct list_head *config_terms); 229 + 230 + 231 + #ifdef HAVE_LIBTRACEEVENT 232 + struct evsel *evsel__newtp_idx(const char *sys, const char *name, int idx); 232 233 233 234 /* 234 235 * Returns pointer with encoded error via <linux/err.h> interface. ··· 240 235 { 241 236 return evsel__newtp_idx(sys, name, 0); 242 237 } 238 + #endif 243 239 244 240 struct evsel *evsel__new_cycles(bool precise, __u32 type, __u64 config); 245 241 242 + #ifdef HAVE_LIBTRACEEVENT 246 243 struct tep_event *event_format__new(const char *sys, const char *name); 244 + #endif 247 245 248 246 void evsel__init(struct evsel *evsel, struct perf_event_attr *attr, int idx); 249 247 void evsel__exit(struct evsel *evsel); ··· 331 323 332 324 struct perf_sample; 333 325 326 + #ifdef HAVE_LIBTRACEEVENT 334 327 void *evsel__rawptr(struct evsel *evsel, struct perf_sample *sample, const char *name); 335 328 u64 evsel__intval(struct evsel *evsel, struct perf_sample *sample, const char *name); 336 329 ··· 339 330 { 340 331 return evsel__rawptr(evsel, sample, name); 341 332 } 333 + #endif 342 334 343 335 struct tep_format_field; 344 336
+6 -1
tools/perf/util/evsel_fprintf.c
··· 2 2 #include <inttypes.h> 3 3 #include <stdio.h> 4 4 #include <stdbool.h> 5 - #include <traceevent/event-parse.h> 6 5 #include "evsel.h" 7 6 #include "util/evsel_fprintf.h" 8 7 #include "util/event.h" ··· 11 12 #include "symbol.h" 12 13 #include "srcline.h" 13 14 #include "dso.h" 15 + 16 + #ifdef HAVE_LIBTRACEEVENT 17 + #include <traceevent/event-parse.h> 18 + #endif 14 19 15 20 static int comma_fprintf(FILE *fp, bool *first, const char *fmt, ...) 16 21 { ··· 77 74 term, (u64)evsel->core.attr.sample_freq); 78 75 } 79 76 77 + #ifdef HAVE_LIBTRACEEVENT 80 78 if (details->trace_fields) { 81 79 struct tep_format_field *field; 82 80 ··· 100 96 field = field->next; 101 97 } 102 98 } 99 + #endif 103 100 out: 104 101 fputc('\n', fp); 105 102 return ++printed;
+19
tools/perf/util/header.c
··· 6 6 #include <sys/types.h> 7 7 #include <byteswap.h> 8 8 #include <unistd.h> 9 + #include <regex.h> 9 10 #include <stdio.h> 10 11 #include <stdlib.h> 11 12 #include <linux/compiler.h> ··· 55 54 56 55 #include <linux/ctype.h> 57 56 #include <internal/lib.h> 57 + 58 + #ifdef HAVE_LIBTRACEEVENT 59 + #include <traceevent/event-parse.h> 60 + #endif 58 61 59 62 /* 60 63 * magic2 = "PERFILE2" ··· 303 298 return 0; 304 299 } 305 300 301 + #ifdef HAVE_LIBTRACEEVENT 306 302 static int write_tracing_data(struct feat_fd *ff, 307 303 struct evlist *evlist) 308 304 { ··· 312 306 313 307 return read_tracing_data(ff->fd, &evlist->core.entries); 314 308 } 309 + #endif 315 310 316 311 static int write_build_id(struct feat_fd *ff, 317 312 struct evlist *evlist __maybe_unused) ··· 2401 2394 FEAT_PROCESS_STR_FUN(cpudesc, cpu_desc); 2402 2395 FEAT_PROCESS_STR_FUN(cpuid, cpuid); 2403 2396 2397 + #ifdef HAVE_LIBTRACEEVENT 2404 2398 static int process_tracing_data(struct feat_fd *ff, void *data) 2405 2399 { 2406 2400 ssize_t ret = trace_report(ff->fd, data, false); 2407 2401 2408 2402 return ret < 0 ? -1 : 0; 2409 2403 } 2404 + #endif 2410 2405 2411 2406 static int process_build_id(struct feat_fd *ff, void *data __maybe_unused) 2412 2407 { ··· 3375 3366 const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE]; 3376 3367 3377 3368 const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE] = { 3369 + #ifdef HAVE_LIBTRACEEVENT 3378 3370 FEAT_OPN(TRACING_DATA, tracing_data, false), 3371 + #endif 3379 3372 FEAT_OPN(BUILD_ID, build_id, false), 3380 3373 FEAT_OPR(HOSTNAME, hostname, false), 3381 3374 FEAT_OPR(OSRELEASE, osrelease, false), ··· 4093 4082 return ret <= 0 ? -1 : 0; 4094 4083 } 4095 4084 4085 + #ifdef HAVE_LIBTRACEEVENT 4096 4086 static int evsel__prepare_tracepoint_event(struct evsel *evsel, struct tep_handle *pevent) 4097 4087 { 4098 4088 struct tep_event *event; ··· 4137 4125 4138 4126 return 0; 4139 4127 } 4128 + #endif 4140 4129 4141 4130 int perf_session__read_header(struct perf_session *session, int repipe_fd) 4142 4131 { ··· 4243 4230 lseek(fd, tmp, SEEK_SET); 4244 4231 } 4245 4232 4233 + #ifdef HAVE_LIBTRACEEVENT 4246 4234 perf_header__process_sections(header, fd, &session->tevent, 4247 4235 perf_file_section__process); 4248 4236 4249 4237 if (evlist__prepare_tracepoint_events(session->evlist, session->tevent.pevent)) 4250 4238 goto out_delete_evlist; 4239 + #else 4240 + perf_header__process_sections(header, fd, NULL, perf_file_section__process); 4241 + #endif 4251 4242 4252 4243 return 0; 4253 4244 out_errno: ··· 4429 4412 return 0; 4430 4413 } 4431 4414 4415 + #ifdef HAVE_LIBTRACEEVENT 4432 4416 int perf_event__process_tracing_data(struct perf_session *session, 4433 4417 union perf_event *event) 4434 4418 { ··· 4477 4459 4478 4460 return size_read + padding; 4479 4461 } 4462 + #endif 4480 4463 4481 4464 int perf_event__process_build_id(struct perf_session *session, 4482 4465 union perf_event *event)
+2
tools/perf/util/header.h
··· 160 160 union perf_event *event, 161 161 struct evlist **pevlist); 162 162 size_t perf_event__fprintf_event_update(union perf_event *event, FILE *fp); 163 + #ifdef HAVE_LIBTRACEEVENT 163 164 int perf_event__process_tracing_data(struct perf_session *session, 164 165 union perf_event *event); 166 + #endif 165 167 int perf_event__process_build_id(struct perf_session *session, 166 168 union perf_event *event); 167 169 bool is_perf_magic(u64 magic);
+6 -1
tools/perf/util/intel-pt.c
··· 3142 3142 return 1; 3143 3143 } 3144 3144 3145 + #ifdef HAVE_LIBTRACEEVENT 3145 3146 static int intel_pt_process_switch(struct intel_pt *pt, 3146 3147 struct perf_sample *sample) 3147 3148 { ··· 3166 3165 3167 3166 return machine__set_current_tid(pt->machine, cpu, -1, tid); 3168 3167 } 3168 + #endif /* HAVE_LIBTRACEEVENT */ 3169 3169 3170 3170 static int intel_pt_context_switch_in(struct intel_pt *pt, 3171 3171 struct perf_sample *sample) ··· 3435 3433 return err; 3436 3434 } 3437 3435 3436 + #ifdef HAVE_LIBTRACEEVENT 3438 3437 if (pt->switch_evsel && event->header.type == PERF_RECORD_SAMPLE) 3439 3438 err = intel_pt_process_switch(pt, sample); 3440 - else if (event->header.type == PERF_RECORD_ITRACE_START) 3439 + else 3440 + #endif 3441 + if (event->header.type == PERF_RECORD_ITRACE_START) 3441 3442 err = intel_pt_process_itrace_start(pt, event, sample); 3442 3443 else if (event->header.type == PERF_RECORD_AUX_OUTPUT_HW_ID) 3443 3444 err = intel_pt_process_aux_output_hw_id(pt, event, sample);
+15
tools/perf/util/parse-events.c
··· 445 445 return ret; 446 446 } 447 447 448 + #ifdef HAVE_LIBTRACEEVENT 448 449 static void tracepoint_error(struct parse_events_error *e, int err, 449 450 const char *sys, const char *name) 450 451 { ··· 594 593 closedir(events_dir); 595 594 return ret; 596 595 } 596 + #endif /* HAVE_LIBTRACEEVENT */ 597 597 598 598 #ifdef HAVE_LIBBPF_SUPPORT 599 599 struct __add_bpf_event_param { ··· 1145 1143 return config_term_common(attr, term, err); 1146 1144 } 1147 1145 1146 + #ifdef HAVE_LIBTRACEEVENT 1148 1147 static int config_term_tracepoint(struct perf_event_attr *attr, 1149 1148 struct parse_events_term *term, 1150 1149 struct parse_events_error *err) ··· 1173 1170 1174 1171 return 0; 1175 1172 } 1173 + #endif 1176 1174 1177 1175 static int config_attr(struct perf_event_attr *attr, 1178 1176 struct list_head *head, ··· 1329 1325 struct parse_events_error *err, 1330 1326 struct list_head *head_config) 1331 1327 { 1328 + #ifdef HAVE_LIBTRACEEVENT 1332 1329 if (head_config) { 1333 1330 struct perf_event_attr attr; 1334 1331 ··· 1344 1339 else 1345 1340 return add_tracepoint_event(list, idx, sys, event, 1346 1341 err, head_config); 1342 + #else 1343 + (void)list; 1344 + (void)idx; 1345 + (void)sys; 1346 + (void)event; 1347 + (void)head_config; 1348 + parse_events_error__handle(err, 0, strdup("unsupported tracepoint"), 1349 + strdup("libtraceevent is necessary for tracepoint support")); 1350 + return -1; 1351 + #endif 1347 1352 } 1348 1353 1349 1354 int parse_events_add_numeric(struct parse_events_state *parse_state,
-1
tools/perf/util/parse-events.h
··· 18 18 struct option; 19 19 struct perf_pmu; 20 20 21 - bool have_tracepoints(struct list_head *evlist); 22 21 bool is_event_supported(u8 type, u64 config); 23 22 24 23 const char *event_type(int type);
+10
tools/perf/util/python.c
··· 5 5 #include <poll.h> 6 6 #include <linux/err.h> 7 7 #include <perf/cpumap.h> 8 + #ifdef HAVE_LIBTRACEEVENT 8 9 #include <traceevent/event-parse.h> 10 + #endif 9 11 #include <perf/mmap.h> 10 12 #include "evlist.h" 11 13 #include "callchain.h" ··· 419 417 return ret; 420 418 } 421 419 420 + #ifdef HAVE_LIBTRACEEVENT 422 421 static bool is_tracepoint(struct pyrf_event *pevent) 423 422 { 424 423 return pevent->evsel->core.attr.type == PERF_TYPE_TRACEPOINT; ··· 489 486 490 487 return tracepoint_field(pevent, field); 491 488 } 489 + #endif /* HAVE_LIBTRACEEVENT */ 492 490 493 491 static PyObject* 494 492 pyrf_sample_event__getattro(struct pyrf_event *pevent, PyObject *attr_name) 495 493 { 496 494 PyObject *obj = NULL; 497 495 496 + #ifdef HAVE_LIBTRACEEVENT 498 497 if (is_tracepoint(pevent)) 499 498 obj = get_tracepoint_field(pevent, attr_name); 499 + #endif 500 500 501 501 return obj ?: PyObject_GenericGetAttr((PyObject *) pevent, attr_name); 502 502 } ··· 1332 1326 static PyObject *pyrf__tracepoint(struct pyrf_evsel *pevsel, 1333 1327 PyObject *args, PyObject *kwargs) 1334 1328 { 1329 + #ifndef HAVE_LIBTRACEEVENT 1330 + return NULL; 1331 + #else 1335 1332 struct tep_event *tp_format; 1336 1333 static char *kwlist[] = { "sys", "name", NULL }; 1337 1334 char *sys = NULL; ··· 1349 1340 return _PyLong_FromLong(-1); 1350 1341 1351 1342 return _PyLong_FromLong(tp_format->id); 1343 + #endif // HAVE_LIBTRACEEVENT 1352 1344 } 1353 1345 1354 1346 static PyMethodDef perf__methods[] = {
+4 -2
tools/perf/util/scripting-engines/Build
··· 1 - perf-$(CONFIG_LIBPERL) += trace-event-perl.o 2 - perf-$(CONFIG_LIBPYTHON) += trace-event-python.o 1 + ifeq ($(CONFIG_LIBTRACEEVENT),y) 2 + perf-$(CONFIG_LIBPERL) += trace-event-perl.o 3 + perf-$(CONFIG_LIBPYTHON) += trace-event-python.o 4 + endif 3 5 4 6 CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum 5 7
+1
tools/perf/util/scripting-engines/trace-event-perl.c
··· 27 27 #include <errno.h> 28 28 #include <linux/bitmap.h> 29 29 #include <linux/time64.h> 30 + #include <traceevent/event-parse.h> 30 31 31 32 #include <stdbool.h> 32 33 /* perl needs the following define, right after including stdbool.h */
+1
tools/perf/util/scripting-engines/trace-event-python.c
··· 30 30 #include <linux/bitmap.h> 31 31 #include <linux/compiler.h> 32 32 #include <linux/time64.h> 33 + #include <traceevent/event-parse.h> 33 34 34 35 #include "../build-id.h" 35 36 #include "../counts.h"
+2
tools/perf/util/session.c
··· 314 314 evlist__delete(session->evlist); 315 315 perf_data__close(session->data); 316 316 } 317 + #ifdef HAVE_LIBTRACEEVENT 317 318 trace_event__cleanup(&session->tevent); 319 + #endif 318 320 free(session); 319 321 } 320 322
+2
tools/perf/util/session.h
··· 33 33 struct auxtrace *auxtrace; 34 34 struct itrace_synth_opts *itrace_synth_opts; 35 35 struct list_head auxtrace_index; 36 + #ifdef HAVE_LIBTRACEEVENT 36 37 struct trace_event tevent; 38 + #endif 37 39 struct perf_record_time_conv time_conv; 38 40 bool repipe; 39 41 bool one_mmap;
+8 -2
tools/perf/util/setup.py
··· 63 63 ext_sources = [f.strip() for f in open('util/python-ext-sources') 64 64 if len(f.strip()) > 0 and f[0] != '#'] 65 65 66 + extra_libraries = [] 67 + 68 + if '-DHAVE_LIBTRACEEVENT' in cflags: 69 + extra_libraries += [ 'traceevent' ] 70 + else: 71 + ext_sources.remove('util/trace-event.c') 72 + 66 73 # use full paths with source files 67 74 ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources)) 68 75 69 - extra_libraries = [] 70 76 if '-DHAVE_LIBNUMA_SUPPORT' in cflags: 71 - extra_libraries = [ 'numa' ] 77 + extra_libraries += [ 'numa' ] 72 78 if '-DHAVE_LIBCAP_SUPPORT' in cflags: 73 79 extra_libraries += [ 'cap' ] 74 80
+50 -10
tools/perf/util/sort.c
··· 22 22 #include "srcline.h" 23 23 #include "strlist.h" 24 24 #include "strbuf.h" 25 - #include <traceevent/event-parse.h> 26 25 #include "mem-events.h" 27 26 #include "annotate.h" 28 27 #include "event.h" ··· 30 31 #include "machine.h" 31 32 #include <linux/kernel.h> 32 33 #include <linux/string.h> 34 + 35 + #ifdef HAVE_LIBTRACEEVENT 36 + #include <traceevent/event-parse.h> 37 + #endif 33 38 34 39 regex_t parent_regex; 35 40 const char default_parent_pattern[] = "^sys_|^do_page_fault"; ··· 746 743 747 744 /* --sort trace */ 748 745 746 + #ifdef HAVE_LIBTRACEEVENT 749 747 static char *get_trace_output(struct hist_entry *he) 750 748 { 751 749 struct trace_seq seq; ··· 810 806 .se_snprintf = hist_entry__trace_snprintf, 811 807 .se_width_idx = HISTC_TRACE, 812 808 }; 809 + #endif /* HAVE_LIBTRACEEVENT */ 813 810 814 811 /* sort keys for branch stacks */ 815 812 ··· 2027 2022 DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight), 2028 2023 DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight), 2029 2024 DIM(SORT_TRANSACTION, "transaction", sort_transaction), 2025 + #ifdef HAVE_LIBTRACEEVENT 2030 2026 DIM(SORT_TRACE, "trace", sort_trace), 2027 + #endif 2031 2028 DIM(SORT_SYM_SIZE, "symbol_size", sort_sym_size), 2032 2029 DIM(SORT_DSO_SIZE, "dso_size", sort_dso_size), 2033 2030 DIM(SORT_CGROUP, "cgroup", sort_cgroup), ··· 2213 2206 return hse->se == &sort_ ## key ; \ 2214 2207 } 2215 2208 2209 + #ifdef HAVE_LIBTRACEEVENT 2216 2210 MK_SORT_ENTRY_CHK(trace) 2211 + #else 2212 + bool perf_hpp__is_trace_entry(struct perf_hpp_fmt *fmt __maybe_unused) 2213 + { 2214 + return false; 2215 + } 2216 + #endif 2217 2217 MK_SORT_ENTRY_CHK(srcline) 2218 2218 MK_SORT_ENTRY_CHK(srcfile) 2219 2219 MK_SORT_ENTRY_CHK(thread) ··· 2361 2347 return 0; 2362 2348 } 2363 2349 2350 + #ifndef HAVE_LIBTRACEEVENT 2351 + bool perf_hpp__is_dynamic_entry(struct perf_hpp_fmt *fmt __maybe_unused) 2352 + { 2353 + return false; 2354 + } 2355 + bool perf_hpp__defined_dynamic_entry(struct perf_hpp_fmt *fmt __maybe_unused, 2356 + struct hists *hists __maybe_unused) 2357 + { 2358 + return false; 2359 + } 2360 + #else 2364 2361 struct hpp_dynamic_entry { 2365 2362 struct perf_hpp_fmt hpp; 2366 2363 struct evsel *evsel; ··· 2646 2621 2647 2622 return hde; 2648 2623 } 2624 + #endif /* HAVE_LIBTRACEEVENT */ 2649 2625 2650 2626 struct perf_hpp_fmt *perf_hpp_fmt__dup(struct perf_hpp_fmt *fmt) 2651 2627 { ··· 2659 2633 new_hse = memdup(hse, sizeof(*hse)); 2660 2634 if (new_hse) 2661 2635 new_fmt = &new_hse->hpp; 2636 + #ifdef HAVE_LIBTRACEEVENT 2662 2637 } else if (perf_hpp__is_dynamic_entry(fmt)) { 2663 2638 struct hpp_dynamic_entry *hde, *new_hde; 2664 2639 ··· 2667 2640 new_hde = memdup(hde, sizeof(*hde)); 2668 2641 if (new_hde) 2669 2642 new_fmt = &new_hde->hpp; 2643 + #endif 2670 2644 } else { 2671 2645 new_fmt = memdup(fmt, sizeof(*fmt)); 2672 2646 } ··· 2747 2719 return evsel; 2748 2720 } 2749 2721 2722 + #ifdef HAVE_LIBTRACEEVENT 2750 2723 static int __dynamic_dimension__add(struct evsel *evsel, 2751 2724 struct tep_format_field *field, 2752 2725 bool raw_trace, int level) ··· 2818 2789 } 2819 2790 return ret; 2820 2791 } 2792 + #endif /* HAVE_LIBTRACEEVENT */ 2821 2793 2822 2794 static int add_dynamic_entry(struct evlist *evlist, const char *tok, 2823 2795 int level) 2824 2796 { 2825 2797 char *str, *event_name, *field_name, *opt_name; 2826 2798 struct evsel *evsel; 2827 - struct tep_format_field *field; 2828 2799 bool raw_trace = symbol_conf.raw_trace; 2829 2800 int ret = 0; 2830 2801 ··· 2849 2820 raw_trace = true; 2850 2821 } 2851 2822 2823 + #ifdef HAVE_LIBTRACEEVENT 2852 2824 if (!strcmp(field_name, "trace_fields")) { 2853 2825 ret = add_all_dynamic_fields(evlist, raw_trace, level); 2854 2826 goto out; ··· 2859 2829 ret = add_all_matching_fields(evlist, field_name, raw_trace, level); 2860 2830 goto out; 2861 2831 } 2832 + #endif 2862 2833 2863 2834 evsel = find_evsel(evlist, event_name); 2864 2835 if (evsel == NULL) { ··· 2874 2843 goto out; 2875 2844 } 2876 2845 2846 + #ifdef HAVE_LIBTRACEEVENT 2877 2847 if (!strcmp(field_name, "*")) { 2878 2848 ret = add_evsel_fields(evsel, raw_trace, level); 2879 2849 } else { 2880 - field = tep_find_any_field(evsel->tp_format, field_name); 2850 + struct tep_format_field *field = tep_find_any_field(evsel->tp_format, field_name); 2851 + 2881 2852 if (field == NULL) { 2882 2853 pr_debug("Cannot find event field for %s.%s\n", 2883 2854 event_name, field_name); ··· 2888 2855 2889 2856 ret = __dynamic_dimension__add(evsel, field, raw_trace, level); 2890 2857 } 2858 + #else 2859 + (void)level; 2860 + (void)raw_trace; 2861 + #endif /* HAVE_LIBTRACEEVENT */ 2891 2862 2892 2863 out: 2893 2864 free(str); ··· 2992 2955 for (i = 0; i < ARRAY_SIZE(common_sort_dimensions); i++) { 2993 2956 struct sort_dimension *sd = &common_sort_dimensions[i]; 2994 2957 2995 - if (strncasecmp(tok, sd->name, strlen(tok))) 2958 + if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) 2996 2959 continue; 2997 2960 2998 2961 for (j = 0; j < ARRAY_SIZE(dynamic_headers); j++) { 2999 - if (!strcmp(dynamic_headers[j], sd->name)) 2962 + if (sd->name && !strcmp(dynamic_headers[j], sd->name)) 3000 2963 sort_dimension_add_dynamic_header(sd); 3001 2964 } 3002 2965 ··· 3046 3009 for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) { 3047 3010 struct sort_dimension *sd = &bstack_sort_dimensions[i]; 3048 3011 3049 - if (strncasecmp(tok, sd->name, strlen(tok))) 3012 + if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) 3050 3013 continue; 3051 3014 3052 3015 if (sort__mode != SORT_MODE__BRANCH) ··· 3062 3025 for (i = 0; i < ARRAY_SIZE(memory_sort_dimensions); i++) { 3063 3026 struct sort_dimension *sd = &memory_sort_dimensions[i]; 3064 3027 3065 - if (strncasecmp(tok, sd->name, strlen(tok))) 3028 + if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) 3066 3029 continue; 3067 3030 3068 3031 if (sort__mode != SORT_MODE__MEMORY) ··· 3376 3339 for (i = 0; i < ARRAY_SIZE(common_sort_dimensions); i++) { 3377 3340 struct sort_dimension *sd = &common_sort_dimensions[i]; 3378 3341 3379 - if (strncasecmp(tok, sd->name, strlen(tok))) 3342 + if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) 3380 3343 continue; 3381 3344 3382 3345 return __sort_dimension__add_output(list, sd); ··· 3394 3357 for (i = 0; i < ARRAY_SIZE(bstack_sort_dimensions); i++) { 3395 3358 struct sort_dimension *sd = &bstack_sort_dimensions[i]; 3396 3359 3397 - if (strncasecmp(tok, sd->name, strlen(tok))) 3360 + if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) 3398 3361 continue; 3399 3362 3400 3363 if (sort__mode != SORT_MODE__BRANCH) ··· 3406 3369 for (i = 0; i < ARRAY_SIZE(memory_sort_dimensions); i++) { 3407 3370 struct sort_dimension *sd = &memory_sort_dimensions[i]; 3408 3371 3409 - if (strncasecmp(tok, sd->name, strlen(tok))) 3372 + if (!sd->name || strncasecmp(tok, sd->name, strlen(tok))) 3410 3373 continue; 3411 3374 3412 3375 if (sort__mode != SORT_MODE__MEMORY) ··· 3545 3508 3546 3509 static void add_key(struct strbuf *sb, const char *str, int *llen) 3547 3510 { 3511 + if (!str) 3512 + return; 3513 + 3548 3514 if (*llen >= 75) { 3549 3515 strbuf_addstr(sb, "\n\t\t\t "); 3550 3516 *llen = INDENT;
+6
tools/perf/util/synthetic-events.c
··· 2157 2157 return err; 2158 2158 } 2159 2159 2160 + #ifdef HAVE_LIBTRACEEVENT 2160 2161 int perf_event__synthesize_tracing_data(struct perf_tool *tool, int fd, struct evlist *evlist, 2161 2162 perf_event__handler_t process) 2162 2163 { ··· 2204 2203 2205 2204 return aligned_size; 2206 2205 } 2206 + #endif 2207 2207 2208 2208 int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, 2209 2209 perf_event__handler_t process, struct machine *machine) ··· 2357 2355 } 2358 2356 ret += err; 2359 2357 2358 + #ifdef HAVE_LIBTRACEEVENT 2360 2359 if (have_tracepoints(&evlist->core.entries)) { 2361 2360 int fd = perf_data__fd(data); 2362 2361 ··· 2377 2374 } 2378 2375 ret += err; 2379 2376 } 2377 + #else 2378 + (void)data; 2379 + #endif 2380 2380 2381 2381 return ret; 2382 2382 }
+2
tools/perf/util/trace-event-parse.c
··· 11 11 #include "trace-event.h" 12 12 13 13 #include <linux/ctype.h> 14 + #include <linux/kernel.h> 15 + #include <traceevent/event-parse.h> 14 16 15 17 static int get_common_field(struct scripting_context *context, 16 18 int *offset, int *size, const char *type)
+1
tools/perf/util/trace-event-read.c
··· 11 11 #include <sys/stat.h> 12 12 #include <sys/wait.h> 13 13 #include <sys/mman.h> 14 + #include <traceevent/event-parse.h> 14 15 #include <fcntl.h> 15 16 #include <unistd.h> 16 17 #include <errno.h>
+1
tools/perf/util/trace-event-scripting.c
··· 9 9 #include <stdlib.h> 10 10 #include <string.h> 11 11 #include <errno.h> 12 + #include <traceevent/event-parse.h> 12 13 13 14 #include "debug.h" 14 15 #include "trace-event.h"
-1
tools/perf/util/trace-event.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - 3 2 #include <stdio.h> 4 3 #include <unistd.h> 5 4 #include <stdlib.h>
+9 -2
tools/perf/util/trace-event.h
··· 2 2 #ifndef _PERF_UTIL_TRACE_EVENT_H 3 3 #define _PERF_UTIL_TRACE_EVENT_H 4 4 5 - #include <traceevent/event-parse.h> 6 - #include "parse-events.h" 5 + #include <stdbool.h> 6 + #include <stdio.h> 7 + #include <linux/types.h> 7 8 9 + struct evlist; 8 10 struct machine; 9 11 struct perf_sample; 10 12 union perf_event; ··· 19 17 struct tep_handle *pevent; 20 18 struct tep_plugin_list *plugin_list; 21 19 }; 20 + 21 + typedef char *(tep_func_resolver_t)(void *priv, 22 + unsigned long long *addrp, char **modp); 23 + 24 + bool have_tracepoints(struct list_head *evlist); 22 25 23 26 int trace_event__init(struct trace_event *t); 24 27 void trace_event__cleanup(struct trace_event *t);