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

libtraceevent: Move traceevent plugins in its own subdirectory

All traceevent plugins code is moved to tools/lib/traceevent/plugins
subdirectory. It makes traceevent implementation in trace-cmd and in
kernel tree consistent. There is no changes in the way libtraceevent and
plugins are compiled and installed.

Committer notes:

Applied fixup provided by Steven, fixing the tools/perf/Makefile.perf
target for the plugin dynamic list file. Problem noticed when cross
building to aarch64 from a Ubuntu 19.04 container.

Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Link: http://lore.kernel.org/lkml/20190923115929.453b68f1@oasis.local.home
Link: http://lore.kernel.org/lkml/20190919212542.377333393@goodmis.org
Link: http://lore.kernel.org/linux-trace-devel/20190917105055.18983-1-tz.stoyanov@gmail.com
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Tzvetomir Stoyanov (VMware) and committed by
Arnaldo Carvalho de Melo
077faf3d d69094f3

+250 -91
-11
tools/lib/traceevent/Build
··· 6 6 libtraceevent-y += kbuffer-parse.o 7 7 libtraceevent-y += tep_strerror.o 8 8 libtraceevent-y += event-parse-api.o 9 - 10 - plugin_jbd2-y += plugin_jbd2.o 11 - plugin_hrtimer-y += plugin_hrtimer.o 12 - plugin_kmem-y += plugin_kmem.o 13 - plugin_kvm-y += plugin_kvm.o 14 - plugin_mac80211-y += plugin_mac80211.o 15 - plugin_sched_switch-y += plugin_sched_switch.o 16 - plugin_function-y += plugin_function.o 17 - plugin_xen-y += plugin_xen.o 18 - plugin_scsi-y += plugin_scsi.o 19 - plugin_cfg80211-y += plugin_cfg80211.o
+16 -78
tools/lib/traceevent/Makefile
··· 58 58 export DESTDIR DESTDIR_SQ 59 59 export EVENT_PARSE_VERSION 60 60 61 - set_plugin_dir := 1 62 - 63 - # Set plugin_dir to preffered global plugin location 64 - # If we install under $HOME directory we go under 65 - # $(HOME)/.local/lib/traceevent/plugins 66 - # 67 - # We dont set PLUGIN_DIR in case we install under $HOME 68 - # directory, because by default the code looks under: 69 - # $(HOME)/.local/lib/traceevent/plugins by default. 70 - # 71 - ifeq ($(plugin_dir),) 72 - ifeq ($(prefix),$(HOME)) 73 - override plugin_dir = $(HOME)/.local/lib/traceevent/plugins 74 - set_plugin_dir := 0 75 - else 76 - override plugin_dir = $(libdir)/traceevent/plugins 77 - endif 78 - endif 79 - 80 - ifeq ($(set_plugin_dir),1) 81 - PLUGIN_DIR = -DPLUGIN_DIR="$(plugin_dir)" 82 - PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))' 83 - endif 84 - 85 61 include ../../scripts/Makefile.include 86 62 87 63 # copy a bit from Linux kbuild ··· 81 105 # Shell quotes 82 106 libdir_SQ = $(subst ','\'',$(libdir)) 83 107 libdir_relative_SQ = $(subst ','\'',$(libdir_relative)) 84 - plugin_dir_SQ = $(subst ','\'',$(plugin_dir)) 85 108 86 109 CONFIG_INCLUDES = 87 110 CONFIG_LIBS = ··· 126 151 export srctree OUTPUT CC LD CFLAGS V 127 152 build := -f $(srctree)/tools/build/Makefile.build dir=. obj 128 153 129 - PLUGINS = plugin_jbd2.so 130 - PLUGINS += plugin_hrtimer.so 131 - PLUGINS += plugin_kmem.so 132 - PLUGINS += plugin_kvm.so 133 - PLUGINS += plugin_mac80211.so 134 - PLUGINS += plugin_sched_switch.so 135 - PLUGINS += plugin_function.so 136 - PLUGINS += plugin_xen.so 137 - PLUGINS += plugin_scsi.so 138 - PLUGINS += plugin_cfg80211.so 139 - 140 - PLUGINS := $(addprefix $(OUTPUT),$(PLUGINS)) 141 - PLUGINS_IN := $(PLUGINS:.so=-in.o) 142 - 143 154 TE_IN := $(OUTPUT)libtraceevent-in.o 144 155 LIB_TARGET := $(addprefix $(OUTPUT),$(LIB_TARGET)) 145 - DYNAMIC_LIST_FILE := $(OUTPUT)libtraceevent-dynamic-list 146 156 147 - CMD_TARGETS = $(LIB_TARGET) $(PLUGINS) $(DYNAMIC_LIST_FILE) 157 + CMD_TARGETS = $(LIB_TARGET) 148 158 149 159 TARGETS = $(CMD_TARGETS) 150 160 151 - all: all_cmd 161 + all: all_cmd plugins 152 162 153 163 all_cmd: $(CMD_TARGETS) 154 164 ··· 147 187 148 188 $(OUTPUT)libtraceevent.a: $(TE_IN) 149 189 $(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^ 150 - 151 - $(OUTPUT)libtraceevent-dynamic-list: $(PLUGINS) 152 - $(QUIET_GEN)$(call do_generate_dynamic_list_file, $(PLUGINS), $@) 153 - 154 - plugins: $(PLUGINS) 155 - 156 - __plugin_obj = $(notdir $@) 157 - plugin_obj = $(__plugin_obj:-in.o=) 158 - 159 - $(PLUGINS_IN): force 160 - $(Q)$(MAKE) $(build)=$(plugin_obj) 161 190 162 191 $(OUTPUT)%.so: $(OUTPUT)%-in.o 163 192 $(QUIET_LINK)$(CC) $(CFLAGS) -shared $(LDFLAGS) -nostartfiles -o $@ $^ ··· 207 258 $(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2' 208 259 endef 209 260 210 - define do_install_plugins 211 - for plugin in $1; do \ 212 - $(call do_install,$$plugin,$(plugin_dir_SQ)); \ 213 - done 214 - endef 215 - 216 - define do_generate_dynamic_list_file 217 - symbol_type=`$(NM) -u -D $1 | awk 'NF>1 {print $$1}' | \ 218 - xargs echo "U w W" | tr 'w ' 'W\n' | sort -u | xargs echo`;\ 219 - if [ "$$symbol_type" = "U W" ];then \ 220 - (echo '{'; \ 221 - $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ 222 - echo '};'; \ 223 - ) > $2; \ 224 - else \ 225 - (echo Either missing one of [$1] or bad version of $(NM)) 1>&2;\ 226 - fi 227 - endef 228 - 229 261 PKG_CONFIG_FILE = libtraceevent.pc 230 262 define do_install_pkgconfig_file 231 263 if [ -n "${pkgconfig_dir}" ]; then \ ··· 226 296 $(call do_install_mkdir,$(libdir_SQ)); \ 227 297 cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ) 228 298 229 - install_plugins: $(PLUGINS) 230 - $(call QUIET_INSTALL, trace_plugins) \ 231 - $(call do_install_plugins, $(PLUGINS)) 232 - 233 299 install_pkgconfig: 234 300 $(call QUIET_INSTALL, $(PKG_CONFIG_FILE)) \ 235 301 $(call do_install_pkgconfig_file,$(prefix)) ··· 239 313 240 314 install: install_lib 241 315 242 - clean: 316 + clean: clean_plugins 243 317 $(call QUIET_CLEAN, libtraceevent) \ 244 318 $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd; \ 245 319 $(RM) TRACEEVENT-CFLAGS tags TAGS; \ ··· 277 351 @echo ' doc-install - install the man pages' 278 352 @echo ' doc-uninstall - uninstall the man pages' 279 353 @echo'' 280 - PHONY += force plugins 354 + 355 + PHONY += plugins 356 + plugins: 357 + $(call descend,plugins) 358 + 359 + PHONY += install_plugins 360 + install_plugins: 361 + $(call descend,plugins,install) 362 + 363 + PHONY += clean_plugins 364 + clean_plugins: 365 + $(call descend,plugins,clean) 366 + 281 367 force: 282 368 283 369 # Declare the contents of the .PHONY variable as phony. We keep that
tools/lib/traceevent/plugin_cfg80211.c tools/lib/traceevent/plugins/plugin_cfg80211.c
tools/lib/traceevent/plugin_function.c tools/lib/traceevent/plugins/plugin_function.c
tools/lib/traceevent/plugin_hrtimer.c tools/lib/traceevent/plugins/plugin_hrtimer.c
tools/lib/traceevent/plugin_jbd2.c tools/lib/traceevent/plugins/plugin_jbd2.c
tools/lib/traceevent/plugin_kmem.c tools/lib/traceevent/plugins/plugin_kmem.c
tools/lib/traceevent/plugin_kvm.c tools/lib/traceevent/plugins/plugin_kvm.c
tools/lib/traceevent/plugin_mac80211.c tools/lib/traceevent/plugins/plugin_mac80211.c
tools/lib/traceevent/plugin_sched_switch.c tools/lib/traceevent/plugins/plugin_sched_switch.c
tools/lib/traceevent/plugin_scsi.c tools/lib/traceevent/plugins/plugin_scsi.c
tools/lib/traceevent/plugin_xen.c tools/lib/traceevent/plugins/plugin_xen.c
+10
tools/lib/traceevent/plugins/Build
··· 1 + plugin_jbd2-y += plugin_jbd2.o 2 + plugin_hrtimer-y += plugin_hrtimer.o 3 + plugin_kmem-y += plugin_kmem.o 4 + plugin_kvm-y += plugin_kvm.o 5 + plugin_mac80211-y += plugin_mac80211.o 6 + plugin_sched_switch-y += plugin_sched_switch.o 7 + plugin_function-y += plugin_function.o 8 + plugin_xen-y += plugin_xen.o 9 + plugin_scsi-y += plugin_scsi.o 10 + plugin_cfg80211-y += plugin_cfg80211.o
+222
tools/lib/traceevent/plugins/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + #MAKEFLAGS += --no-print-directory 4 + 5 + 6 + # Makefiles suck: This macro sets a default value of $(2) for the 7 + # variable named by $(1), unless the variable has been set by 8 + # environment or command line. This is necessary for CC and AR 9 + # because make sets default values, so the simpler ?= approach 10 + # won't work as expected. 11 + define allow-override 12 + $(if $(or $(findstring environment,$(origin $(1))),\ 13 + $(findstring command line,$(origin $(1)))),,\ 14 + $(eval $(1) = $(2))) 15 + endef 16 + 17 + # Allow setting CC and AR, or setting CROSS_COMPILE as a prefix. 18 + $(call allow-override,CC,$(CROSS_COMPILE)gcc) 19 + $(call allow-override,AR,$(CROSS_COMPILE)ar) 20 + $(call allow-override,NM,$(CROSS_COMPILE)nm) 21 + $(call allow-override,PKG_CONFIG,pkg-config) 22 + 23 + EXT = -std=gnu99 24 + INSTALL = install 25 + 26 + # Use DESTDIR for installing into a different root directory. 27 + # This is useful for building a package. The program will be 28 + # installed in this directory as if it was the root directory. 29 + # Then the build tool can move it later. 30 + DESTDIR ?= 31 + DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' 32 + 33 + LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) 34 + ifeq ($(LP64), 1) 35 + libdir_relative = lib64 36 + else 37 + libdir_relative = lib 38 + endif 39 + 40 + prefix ?= /usr/local 41 + libdir = $(prefix)/$(libdir_relative) 42 + 43 + set_plugin_dir := 1 44 + 45 + # Set plugin_dir to preffered global plugin location 46 + # If we install under $HOME directory we go under 47 + # $(HOME)/.local/lib/traceevent/plugins 48 + # 49 + # We dont set PLUGIN_DIR in case we install under $HOME 50 + # directory, because by default the code looks under: 51 + # $(HOME)/.local/lib/traceevent/plugins by default. 52 + # 53 + ifeq ($(plugin_dir),) 54 + ifeq ($(prefix),$(HOME)) 55 + override plugin_dir = $(HOME)/.local/lib/traceevent/plugins 56 + set_plugin_dir := 0 57 + else 58 + override plugin_dir = $(libdir)/traceevent/plugins 59 + endif 60 + endif 61 + 62 + ifeq ($(set_plugin_dir),1) 63 + PLUGIN_DIR = -DPLUGIN_DIR="$(plugin_dir)" 64 + PLUGIN_DIR_SQ = '$(subst ','\'',$(PLUGIN_DIR))' 65 + endif 66 + 67 + include ../../../scripts/Makefile.include 68 + 69 + # copy a bit from Linux kbuild 70 + 71 + ifeq ("$(origin V)", "command line") 72 + VERBOSE = $(V) 73 + endif 74 + ifndef VERBOSE 75 + VERBOSE = 0 76 + endif 77 + 78 + ifeq ($(srctree),) 79 + srctree := $(patsubst %/,%,$(dir $(CURDIR))) 80 + srctree := $(patsubst %/,%,$(dir $(srctree))) 81 + srctree := $(patsubst %/,%,$(dir $(srctree))) 82 + srctree := $(patsubst %/,%,$(dir $(srctree))) 83 + #$(info Determined 'srctree' to be $(srctree)) 84 + endif 85 + 86 + export prefix libdir src obj 87 + 88 + # Shell quotes 89 + plugin_dir_SQ = $(subst ','\'',$(plugin_dir)) 90 + 91 + CONFIG_INCLUDES = 92 + CONFIG_LIBS = 93 + CONFIG_FLAGS = 94 + 95 + OBJ = $@ 96 + N = 97 + 98 + INCLUDES = -I. -I.. -I $(srctree)/tools/include $(CONFIG_INCLUDES) 99 + 100 + # Set compile option CFLAGS 101 + ifdef EXTRA_CFLAGS 102 + CFLAGS := $(EXTRA_CFLAGS) 103 + else 104 + CFLAGS := -g -Wall 105 + endif 106 + 107 + # Append required CFLAGS 108 + override CFLAGS += -fPIC 109 + override CFLAGS += $(CONFIG_FLAGS) $(INCLUDES) $(PLUGIN_DIR_SQ) 110 + override CFLAGS += $(udis86-flags) -D_GNU_SOURCE 111 + 112 + ifeq ($(VERBOSE),1) 113 + Q = 114 + else 115 + Q = @ 116 + endif 117 + 118 + # Disable command line variables (CFLAGS) override from top 119 + # level Makefile (perf), otherwise build Makefile will get 120 + # the same command line setup. 121 + MAKEOVERRIDES= 122 + 123 + export srctree OUTPUT CC LD CFLAGS V 124 + 125 + build := -f $(srctree)/tools/build/Makefile.build dir=. obj 126 + 127 + DYNAMIC_LIST_FILE := $(OUTPUT)libtraceevent-dynamic-list 128 + 129 + PLUGINS = plugin_jbd2.so 130 + PLUGINS += plugin_hrtimer.so 131 + PLUGINS += plugin_kmem.so 132 + PLUGINS += plugin_kvm.so 133 + PLUGINS += plugin_mac80211.so 134 + PLUGINS += plugin_sched_switch.so 135 + PLUGINS += plugin_function.so 136 + PLUGINS += plugin_xen.so 137 + PLUGINS += plugin_scsi.so 138 + PLUGINS += plugin_cfg80211.so 139 + 140 + PLUGINS := $(addprefix $(OUTPUT),$(PLUGINS)) 141 + PLUGINS_IN := $(PLUGINS:.so=-in.o) 142 + 143 + plugins: $(PLUGINS) $(DYNAMIC_LIST_FILE) 144 + 145 + __plugin_obj = $(notdir $@) 146 + plugin_obj = $(__plugin_obj:-in.o=) 147 + 148 + $(PLUGINS_IN): force 149 + $(Q)$(MAKE) $(build)=$(plugin_obj) 150 + 151 + $(OUTPUT)libtraceevent-dynamic-list: $(PLUGINS) 152 + $(QUIET_GEN)$(call do_generate_dynamic_list_file, $(PLUGINS), $@) 153 + 154 + $(OUTPUT)%.so: $(OUTPUT)%-in.o 155 + $(QUIET_LINK)$(CC) $(CFLAGS) -shared $(LDFLAGS) -nostartfiles -o $@ $^ 156 + 157 + define update_dir 158 + (echo $1 > $@.tmp; \ 159 + if [ -r $@ ] && cmp -s $@ $@.tmp; then \ 160 + rm -f $@.tmp; \ 161 + else \ 162 + echo ' UPDATE $@'; \ 163 + mv -f $@.tmp $@; \ 164 + fi); 165 + endef 166 + 167 + tags: force 168 + $(RM) tags 169 + find . -name '*.[ch]' | xargs ctags --extra=+f --c-kinds=+px \ 170 + --regex-c++='/_PE\(([^,)]*).*/TEP_ERRNO__\1/' 171 + 172 + TAGS: force 173 + $(RM) TAGS 174 + find . -name '*.[ch]' | xargs etags \ 175 + --regex='/_PE(\([^,)]*\).*/TEP_ERRNO__\1/' 176 + 177 + define do_install_mkdir 178 + if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ 179 + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ 180 + fi 181 + endef 182 + 183 + define do_install 184 + $(call do_install_mkdir,$2); \ 185 + $(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2' 186 + endef 187 + 188 + define do_install_plugins 189 + for plugin in $1; do \ 190 + $(call do_install,$$plugin,$(plugin_dir_SQ)); \ 191 + done 192 + endef 193 + 194 + define do_generate_dynamic_list_file 195 + symbol_type=`$(NM) -u -D $1 | awk 'NF>1 {print $$1}' | \ 196 + xargs echo "U w W" | tr 'w ' 'W\n' | sort -u | xargs echo`;\ 197 + if [ "$$symbol_type" = "U W" ];then \ 198 + (echo '{'; \ 199 + $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ 200 + echo '};'; \ 201 + ) > $2; \ 202 + else \ 203 + (echo Either missing one of [$1] or bad version of $(NM)) 1>&2;\ 204 + fi 205 + endef 206 + 207 + install: $(PLUGINS) 208 + $(call QUIET_INSTALL, trace_plugins) \ 209 + $(call do_install_plugins, $(PLUGINS)) 210 + 211 + clean: 212 + $(call QUIET_CLEAN, trace_plugins) \ 213 + $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd; \ 214 + $(RM) $(OUTPUT)libtraceevent-dynamic-list \ 215 + $(RM) TRACEEVENT-CFLAGS tags TAGS; 216 + 217 + PHONY += force plugins 218 + force: 219 + 220 + # Declare the contents of the .PHONY variable as phony. We keep that 221 + # information in a variable so we can use it in if_changed and friends. 222 + .PHONY: $(PHONY)
+2 -2
tools/perf/Makefile.perf
··· 292 292 LIBTRACEEVENT = $(TE_PATH)libtraceevent.a 293 293 export LIBTRACEEVENT 294 294 295 - LIBTRACEEVENT_DYNAMIC_LIST = $(TE_PATH)libtraceevent-dynamic-list 295 + LIBTRACEEVENT_DYNAMIC_LIST = $(TE_PATH)plugins/libtraceevent-dynamic-list 296 296 297 297 # 298 298 # The static build has no dynsym table, so this does not work for ··· 737 737 $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins 738 738 739 739 $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins 740 - $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent-dynamic-list 740 + $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)plugins/libtraceevent-dynamic-list 741 741 742 742 $(LIBTRACEEVENT)-clean: 743 743 $(call QUIET_CLEAN, libtraceevent)