Fix perf tools/lib includes
Subsystems (2)
Ian Rogers
reviewerv2 cover Fix perf tools/lib includes
The previous build would add -Itools/lib and get dependencies for libtraceevent, libsubcmd, libsymbol, libapi and libbpf meaning that overriding these libraries would change the link time dependency but the headers would erroneously come from tools/lib. Fix the build to install headers and then depend on these. To reduce exposing internal headers/APIs some clean up is performed. tools/lib/symbol has a Makefile added, while tools/lib/api and tools/lib/subcmd have install targets added. The pattern used for the dependencies in Makefile.perf is modelled on libbpf.
The problem and solution were motivated by this issue and discussion:
https://lore.kernel.org/lkml/CAEf4BzbbOHQZUAe6iWaehKCPQAf3VC=hq657buqe2_yRKxaK-A@mail.gmail.com/
v2. Fix a MANIFEST issue for the source tar ball. Add dependencies for
the installed header files so that the build doesn't overtake building these dependencies. Both issues reported by Arnaldo Carvalho de Melo <[email protected]>.
Ian Rogers (14):
tools lib api: Add install target
tools lib subcmd: Add install target
perf build: Install libsubcmd locally when building perf build: Install libapi locally when building perf build: Install libperf locally when building perf build: Install libtraceevent locally when building tools lib api: Add missing install headers tools lib perf: Add missing install headers tool lib symbol: Add Makefile/Build
perf build: Install libsymbol locally when building perf expr: Tidy hashmap dependency
perf thread_map: Reduce exposure of libperf internal API perf cpumap: Tidy libperf includes
perf build: Use tools/lib headers from install path
tools/lib/api/Makefile | 52 +++++ tools/lib/perf/Makefile | 10 +- tools/lib/subcmd/Makefile | 49 +++++ tools/lib/symbol/Build | 1 + tools/lib/symbol/Makefile | 115 +++++++++++ tools/perf/.gitignore | 7 +- tools/perf/MANIFEST | 3 +- tools/perf/Makefile.config | 2 - tools/perf/Makefile.perf | 192 ++++++++++++++---- tools/perf/builtin-stat.c | 1 + tools/perf/builtin-trace.c | 4 +- tools/perf/tests/cpumap.c | 2 +- tools/perf/tests/expr.c | 1 + tools/perf/tests/openat-syscall.c | 1 + tools/perf/tests/pmu-events.c | 1 + tools/perf/tests/thread-map.c | 1 + tools/perf/util/Build | 5 - tools/perf/util/auxtrace.h | 2 +- tools/perf/util/bpf-loader.c | 4 - tools/perf/util/bpf_counter.c | 2 +- tools/perf/util/cpumap.c | 1 + tools/perf/util/cpumap.h | 2 +- tools/perf/util/evsel.c | 5 +- tools/perf/util/evsel.h | 2 - tools/perf/util/expr.c | 1 + tools/perf/util/expr.h | 7 +- tools/perf/util/metricgroup.c | 1 + tools/perf/util/python.c | 6 +- .../scripting-engines/trace-event-python.c | 2 +- tools/perf/util/stat-shadow.c | 1 + tools/perf/util/stat.c | 4 - tools/perf/util/thread_map.c | 1 + tools/perf/util/thread_map.h | 2 - 33 files changed, 402 insertions(+), 88 deletions(-) create mode 100644 tools/lib/symbol/Build create mode 100644 tools/lib/symbol/Makefile
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 1/14 tools lib api: Add install target
This allows libapi to be installed as a dependency.
--- tools/lib/api/Makefile | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
tools/lib/api/Makefile +49 -0
@@ -15,6 +15,16 @@ LD ?= $(CROSS_COMPILE)ld MAKEFLAGS += --no-print-directory +INSTALL = install + + +# Use DESTDIR for installing into a different root directory. +# This is useful for building a package. The program will be +# installed in this directory as if it was the root directory. +# Then the build tool can move it later. +DESTDIR ?= +DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' + LIBFILE = $(OUTPUT)libapi.a CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
@@ -45,10 +55,23 @@ RM = rm -f API_IN := $(OUTPUT)libapi-in.o +ifeq ($(LP64), 1) + libdir_relative = lib64 +else + libdir_relative = lib +endif + +prefix ?= +libdir = $(prefix)/$(libdir_relative) + +# Shell quotes +libdir_SQ = $(subst ','\'',$(libdir)) + all: export srctree OUTPUT CC LD CFLAGS V include $(srctree)/tools/build/Makefile.include +include $(srctree)/tools/scripts/Makefile.include all: fixdep $(LIBFILE)
@@ -58,6 +81,32 @@ $(API_IN): FORCE $(LIBFILE): $(API_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(API_IN) +define do_install_mkdir + if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ + fi +endef + +define do_install + if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ + fi; \ + $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' +endef + +install_lib: $(LIBFILE) + $(call QUIET_INSTALL, $(LIBFILE)) \ + $(call do_install_mkdir,$(libdir_SQ)); \ + cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ) + +install_headers: + $(call QUIET_INSTALL, headers) \ + $(call do_install,cpu.h,$(prefix)/include/api,644); \ + $(call do_install,debug.h,$(prefix)/include/api,644); \ + $(call do_install,io.h,$(prefix)/include/api,644); + +install: install_lib install_headers + clean: $(call QUIET_CLEAN, libapi) $(RM) $(LIBFILE); \ find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 2/14 tools lib subcmd: Add install target
In reply to Ian RogersThis allows libsubcmd to be installed as a dependency.
--- tools/lib/subcmd/Makefile | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
tools/lib/subcmd/Makefile +49 -0
@@ -17,6 +17,15 @@ RM = rm -f MAKEFLAGS += --no-print-directory +INSTALL = install + +# Use DESTDIR for installing into a different root directory. +# This is useful for building a package. The program will be +# installed in this directory as if it was the root directory. +# Then the build tool can move it later. +DESTDIR ?= +DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' + LIBFILE = $(OUTPUT)libsubcmd.a CFLAGS := -ggdb3 -Wall -Wextra -std=gnu99 -fPIC
@@ -48,6 +57,18 @@ CFLAGS += $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) SUBCMD_IN := $(OUTPUT)libsubcmd-in.o +ifeq ($(LP64), 1) + libdir_relative = lib64 +else + libdir_relative = lib +endif + +prefix ?= +libdir = $(prefix)/$(libdir_relative) + +# Shell quotes +libdir_SQ = $(subst ','\'',$(libdir)) + all: export srctree OUTPUT CC LD CFLAGS V
@@ -61,6 +82,34 @@ $(SUBCMD_IN): FORCE $(LIBFILE): $(SUBCMD_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(SUBCMD_IN) +define do_install_mkdir + if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ + fi +endef + +define do_install + if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ + fi; \ + $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' +endef + +install_lib: $(LIBFILE) + $(call QUIET_INSTALL, $(LIBFILE)) \ + $(call do_install_mkdir,$(libdir_SQ)); \ + cp -fpR $(LIBFILE) $(DESTDIR)$(libdir_SQ) + +install_headers: + $(call QUIET_INSTALL, headers) \ + $(call do_install,exec-cmd.h,$(prefix)/include/subcmd,644); \ + $(call do_install,help.h,$(prefix)/include/subcmd,644); \ + $(call do_install,pager.h,$(prefix)/include/subcmd,644); \ + $(call do_install,parse-options.h,$(prefix)/include/subcmd,644); \ + $(call do_install,run-command.h,$(prefix)/include/subcmd,644); + +install: install_lib install_headers + clean: $(call QUIET_CLEAN, libsubcmd) $(RM) $(LIBFILE); \ find $(or $(OUTPUT),.) -name \*.o -or -name \*.o.cmd -or -name \*.o.d | xargs $(RM)
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 3/14 perf build: Install libsubcmd locally when building
In reply to Ian RogersThe perf build currently has a '-Itools/lib' on the CC command line. This causes issues as the libapi, libsubcmd, libtraceevent, libbpf headers are all found via this path, making it impossible to override include behavior. Change the libsubcmd build mirroring the libbpf build, so that it is installed in a directory along with its headers. A later change will modify the include behavior.
--- tools/perf/.gitignore | 1 + tools/perf/Makefile.perf | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-)
tools/perf/.gitignore +1 -0
@@ -39,6 +39,7 @@ pmu-events/pmu-events.c pmu-events/jevents feature/ libbpf/ +libsubcmd/ fixdep libtraceevent-dynamic-list Documentation/doc.dep
tools/perf/Makefile.perf +16 -8
@@ -244,7 +244,7 @@ else # force_fixdep LIB_DIR = $(srctree)/tools/lib/api/ TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ LIBBPF_DIR = $(srctree)/tools/lib/bpf/ -SUBCMD_DIR = $(srctree)/tools/lib/subcmd/ +LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/ LIBPERF_DIR = $(srctree)/tools/lib/perf/ DOC_DIR = $(srctree)/tools/perf/Documentation/
@@ -294,7 +294,6 @@ strip-libs = $(filter-out -l%,$(1)) ifneq ($(OUTPUT),) TE_PATH=$(OUTPUT) PLUGINS_PATH=$(OUTPUT) - SUBCMD_PATH=$(OUTPUT) LIBPERF_PATH=$(OUTPUT) ifneq ($(subdir),) API_PATH=$(OUTPUT)/../lib/api/
@@ -305,7 +304,6 @@ else TE_PATH=$(TRACE_EVENT_DIR) PLUGINS_PATH=$(TRACE_EVENT_DIR)plugins/ API_PATH=$(LIB_DIR) - SUBCMD_PATH=$(SUBCMD_DIR) LIBPERF_PATH=$(LIBPERF_DIR) endif
@@ -332,7 +330,14 @@ LIBBPF_DESTDIR = $(LIBBPF_OUTPUT) LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a -LIBSUBCMD = $(SUBCMD_PATH)libsubcmd.a +ifneq ($(OUTPUT),) + LIBSUBCMD_OUTPUT = $(abspath $(OUTPUT))/libsubcmd +else + LIBSUBCMD_OUTPUT = $(CURDIR)/libsubcmd +endif +LIBSUBCMD_DESTDIR = $(LIBSUBCMD_OUTPUT) +LIBSUBCMD_INCLUDE = $(LIBSUBCMD_DESTDIR)/include +LIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.a LIBPERF = $(LIBPERF_PATH)libperf.a export LIBPERF
@@ -849,11 +854,14 @@ $(LIBPERF)-clean: $(call QUIET_CLEAN, libperf) $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) clean >/dev/null -$(LIBSUBCMD): FORCE - $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a +$(LIBSUBCMD): FORCE | $(LIBSUBCMD_OUTPUT) + $(Q)$(MAKE) -C $(LIBSUBCMD_DIR) O=$(LIBSUBCMD_OUTPUT) \ + DESTDIR=$(LIBSUBCMD_DESTDIR) prefix= \ + $@ install_headers $(LIBSUBCMD)-clean: - $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) clean + $(call QUIET_CLEAN, libsubcmd) + $(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT) help: @echo 'Perf make targets:'
@@ -1039,7 +1047,7 @@ SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h $(SKEL_OUT)/func_latency.skel.h SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h -$(SKEL_TMP_OUT) $(LIBBPF_OUTPUT): +$(SKEL_TMP_OUT) $(LIBBPF_OUTPUT) $(LIBSUBCMD_OUTPUT): $(Q)$(MKDIR) -p $@ ifdef BUILD_BPF_SKEL
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 4/14 perf build: Install libapi locally when building
In reply to Ian RogersThe perf build currently has a '-Itools/lib' on the CC command line. This causes issues as the libapi, libsubcmd, libtraceevent, libbpf headers are all found via this path, making it impossible to override include behavior. Change the libapi build mirroring the libbpf and libsubcmd build, so that it is installed in a directory along with its headers. A later change will modify the include behavior.
--- tools/perf/.gitignore | 1 + tools/perf/Makefile.perf | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-)
tools/perf/.gitignore +1 -0
@@ -38,6 +38,7 @@ trace/beauty/generated/ pmu-events/pmu-events.c pmu-events/jevents feature/ +libapi/ libbpf/ libsubcmd/ fixdep
tools/perf/Makefile.perf +15 -12
@@ -241,7 +241,7 @@ sub-make: fixdep else # force_fixdep -LIB_DIR = $(srctree)/tools/lib/api/ +LIBAPI_DIR = $(srctree)/tools/lib/api/ TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ LIBBPF_DIR = $(srctree)/tools/lib/bpf/ LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/
@@ -295,15 +295,9 @@ ifneq ($(OUTPUT),) TE_PATH=$(OUTPUT) PLUGINS_PATH=$(OUTPUT) LIBPERF_PATH=$(OUTPUT) -ifneq ($(subdir),) - API_PATH=$(OUTPUT)/../lib/api/ -else - API_PATH=$(OUTPUT) -endif else TE_PATH=$(TRACE_EVENT_DIR) PLUGINS_PATH=$(TRACE_EVENT_DIR)plugins/ - API_PATH=$(LIB_DIR) LIBPERF_PATH=$(LIBPERF_DIR) endif
@@ -318,7 +312,14 @@ LIBTRACEEVENT_DYNAMIC_LIST = $(PLUGINS_PATH)libtraceevent-dynamic-list DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST) LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS)) -LIBAPI = $(API_PATH)libapi.a +ifneq ($(OUTPUT),) + LIBAPI_OUTPUT = $(abspath $(OUTPUT))/libapi +else + LIBAPI_OUTPUT = $(CURDIR)/libapi +endif +LIBAPI_DESTDIR = $(LIBAPI_OUTPUT) +LIBAPI_INCLUDE = $(LIBAPI_DESTDIR)/include +LIBAPI = $(LIBAPI_OUTPUT)/libapi.a export LIBAPI ifneq ($(OUTPUT),)
@@ -831,12 +832,14 @@ $(LIBTRACEEVENT)-clean: install-traceevent-plugins: libtraceevent_plugins $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins -$(LIBAPI): FORCE - $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a +$(LIBAPI): FORCE | $(LIBAPI_OUTPUT) + $(Q)$(MAKE) -C $(LIBAPI_DIR) O=$(LIBAPI_OUTPUT) \ + DESTDIR=$(LIBAPI_DESTDIR) prefix= \ + $@ install_headers $(LIBAPI)-clean: $(call QUIET_CLEAN, libapi) - $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null + $(Q)$(RM) -r -- $(LIBAPI_OUTPUT) $(LIBBPF): FORCE | $(LIBBPF_OUTPUT) $(Q)$(MAKE) -C $(LIBBPF_DIR) FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) \
@@ -1047,7 +1050,7 @@ SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h $(SKEL_OUT)/func_latency.skel.h SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h -$(SKEL_TMP_OUT) $(LIBBPF_OUTPUT) $(LIBSUBCMD_OUTPUT): +$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBSUBCMD_OUTPUT): $(Q)$(MKDIR) -p $@ ifdef BUILD_BPF_SKEL
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 5/14 perf build: Install libperf locally when building
In reply to Ian RogersThe perf build currently has a '-Itools/lib' on the CC command line. This causes issues as the libapi, libsubcmd, libtraceevent, libbpf headers are all found via this path, making it impossible to override include behavior. Change the libperf build mirroring the libbpf, libsubcmd and libapi build, so that it is installed in a directory along with its headers. A later change will modify the include behavior.
--- tools/perf/.gitignore | 1 + tools/perf/Makefile.perf | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-)
tools/perf/.gitignore +1 -0
@@ -40,6 +40,7 @@ pmu-events/jevents feature/ libapi/ libbpf/ +libperf/ libsubcmd/ fixdep libtraceevent-dynamic-list
tools/perf/Makefile.perf +14 -7
@@ -294,11 +294,9 @@ strip-libs = $(filter-out -l%,$(1)) ifneq ($(OUTPUT),) TE_PATH=$(OUTPUT) PLUGINS_PATH=$(OUTPUT) - LIBPERF_PATH=$(OUTPUT) else TE_PATH=$(TRACE_EVENT_DIR) PLUGINS_PATH=$(TRACE_EVENT_DIR)plugins/ - LIBPERF_PATH=$(LIBPERF_DIR) endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
@@ -340,7 +338,14 @@ LIBSUBCMD_DESTDIR = $(LIBSUBCMD_OUTPUT) LIBSUBCMD_INCLUDE = $(LIBSUBCMD_DESTDIR)/include LIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.a -LIBPERF = $(LIBPERF_PATH)libperf.a +ifneq ($(OUTPUT),) + LIBPERF_OUTPUT = $(abspath $(OUTPUT))/libperf +else + LIBPERF_OUTPUT = $(CURDIR)/libperf +endif +LIBPERF_DESTDIR = $(LIBPERF_OUTPUT) +LIBPERF_INCLUDE = $(LIBPERF_DESTDIR)/include +LIBPERF = $(LIBPERF_OUTPUT)/libperf.a export LIBPERF # python extension build directories
@@ -850,12 +855,14 @@ $(LIBBPF)-clean: $(call QUIET_CLEAN, libbpf) $(Q)$(RM) -r -- $(LIBBPF_OUTPUT) -$(LIBPERF): FORCE - $(Q)$(MAKE) -C $(LIBPERF_DIR) EXTRA_CFLAGS="$(LIBPERF_CFLAGS)" O=$(OUTPUT) $(OUTPUT)libperf.a +$(LIBPERF): FORCE | $(LIBPERF_OUTPUT) + $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(LIBPERF_OUTPUT) \ + DESTDIR=$(LIBPERF_DESTDIR) prefix= \ + $@ install_headers $(LIBPERF)-clean: $(call QUIET_CLEAN, libperf) - $(Q)$(MAKE) -C $(LIBPERF_DIR) O=$(OUTPUT) clean >/dev/null + $(Q)$(RM) -r -- $(LIBPERF_OUTPUT) $(LIBSUBCMD): FORCE | $(LIBSUBCMD_OUTPUT) $(Q)$(MAKE) -C $(LIBSUBCMD_DIR) O=$(LIBSUBCMD_OUTPUT) \
@@ -1050,7 +1057,7 @@ SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h $(SKEL_OUT)/func_latency.skel.h SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h -$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBSUBCMD_OUTPUT): +$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT): $(Q)$(MKDIR) -p $@ ifdef BUILD_BPF_SKEL
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 6/14 perf build: Install libtraceevent locally when building
In reply to Ian RogersThe perf build currently has a '-Itools/lib' on the CC command line. This causes issues as the libapi, libsubcmd, libtraceevent, libbpf headers are all found via this path, making it impossible to override include behavior. Change the libtraceevent build mirroring the libbpf, libsubcmd, libapi and libperf build, so that it is installed in a directory along with its headers. A later change will modify the include behavior.
Similarly, the plugins are now installed into libtraceevent_plugins except they have no header files.
--- tools/perf/.gitignore | 3 ++- tools/perf/Makefile.perf | 57 ++++++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 20 deletions(-)
tools/perf/.gitignore +2 -1
@@ -42,6 +42,7 @@ libapi/ libbpf/ libperf/ libsubcmd/ +libtraceevent/ +libtraceevent_plugins/ fixdep -libtraceevent-dynamic-list Documentation/doc.dep
tools/perf/Makefile.perf +38 -19
95 lines not on this page · raw message
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 7/14 tools lib api: Add missing install headers
In reply to Ian RogersHeaders necessary for the perf build.
--- tools/lib/api/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/lib/api/Makefile +4 -1
@@ -103,7 +103,10 @@ install_headers: $(call QUIET_INSTALL, headers) \ $(call do_install,cpu.h,$(prefix)/include/api,644); \ $(call do_install,debug.h,$(prefix)/include/api,644); \ - $(call do_install,io.h,$(prefix)/include/api,644); + $(call do_install,io.h,$(prefix)/include/api,644); \ + $(call do_install,fd/array.h,$(prefix)/include/api/fd,644); \ + $(call do_install,fs/fs.h,$(prefix)/include/api/fs,644); + $(call do_install,fs/tracing_path.h,$(prefix)/include/api/fs,644); install: install_lib install_headers
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 8/14 tools lib perf: Add missing install headers
In reply to Ian RogersHeaders necessary for the perf build. Note, internal headers are also installed as these are necessary for the build.
--- tools/lib/perf/Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
tools/lib/perf/Makefile +9 -1
@@ -189,13 +189,21 @@ install_lib: libs install_headers: $(call QUIET_INSTALL, headers) \ + $(call do_install,include/perf/bpf_perf.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/core.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/event.h,$(prefix)/include/perf,644); \ - $(call do_install,include/perf/mmap.h,$(prefix)/include/perf,644); + $(call do_install,include/perf/mmap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/internal/cpumap.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/evlist.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/evsel.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/lib.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/mmap.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/threadmap.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/xyarray.h,$(prefix)/include/internal,644); install_pkgconfig: $(LIBPERF_PC) $(call QUIET_INSTALL, $(LIBPERF_PC)) \
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Namhyung Kim
maintainerRe: [PATCH v2 08/14] tools lib perf: Add missing install headers
Quoted 3 lines · Ian Rogers
Headers necessary for the perf build. Note, internal headers are also installed as these are necessary for the build.
Yeah, it's sad we are using those internal headers in perf. Ideally libperf provides callbacks to associate private data to each public data structure (e.g. evsel, evlist, etc). And external users just use public APIs only.
But that would be a major change.
Thanks,
Namhyung
Quoted 36 lines
Signed-off-by Ian Rogers <[email protected]>--- tools/lib/perf/Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)tools/lib/perf/Makefile +9
-2@@ -189,13 +189,21 @@ install_lib: libs install_headers: $(call QUIET_INSTALL, headers) \ + $(call do_install,include/perf/bpf_perf.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/core.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644); \ $(call do_install,include/perf/event.h,$(prefix)/include/perf,644); \ - $(call do_install,include/perf/mmap.h,$(prefix)/include/perf,644); + $(call do_install,include/perf/mmap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/internal/cpumap.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/evlist.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/evsel.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/lib.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/mmap.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/threadmap.h,$(prefix)/include/internal,644); \ + $(call do_install,include/internal/xyarray.h,$(prefix)/include/internal,644); install_pkgconfig: $(LIBPERF_PC) $(call QUIET_INSTALL, $(LIBPERF_PC)) \ --2.38.1.431.g37b22c650d-goog
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v2 08/14] tools lib perf: Add missing install headers
Em Wed, Nov 09, 2022 at 12:12:16PM -0800, Namhyung Kim escreveu:
Quoted 5 lines · Ian Rogers
Quoted 2 lines
Headers necessary for the perf build. Note, internal headers are also installed as these are necessary for the build.
Yeah, it's sad we are using those internal headers in perf.
The plan is for perf to eventually be a libperf tool, but what was done so far was make available classes and methods that were asked for by libperf users.
Completely untangling tools/perf/ from those internal bits will needs lots more work, so doing it the way Ian is doing now seems ok.
- Arnaldo
Quoted 5 lines
Ideally libperf provides callbacks to associate private data to each public data structure (e.g. evsel, evlist, etc). And external users just use public APIs only.
But that would be a major change.
Namhyung Kim
maintainerRe: [PATCH v2 08/14] tools lib perf: Add missing install headers
Hi Arnaldo,
Quoted 6 lines · Arnaldo Carvalho de Melo
Em Wed, Nov 09, 2022 at 12:12:16PM -0800, Namhyung Kim escreveu:
Quoted 3 lines · Ian Rogers
Quoted 2 lines
Headers necessary for the perf build. Note, internal headers are also installed as these are necessary for the build.
Quoted 8 lines
Quoted 1 line
Yeah, it's sad we are using those internal headers in perf.
The plan is for perf to eventually be a libperf tool, but what was done so far was make available classes and methods that were asked for by libperf users.
Completely untangling
tools/perf/from those internal bits will needs lots more work, so doing it the way Ian is doing now seems ok.
Agreed. I'm happy to see this work going on. :)
Thanks,
Namhyung
Ian Rogers
reviewerPATCH v2 9/14 tool lib symbol: Add Makefile/Build
In reply to Ian RogersAdd sufficient Makefile for libsymbol to be built as a dependency and header files installed.
--- tools/lib/symbol/Build | 1 + tools/lib/symbol/Makefile | 115 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 tools/lib/symbol/Build create mode 100644 tools/lib/symbol/Makefile
tools/lib/symbol/Build new file +1 -0
@@ -0,0 +1 @@ +libsymbol-y += kallsyms.o
tools/lib/symbol/Makefile new file +115 -0
115 lines not on this page · raw message
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 10/14 perf build: Install libsymbol locally when building
In reply to Ian RogersThe perf build currently has a '-Itools/lib' on the CC command line. This causes issues as the libapi, libsubcmd, libtraceevent, libbpf and libsymbol headers are all found via this path, making it impossible to override include behavior. Change the libsymbol build mirroring the libbpf, libsubcmd, libapi, libperf and libtraceevent build, so that it is installed in a directory along with its headers. A later change will modify the include behavior. Don't build kallsyms.o as part of util as this will lead to duplicate definitions. Add kallsym's directory to the MANIFEST rather than individual files, so that the Build and Makefile are added to a source tar ball.
--- tools/perf/.gitignore | 1 + tools/perf/MANIFEST | 3 +-- tools/perf/Makefile.perf | 25 ++++++++++++++++++++++--- tools/perf/util/Build | 5 ----- 4 files changed, 24 insertions(+), 10 deletions(-)
tools/perf/.gitignore +1 -0
@@ -42,6 +42,7 @@ libapi/ libbpf/ libperf/ libsubcmd/ +libsymbol/ libtraceevent/ libtraceevent_plugins/ fixdep
tools/perf/MANIFEST +1 -2
@@ -13,8 +13,7 @@ tools/lib/ctype.c tools/lib/hweight.c tools/lib/rbtree.c tools/lib/string.c -tools/lib/symbol/kallsyms.c -tools/lib/symbol/kallsyms.h +tools/lib/symbol tools/lib/find_bit.c tools/lib/bitmap.c tools/lib/list_sort.c
tools/perf/Makefile.perf +22 -3
@@ -246,6 +246,7 @@ LIBTRACEEVENT_DIR = $(srctree)/tools/lib/traceevent/ LIBTRACEEVENT_PLUGINS_DIR = $(LIBTRACEEVENT_DIR)/plugins LIBBPF_DIR = $(srctree)/tools/lib/bpf/ LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/ +LIBSYMBOL_DIR = $(srctree)/tools/lib/symbol/ LIBPERF_DIR = $(srctree)/tools/lib/perf/ DOC_DIR = $(srctree)/tools/perf/Documentation/
@@ -340,6 +341,15 @@ LIBSUBCMD_DESTDIR = $(LIBSUBCMD_OUTPUT) LIBSUBCMD_INCLUDE = $(LIBSUBCMD_DESTDIR)/include LIBSUBCMD = $(LIBSUBCMD_OUTPUT)/libsubcmd.a +ifneq ($(OUTPUT),) + LIBSYMBOL_OUTPUT = $(abspath $(OUTPUT))/libsymbol +else + LIBSYMBOL_OUTPUT = $(CURDIR)/libsymbol +endif +LIBSYMBOL_DESTDIR = $(LIBSYMBOL_OUTPUT) +LIBSYMBOL_INCLUDE = $(LIBSYMBOL_DESTDIR)/include +LIBSYMBOL = $(LIBSYMBOL_OUTPUT)/libsymbol.a + ifneq ($(OUTPUT),) LIBPERF_OUTPUT = $(abspath $(OUTPUT))/libperf else
@@ -398,7 +408,7 @@ endif export PERL_PATH -PERFLIBS = $(LIBAPI) $(LIBSUBCMD) $(LIBPERF) +PERFLIBS = $(LIBAPI) $(LIBPERF) $(LIBSUBCMD) $(LIBSYMBOL) ifndef NO_LIBBPF ifndef LIBBPF_DYNAMIC PERFLIBS += $(LIBBPF)
@@ -887,6 +897,15 @@ $(LIBSUBCMD)-clean: $(call QUIET_CLEAN, libsubcmd) $(Q)$(RM) -r -- $(LIBSUBCMD_OUTPUT) +$(LIBSYMBOL): FORCE | $(LIBSYMBOL_OUTPUT) + $(Q)$(MAKE) -C $(LIBSYMBOL_DIR) O=$(LIBSYMBOL_OUTPUT) \ + DESTDIR=$(LIBSYMBOL_DESTDIR) prefix= \ + $@ install_headers + +$(LIBSYMBOL)-clean: + $(call QUIET_CLEAN, libsymbol) + $(Q)$(RM) -r -- $(LIBSYMBOL_OUTPUT) + help: @echo 'Perf make targets:' @echo ' doc - make *all* documentation (see below)'
@@ -1071,7 +1090,7 @@ SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h $(SKEL_OUT)/func_latency.skel.h SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h -$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT): +$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): $(Q)$(MKDIR) -p $@ ifndef LIBTRACEEVENT_DYNAMIC
@@ -1121,7 +1140,7 @@ endif # BUILD_BPF_SKEL bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) -clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean libtraceevent_plugins-clean +clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean libtraceevent_plugins-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete $(Q)$(RM) $(OUTPUT).config-detected
tools/perf/util/Build +0 -5
@@ -19,7 +19,6 @@ perf-y += perf_event_attr_fprintf.o perf-y += evswitch.o perf-y += find_bit.o perf-y += get_current_dir_name.o -perf-y += kallsyms.o perf-y += levenshtein.o perf-y += llvm-utils.o perf-y += mmap.o
@@ -294,10 +293,6 @@ CFLAGS_expr.o += -Wno-redundant-decls CFLAGS_header.o += -include $(OUTPUT)PERF-VERSION-FILE CFLAGS_arm-spe.o += -I$(srctree)/tools/arch/arm64/include/ -$(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE - $(call rule_mkdir) - $(call if_changed_dep,cc_o_c) - $(OUTPUT)util/argv_split.o: ../lib/argv_split.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c)
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 11/14 perf expr: Tidy hashmap dependency
In reply to Ian Rogershashmap.h comes from libbpf but isn't installed with its headers. Always use the header file of the code in util. Change the hashmap.h dependency in expr.h to a forward declaration, add the necessary header file includes in the C files.
--- tools/perf/tests/expr.c | 1 + tools/perf/tests/pmu-events.c | 1 + tools/perf/util/bpf-loader.c | 4 ---- tools/perf/util/evsel.c | 4 ---- tools/perf/util/expr.c | 1 + tools/perf/util/expr.h | 7 +------ tools/perf/util/metricgroup.c | 1 + tools/perf/util/stat-shadow.c | 1 + tools/perf/util/stat.c | 4 ---- 9 files changed, 6 insertions(+), 18 deletions(-)
tools/perf/tests/expr.c +1 -0
@@ -2,6 +2,7 @@#include "util/cputopo.h" #include "util/debug.h" #include "util/expr.h" +#include "util/hashmap.h" #include "util/header.h" #include "util/smt.h" #include "tests.h"
tools/perf/tests/pmu-events.c +1 -0
@@ -12,6 +12,7 @@#include <perf/evlist.h> #include "util/evlist.h" #include "util/expr.h" +#include "util/hashmap.h" #include "util/parse-events.h" #include "metricgroup.h" #include "stat.h"
tools/perf/util/bpf-loader.c +0 -4
@@ -27,11 +27,7 @@#include "util.h" #include "llvm-utils.h" #include "c++/clang-c.h" -#ifdef HAVE_LIBBPF_SUPPORT -#include <bpf/hashmap.h> -#else #include "util/hashmap.h" -#endif #include "asm/bug.h" #include <internal/xyarray.h>
tools/perf/util/evsel.c +0 -4
@@ -46,11 +46,7 @@#include "string2.h" #include "memswap.h" #include "util.h" -#ifdef HAVE_LIBBPF_SUPPORT -#include <bpf/hashmap.h> -#else #include "util/hashmap.h" -#endif #include "pmu-hybrid.h" #include "off_cpu.h" #include "../perf-sys.h"
tools/perf/util/expr.c +1 -0
@@ -11,6 +11,7 @@#include "expr.h" #include "expr-bison.h" #include "expr-flex.h" +#include "util/hashmap.h" #include "smt.h" #include "tsc.h" #include <linux/err.h>
tools/perf/util/expr.h +1 -6
@@ -2,12 +2,7 @@#ifndef PARSE_CTX_H #define PARSE_CTX_H 1 -#ifdef HAVE_LIBBPF_SUPPORT -#include <bpf/hashmap.h> -#else -#include "util/hashmap.h" -#endif - +struct hashmap ;struct metric_ref ; struct expr_scanner_ctx {
tools/perf/util/metricgroup.c +1 -0
@@ -28,6 +28,7 @@#include "util.h" #include <asm/bug.h> #include "cgroup.h" +#include "util/hashmap.h" struct metric_event *metricgroup__lookup(struct rblist *metric_events, struct evsel *evsel,
tools/perf/util/stat-shadow.c +1 -0
@@ -14,6 +14,7 @@#include "units.h" #include <linux/zalloc.h> #include "iostat.h" +#include "util/hashmap.h" /* * AGGR_GLOBAL: Use CPU 0
tools/perf/util/stat.c +0 -4
@@ -14,11 +14,7 @@#include "evlist.h" #include "evsel.h" #include "thread_map.h" -#ifdef HAVE_LIBBPF_SUPPORT -#include <bpf/hashmap.h> -#else #include "util/hashmap.h" -#endif #include <linux/zalloc.h> void update_stats (struct stats *stats,u64 val)
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 12/14 perf thread_map: Reduce exposure of libperf internal API
In reply to Ian RogersRemove unnecessary include of internal threadmap.h and refcount.h in thread_map.h. Switch to using public APIs when possible or including the internal header file in the C file. Fix a transitive dependency in openat-syscall.c broken by the clean up.
--- tools/perf/builtin-stat.c | 1 + tools/perf/builtin-trace.c | 4 ++-- tools/perf/tests/openat-syscall.c | 1 + tools/perf/tests/thread-map.c | 1 + tools/perf/util/bpf_counter.c | 2 +- tools/perf/util/evsel.c | 1 + tools/perf/util/python.c | 6 +++--- tools/perf/util/scripting-engines/trace-event-python.c | 2 +- tools/perf/util/thread_map.c | 1 + tools/perf/util/thread_map.h | 2 -- 10 files changed, 12 insertions(+), 9 deletions(-)
tools/perf/builtin-stat.c +1 -0
@@ -93,6 +93,7 @@#include <linux/ctype.h> #include <perf/evlist.h> +#include <internal/threadmap.h> #define DEFAULT_SEPARATOR " "#define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi"
tools/perf/builtin-trace.c +2 -2
@@ -4093,8 +4093,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv) } trace->multiple_threads =perf_thread_map__pid (evlist->core.threads,0 ) ==-1 || - evlist->core.threads->nr >1 || -evlist__first (evlist)->core.attr.inherit; +perf_thread_map__nr (evlist->core.threads) >1 || +evlist__first (evlist)->core.attr.inherit;/* * Now that we already used evsel->core.attr to ask the kernel to setup the
tools/perf/tests/openat-syscall.c +1 -0
@@ -7,6 +7,7 @@#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <unistd.h> #include "thread_map.h" #include "evsel.h" #include "debug.h"
tools/perf/tests/thread-map.c +1 -0
@@ -11,6 +11,7 @@#include "util/synthetic-events.h" #include <linux/zalloc.h> #include <perf/event.h> +#include <internal/threadmap.h> struct perf_sample ;struct perf_tool ;
tools/perf/util/bpf_counter.c +1 -1
@@ -561,7 +561,7 @@ static int bperf__load(struct evsel *evsel, struct target *target)if (filter_type ==BPERF_FILTER_PID || filter_type ==BPERF_FILTER_TGID ) - key = evsel->core.threads->map[i].pid; + key =perf_thread_map__pid (evsel->core.threads, i);else if (filter_type ==BPERF_FILTER_CPU ) key = evsel->core.cpus->map[i].cpu;else
tools/perf/util/evsel.c +1 -0
@@ -53,6 +53,7 @@#include "util/parse-branch-options.h" #include <internal/xyarray.h> #include <internal/lib.h> +#include <internal/threadmap.h> #include <linux/ctype.h>
tools/perf/util/python.c +3 -3
@@ -718,17 +718,17 @@ static Py_ssize_t pyrf_thread_map__length(PyObject *obj) {struct pyrf_thread_map *pthreads = (void *)obj; -return pthreads->threads->nr; +return perf_thread_map__nr (pthreads->threads); }static PyObject *pyrf_thread_map__item (PyObject *obj,Py_ssize_t i) {struct pyrf_thread_map *pthreads = (void *)obj; -if (i >= pthreads->threads->nr) +if (i >=perf_thread_map__nr (pthreads->threads))return NULL ; -return Py_BuildValue ("i" , pthreads->threads->map[i]); +return Py_BuildValue ("i" ,perf_thread_map__pid (pthreads->threads, i)); }static PySequenceMethods pyrf_thread_map__sequence_methods = {
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -1654,7 +1654,7 @@ static void python_process_stat(struct perf_stat_config *config,struct perf_cpu_map *cpus = counter->core.cpus;int cpu, thread; -for (thread =0 ; thread < threads->nr; thread++) { +for (thread =0 ; thread <perf_thread_map__nr (threads); thread++) {for (cpu =0 ; cpu <perf_cpu_map__nr (cpus); cpu++) { process_stat(counter, perf_cpu_map__cpu(cpus, cpu), perf_thread_map__pid(threads, thread), tstamp,
tools/perf/util/thread_map.c +1 -0
@@ -18,6 +18,7 @@#include "thread_map.h" #include "debug.h" #include "event.h" +#include <internal/threadmap.h> /* Skip "." and ".." directories */ static int filter (const struct dirent *dir)
tools/perf/util/thread_map.h +0 -2
@@ -4,8 +4,6 @@#include <sys/types.h> #include <stdio.h> -#include <linux/refcount.h> -#include <internal/threadmap.h> #include <perf/threadmap.h> struct perf_record_thread_map ;
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 13/14 perf cpumap: Tidy libperf includes
In reply to Ian RogersUse public API when possible, don't include internal API in header files in evsel.h. Fix any related breakages.
--- tools/perf/tests/cpumap.c | 2 +- tools/perf/util/auxtrace.h | 2 +- tools/perf/util/cpumap.c | 1 + tools/perf/util/cpumap.h | 2 +- tools/perf/util/evsel.h | 2 -- 5 files changed, 4 insertions(+), 5 deletions(-)
tools/perf/tests/cpumap.c +1 -1
@@ -6,7 +6,7 @@#include "util/synthetic-events.h" #include <string.h> #include <linux/bitops.h> -#include <perf/cpumap.h> +#include <internal/cpumap.h> #include "debug.h" struct machine ;
tools/perf/util/auxtrace.h +1 -1
@@ -15,7 +15,7 @@#include <linux/list.h> #include <linux/perf_event.h> #include <linux/types.h> -#include <internal/cpumap.h> +#include <perf/cpumap.h> #include <asm/bitsperlong.h> #include <asm/barrier.h>
tools/perf/util/cpumap.c +1 -0
@@ -12,6 +12,7 @@#include <linux/ctype.h> #include <linux/zalloc.h> +#include <internal/cpumap.h> static struct perf_cpu max_cpu_num;static struct perf_cpu max_present_cpu_num;
tools/perf/util/cpumap.h +1 -1
@@ -4,8 +4,8 @@#include <stdbool.h> #include <stdio.h> -#include <internal/cpumap.h> #include <perf/cpumap.h> +#include <linux/refcount.h> /** Identify where counts are aggregated, -1 implies not to aggregate. */ struct aggr_cpu_id {
tools/perf/util/evsel.h +0 -2
@@ -10,8 +10,6 @@#include <internal/evsel.h> #include <perf/evsel.h> #include "symbol_conf.h" -#include <internal/cpumap.h> -#include <perf/cpumap.h> struct bpf_object ;struct cgroup ;
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Ian Rogers
reviewerPATCH v2 14/14 perf build: Use tools/lib headers from install path
In reply to Ian RogersSwitch -I from tools/lib to the install path for the tools/lib libraries that are depended upon. List header files provided by libraries so that dependencies are built in the correct order.
--- tools/perf/Makefile.config | 2 -- tools/perf/Makefile.perf | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-)
tools/perf/Makefile.config +0 -2
@@ -349,7 +349,6 @@ ifeq ($(DEBUG),0) endif endif -INC_FLAGS += -I$(srctree)/tools/lib/perf/include INC_FLAGS += -I$(src-perf)/util/include INC_FLAGS += -I$(src-perf)/arch/$(SRCARCH)/include INC_FLAGS += -I$(srctree)/tools/include/
@@ -367,7 +366,6 @@ endif INC_FLAGS += -I$(src-perf)/util INC_FLAGS += -I$(src-perf) -INC_FLAGS += -I$(srctree)/tools/lib/ CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
tools/perf/Makefile.perf +46 -0
82 lines not on this page · raw message
Signature · 1 line
2.38.1.431.g37b22c650d-goog
Hi Ian,
Quoted 19 lines · Ian Rogers
The previous build would add -Itools/lib and get dependencies for libtraceevent, libsubcmd, libsymbol, libapi and libbpf meaning that overriding these libraries would change the link time dependency but the headers would erroneously come from
tools/lib. Fix the build to install headers and then depend on these. To reduce exposing internal headers/APIs some clean up is performed.tools/lib/symbolhas aMakefileadded, whiletools/lib/apiandtools/lib/subcmdhave install targets added. The pattern used for the dependencies in Makefile.perf is modelled on libbpf.The problem and solution were motivated by this issue and discussion:
https://lore.kernel.org/lkml/CAEf4BzbbOHQZUAe6iWaehKCPQAf3VC=hq657buqe2_yRKxaK-A@mail.gmail.com/v2. Fix a MANIFEST issue for the source tar ball. Add dependencies for
the installed header files so that the build doesn't overtake building these dependencies. Both issues reported by Arnaldo Carvalho de Melo <[email protected]>.
Quoted 15 lines
Ian Rogers (14):
tools lib api: Add install target
tools lib subcmd: Add install target
perf build: Install libsubcmd locally when building perf build: Install libapi locally when building perf build: Install libperf locally when building perf build: Install libtraceevent locally when building tools lib api: Add missing install headers tools lib perf: Add missing install headers tool lib symbol: Add Makefile/Build
perf build: Install libsymbol locally when building perf expr: Tidy hashmap dependency
perfthread_map: Reduce exposure of libperf internal API perf cpumap: Tidy libperf includes
perf build: Usetools/libheaders from install path
Thanks,
Namhyung
Quoted 41 lines
tools/lib/api/Makefile | 52 +++++ tools/lib/perf/Makefile | 10 +- tools/lib/subcmd/Makefile | 49 +++++ tools/lib/symbol/Build | 1 + tools/lib/symbol/Makefile | 115 +++++++++++ tools/perf/.gitignore | 7 +- tools/perf/MANIFEST | 3 +- tools/perf/Makefile.config | 2 - tools/perf/Makefile.perf | 192 ++++++++++++++---- tools/perf/builtin-stat.c | 1 + tools/perf/builtin-trace.c | 4 +- tools/perf/tests/cpumap.c | 2 +- tools/perf/tests/expr.c | 1 + tools/perf/tests/openat-syscall.c | 1 + tools/perf/tests/pmu-events.c | 1 + tools/perf/tests/thread-map.c | 1 + tools/perf/util/Build | 5 - tools/perf/util/auxtrace.h | 2 +- tools/perf/util/bpf-loader.c | 4 - tools/perf/util/bpf_counter.c | 2 +- tools/perf/util/cpumap.c | 1 + tools/perf/util/cpumap.h | 2 +- tools/perf/util/evsel.c | 5 +- tools/perf/util/evsel.h | 2 - tools/perf/util/expr.c | 1 + tools/perf/util/expr.h | 7 +- tools/perf/util/metricgroup.c | 1 + tools/perf/util/python.c | 6 +- .../scripting-engines/trace-event-python.c | 2 +- tools/perf/util/stat-shadow.c | 1 + tools/perf/util/stat.c | 4 - tools/perf/util/thread_map.c | 1 + tools/perf/util/thread_map.h | 2 - 33 files changed, 402 insertions(+), 88 deletions(-) create mode 100644 tools/lib/symbol/Build create mode 100644 tools/lib/symbol/Makefile--
2.38.1.431.g37b22c650d-goog
Arnaldo Carvalho de Melo
maintainerEm Thu, Nov 10, 2022 at 10:10:18AM -0800, Namhyung Kim escreveu:
Quoted 38 lines
Hi Ian,
Quoted 19 lines · Ian Rogers
The previous build would add -Itools/lib and get dependencies for libtraceevent, libsubcmd, libsymbol, libapi and libbpf meaning that overriding these libraries would change the link time dependency but the headers would erroneously come from
tools/lib. Fix the build to install headers and then depend on these. To reduce exposing internal headers/APIs some clean up is performed.tools/lib/symbolhas aMakefileadded, whiletools/lib/apiandtools/lib/subcmdhave install targets added. The pattern used for the dependencies in Makefile.perf is modelled on libbpf.The problem and solution were motivated by this issue and discussion:
https://lore.kernel.org/lkml/CAEf4BzbbOHQZUAe6iWaehKCPQAf3VC=hq657buqe2_yRKxaK-A@mail.gmail.com/v2. Fix a MANIFEST issue for the source tar ball. Add dependencies for
the installed header files so that the build doesn't overtake building these dependencies. Both issues reported by Arnaldo Carvalho de Melo <[email protected]>.Quoted 15 lines
Ian Rogers (14):
tools lib api: Add install target
tools lib subcmd: Add install target
perf build: Install libsubcmd locally when building perf build: Install libapi locally when building perf build: Install libperf locally when building perf build: Install libtraceevent locally when building tools lib api: Add missing install headers tools lib perf: Add missing install headers tool lib symbol: Add Makefile/Build
perf build: Install libsymbol locally when building perf expr: Tidy hashmap dependency
perfthread_map: Reduce exposure of libperf internal API perf cpumap: Tidy libperf includes
perf build: Usetools/libheaders from install path
Quoted 1 line
Acked-by Namhyung Kim <[email protected]>
'make -C tools/perf build-test' is failing, looks like parallelization woes again:
⬢[acme@toolbox perf]$ getconf _NPROCESSORS_ONLN
32
⬢[acme@toolbox perf]$
⬢[acme@toolbox perf]$ git log --oneline -1 ; time make -C tools/perf build-test 9f22d36a1dd0297a (HEAD -> perf/core) perf build: Use tools/lib headers from install path
make: Entering directory '/var/home/acme/git/perf/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
make_static: cd . && make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 -j32 DESTDIR=/tmp/tmp.i0kUDsiQbV
make_with_gtk2: cd . && make GTK2=1 -j32 DESTDIR=/tmp/tmp.MNcgfeG07c
cd . && make GTK2=1 -j32 DESTDIR=/tmp/tmp.MNcgfeG07c
BUILD: Doing 'make -j32' parallel build
HOSTCC fixdep.o
HOSTLD fixdep-in.o
LINK fixdepWarning: Kernel ABI header at 'tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h' diff -u tools/arch/arm64/include/uapi/asm/perf_regs.h arch/arm64/include/uapi/asm/perf_regs.h
Warning: Kernel ABI header at 'tools/arch/arm64/include/asm/cputype.h' differs from latest version at 'arch/arm64/include/asm/cputype.h' diff -u tools/arch/arm64/include/asm/cputype.h arch/arm64/include/asm/cputype.h
Warning: Kernel ABI header at 'tools/perf/arch/powerpc/entry/syscalls/syscall.tbl' differs from latest version at 'arch/powerpc/kernel/syscalls/syscall.tbl' diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
Auto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... libbfd: [ on ] ... libbfd-buildid: [ on ] ... libcap: [ on ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ on ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ on ] ... bpf: [ on ] ... libaio: [ on ] ... libzstd: [ on ]
GEN common-cmds.h
CC perf-read-vdso32
CC dlfilters/dlfilter-test-api-v0.o
CC dlfilters/dlfilter-show-cycles.o
CC jvmti/libjvmti.o
CC jvmti/jvmti_agent.o
CC jvmti/libstring.o
CC jvmti/libctype.o
CC ui/gtk/browser.o
CC ui/gtk/hists.o
CC ui/gtk/setup.o
CC ui/gtk/util.o
GEN pmu-events/pmu-events.c
CC ui/gtk/helpline.o
LINK dlfilters/dlfilter-show-cycles.so
CC ui/gtk/progress.o
CC ui/gtk/annotate.o
CC ui/gtk/zalloc.o
LINK dlfilters/dlfilter-test-api-v0.so
INSTALL headers
CC /var/home/acme/git/perf/tools/perf/libsubcmd/exec-cmd.o
CC /var/home/acme/git/perf/tools/perf/libsubcmd/help.o
CC /var/home/acme/git/perf/tools/perf/libsubcmd/pager.o
CC /var/home/acme/git/perf/tools/perf/libsubcmd/parse-options.o
CC /var/home/acme/git/perf/tools/perf/libsubcmd/run-command.o
In file included from ui/gtk/hists.c:2:
/var/home/acme/git/perf/tools/perf/util/include/../evlist.h:9:10: fatal error: api/fd/array.h: No such file or directory
9 | #include <api/fd/array.h>
| ^~~~~~~~~~~~~~~~compilation terminated.
make[6]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:97: ui/gtk/hists.o] Error 1
make[6]: *** Waiting for unfinished jobs....
CC /var/home/acme/git/perf/tools/perf/libsubcmd/sigchain.o
make -f /var/home/acme/git/perf/tools/build/Makefile.build dir=. obj=libsymbol V=1
In file included from ui/gtk/browser.c:2:/var/home/acme/git/perf/tools/perf/util/include/../evsel.h:10:10: fatal error: internal/evsel.h: No such file or directory
10 | #include <internal/evsel.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
make[6]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:97: ui/gtk/browser.o] Error 1
INSTALL headers
CC /var/home/acme/git/perf/tools/perf/libtraceevent/event-parse.o
Arnaldo Carvalho de Melo
maintainerEm Mon, Nov 14, 2022 at 05:16:57PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 39 lines
Em Thu, Nov 10, 2022 at 10:10:18AM -0800, Namhyung Kim escreveu:
Quoted 38 lines
Hi Ian,
Quoted 34 lines · Ian Rogers
The previous build would add -Itools/lib and get dependencies for libtraceevent, libsubcmd, libsymbol, libapi and libbpf meaning that overriding these libraries would change the link time dependency but the headers would erroneously come from
tools/lib. Fix the build to install headers and then depend on these. To reduce exposing internal headers/APIs some clean up is performed.tools/lib/symbolhas aMakefileadded, whiletools/lib/apiandtools/lib/subcmdhave install targets added. The pattern used for the dependencies in Makefile.perf is modelled on libbpf.The problem and solution were motivated by this issue and discussion:
https://lore.kernel.org/lkml/CAEf4BzbbOHQZUAe6iWaehKCPQAf3VC=hq657buqe2_yRKxaK-A@mail.gmail.com/v2. Fix a MANIFEST issue for the source tar ball. Add dependencies for
the installed header files so that the build doesn't overtake building these dependencies. Both issues reported by Arnaldo Carvalho de Melo <[email protected]>.Ian Rogers (14):
tools lib api: Add install target
tools lib subcmd: Add install target
perf build: Install libsubcmd locally when building perf build: Install libapi locally when building perf build: Install libperf locally when building perf build: Install libtraceevent locally when building tools lib api: Add missing install headers tools lib perf: Add missing install headers tool lib symbol: Add Makefile/Build
perf build: Install libsymbol locally when building perf expr: Tidy hashmap dependency
perfthread_map: Reduce exposure of libperf internal API perf cpumap: Tidy libperf includes
perf build: Usetools/libheaders from install path
Quoted 4 lines
Quoted 1 line
Acked-by Namhyung Kim <[email protected]>'make -C
tools/perfbuild-test' is failing, looks like parallelization woes again:
It's all at the perf/tools-libs-includes branch in my tree.
- Arnaldo
Quoted 86 lines
⬢[acme@toolbox perf]$ getconf
_NPROCESSORS_ONLN
32
⬢[acme@toolbox perf]$⬢[acme@toolbox perf]$ git log --oneline -1 ; time make -C
tools/perfbuild-test9f22d36a1dd0297a(HEAD -> perf/core) perf build: Usetools/libheaders from install path
make: Entering directory '/var/home/acme/git/perf/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .make_static: cd . && make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 -j32 DESTDIR=/tmp/tmp.i0kUDsiQbV make_with_gtk2: cd . && make GTK2=1 -j32 DESTDIR=/tmp/tmp.MNcgfeG07c cd . && make GTK2=1 -j32 DESTDIR=/tmp/tmp.MNcgfeG07c BUILD: Doing 'make -j32' parallel build HOSTCC fixdep.o HOSTLD fixdep-in.o LINK fixdepWarning: Kernel ABI header at '
tools/arch/arm64/include/uapi/asm/perf_regs.h' differs from latest version at 'arch/arm64/include/uapi/asm/perf_regs.h' diff -utools/arch/arm64/include/uapi/asm/perf_regs.harch/arm64/include/uapi/asm/perf_regs.h
Warning: Kernel ABI header at 'tools/arch/arm64/include/asm/cputype.h' differs from latest version at 'arch/arm64/include/asm/cputype.h' diff -utools/arch/arm64/include/asm/cputype.harch/arm64/include/asm/cputype.h
Warning: Kernel ABI header at 'tools/perf/arch/powerpc/entry/syscalls/syscall.tbl' differs from latest version at 'arch/powerpc/kernel/syscalls/syscall.tbl' diff -utools/perf/arch/powerpc/entry/syscalls/syscall.tblarch/powerpc/kernel/syscalls/syscall.tblAuto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... libbfd: [ on ] ... libbfd-buildid: [ on ] ... libcap: [ on ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ on ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ on ] ... bpf: [ on ] ... libaio: [ on ] ... libzstd: [ on ]GEN common-cmds.h CC perf-read-vdso32 CC dlfilters/dlfilter-test-api-v0.o CC dlfilters/dlfilter-show-cycles.o CC jvmti/libjvmti.o CC jvmti/jvmti_agent.o CC jvmti/libstring.o CC jvmti/libctype.o CC ui/gtk/browser.o CC ui/gtk/hists.o CC ui/gtk/setup.o CC ui/gtk/util.o GEN pmu-events/pmu-events.c CC ui/gtk/helpline.o LINK dlfilters/dlfilter-show-cycles.so CC ui/gtk/progress.o CC ui/gtk/annotate.o CC ui/gtk/zalloc.o LINK dlfilters/dlfilter-test-api-v0.so INSTALL headers CC /var/home/acme/git/perf/tools/perf/libsubcmd/exec-cmd.o CC /var/home/acme/git/perf/tools/perf/libsubcmd/help.o CC /var/home/acme/git/perf/tools/perf/libsubcmd/pager.o CC /var/home/acme/git/perf/tools/perf/libsubcmd/parse-options.o CC /var/home/acme/git/perf/tools/perf/libsubcmd/run-command.o In file included from ui/gtk/hists.c:2: /var/home/acme/git/perf/tools/perf/util/include/../evlist.h:9:10: fatal error: api/fd/array.h: No such file or directory 9 | #include <api/fd/array.h> | ^~~~~~~~~~~~~~~~compilation terminated.
make[6]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:97:ui/gtk/hists.o] Error 1
make[6]: *** Waiting for unfinished jobs....
CC/var/home/acme/git/perf/tools/perf/libsubcmd/sigchain.o
make -f/var/home/acme/git/perf/tools/build/Makefile.builddir=. obj=libsymbol V=1
In file included fromui/gtk/browser.c:2:/var/home/acme/git/perf/tools/perf/util/include/../evsel.h:10:10: fatal error:internal/evsel.h: No such file or directory
10 | #include <internal/evsel.h>| ^~~~~~~~~~~~~~~~~~compilation terminated.
make[6]: *** [/var/home/acme/git/perf/tools/build/Makefile.build:97:ui/gtk/browser.o] Error 1
INSTALL headers
CC/var/home/acme/git/perf/tools/perf/libtraceevent/event-parse.o
Signature · 1 line
- Arnaldo