perf/core improvements and fixes
Subsystems (2)
From: Arnaldo Carvalho de Melo <[email protected]>
Hi Ingo,
Please consider pulling,
- Arnaldo
The following changes since commit e259514eef764a5286873618e34c560ecb6cff13:
perf/x86/amd: Enable northbridge performance counters on AMD family 15h (2013-02-16 09:37:27 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo
for you to fetch changes up to 0e0c6670a333aa884d11799f38a435bdf4c408ed:
perf report: Fix build with NO_NEWT=1 (2013-02-28 16:51:01 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
. Honor parallel jobs, fix from Borislav Petkov
. Introduce tools/lib/lk library, initially with just debugfs handling routines
shared with tools/vm, more to come, from Borislav Petkov
. Fix handling of -C (cpus) in perf record, from Jiri Olsa
. Add perf_event_attr entries in 'perf test' to check -C handling in 'record'
and 'stat', from Jiri Olsa.
. Check if -DFORTIFY_SOURCE=2 is allowed, fix from Marcin Slusarz.
. Fix build with NO_NEWT=1, from Michael Ellerman.
----------------------------------------------------------------
Borislav Petkov (6):
perf tools: Remove a write-only variable in the debugfs code perf tools: Honor parallel jobs
perf tools: Correct Makefile.include
perf tools: Introduce tools/lib/lk library
perf tools: Extract perf-specific stuff from debugfs.c tools/vm: Switch to liblk library
Jiri Olsa (5):
perf tests: Make attr script verbose friendly perf tests: Make attr script test event cpu perf tests: Add attr record -C cpu test perf tests: Add attr stat -C cpu test perf record: Fix -C option
Marcin Slusarz (1):
perf tools: check if -DFORTIFY_SOURCE=2 is allowed
Michael Ellerman (2):
perf annotate: Fix build with NO_NEWT=1
perf report: Fix build with NO_NEWT=1
liguang (1):
perf tools: Sort command-list.txt alphabetically
Makefile | 4 +-
tools/Makefile | 16 ++++++-
tools/lib/lk/Makefile | 35 +++++++++++++++
tools/{perf/util => lib/lk}/debugfs.c | 49 ++++++++------------
tools/lib/lk/debugfs.h | 29 ++++++++++++
tools/perf/MANIFEST | 1 +
tools/perf/Makefile | 42 +++++++++++++----
tools/perf/builtin-kvm.c | 2 +-
tools/perf/builtin-probe.c | 2 +-
tools/perf/builtin-record.c | 6 ++-
tools/perf/command-list.txt | 14 +++---
tools/perf/perf.c | 8 ++--
tools/perf/tests/attr.c | 9 +++-
tools/perf/tests/attr.py | 5 ++-
tools/perf/tests/attr/base-record | 1 +
tools/perf/tests/attr/base-stat | 1 +
tools/perf/tests/attr/test-record-C0 | 13 ++++++
tools/perf/tests/attr/test-stat-C0 | 9 ++++
tools/perf/tests/parse-events.c | 2 +-
tools/perf/util/debugfs.h | 12 -----
tools/perf/util/evlist.c | 2 +-
tools/perf/util/evsel.c | 2 +-
tools/perf/util/hist.h | 5 ++-
tools/perf/util/parse-events.c | 2 +-
tools/perf/util/probe-event.c | 2 +-
tools/perf/util/python-ext-sources | 1 -
tools/perf/util/setup.py | 3 +-
tools/perf/util/trace-event-info.c | 4 +-
tools/perf/util/util.c | 27 +++++++++++
tools/perf/util/util.h | 7 ++-
tools/scripts/Makefile.include | 6 ++-
tools/vm/Makefile | 17 +++++--
tools/vm/page-types.c | 85 +++--------------------------------
33 files changed, 253 insertions(+), 170 deletions(-)
create mode 100644 tools/lib/lk/Makefile
rename tools/{perf/util => lib/lk}/debugfs.c (68%)
create mode 100644 tools/lib/lk/debugfs.h
create mode 100644 tools/perf/tests/attr/test-record-C0
create mode 100644 tools/perf/tests/attr/test-stat-C0
delete mode 100644 tools/perf/util/debugfs.hPATCH 1/15 perf tools: check if -DFORTIFY_SOURCE=2 is allowed
From: Marcin Slusarz <[email protected]>
It seems gcc (4.7.2) defines _FORTIFY_SOURCE internally and becomes confused when it sees another definition in flags.
For me, build failed like this:
CHK glibc
Makefile:548: *** No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static. Stop.
and only with V=1 it printed:
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] <stdin>:1:0: note: this is the location of the previous definition
--- tools/perf/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
tools/perf/Makefile +7 -1
@@ -95,7 +95,7 @@ ifeq ("$(origin DEBUG)", "command line") PERF_DEBUG = $(DEBUG) endif ifndef PERF_DEBUG - CFLAGS_OPTIMIZE = -O6 -D_FORTIFY_SOURCE=2 + CFLAGS_OPTIMIZE = -O6 endif ifdef PARSER_DEBUG
@@ -180,6 +180,12 @@ ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-W CFLAGS := $(CFLAGS) -Wvolatile-register-var endif +ifndef PERF_DEBUG + ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) + CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2 + endif +endif + ### --- END CONFIGURATION SECTION --- ifeq ($(srctree),)
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 2/15 perf tools: Remove a write-only variable in the debugfs code
In reply to Arnaldo Carvalho de MeloFrom: Borislav Petkov <[email protected]>
debugfs_premounted is written-to only so drop it. This functionality is covered by debugfs_found now. Make it a bool while at it.
--- tools/perf/util/debugfs.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
tools/perf/util/debugfs.c +5 -8
@@ -5,7 +5,6 @@#include <linux/kernel.h> #include <sys/mount.h> -static int debugfs_premounted;char debugfs_mountpoint[PATH_MAX +1 ] ="/sys/kernel/debug" ;char tracing_events_path[PATH_MAX +1 ] ="/sys/kernel/debug/tracing/events" ;
@@ -15,7 +14,7 @@ static const char *debugfs_known_mountpoints[] = { 0, }; -static int debugfs_found; +static bool debugfs_found;/* find the path to the mounted debugfs */ const char *debugfs_find_mountpoint (void )
@@ -30,7 +29,7 @@ const char *debugfs_find_mountpoint(void) ptr = debugfs_known_mountpoints;while (*ptr) {if (debugfs_valid_mountpoint (*ptr) ==0 ) { - debugfs_found =1 ; + debugfs_found = true;strcpy (debugfs_mountpoint, *ptr);return debugfs_mountpoint; }
@@ -52,7 +51,7 @@ const char *debugfs_find_mountpoint(void)if (strcmp (type,"debugfs" ) !=0 )return NULL ; - debugfs_found =1 ; + debugfs_found = true;return debugfs_mountpoint; }
@@ -82,10 +81,8 @@ static void debugfs_set_tracing_events_path(const char *mountpoint)char *debugfs_mount (const char *mountpoint) {/* see if it's already mounted */ -if (debugfs_find_mountpoint ()) { - debugfs_premounted =1 ; +if (debugfs_find_mountpoint ()) goto out; - }/* if not mounted and no argument */ if (mountpoint ==NULL ) {
@@ -100,7 +97,7 @@ char *debugfs_mount(const char *mountpoint)return NULL ;/* save the mountpoint */ - debugfs_found =1 ; + debugfs_found = true;strncpy (debugfs_mountpoint, mountpoint,sizeof (debugfs_mountpoint)); out:debugfs_set_tracing_events_path (debugfs_mountpoint);
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 3/15 perf tools: Honor parallel jobs
In reply to Arnaldo Carvalho de MeloFrom: Borislav Petkov <[email protected]>
We need to hand down parallel build options like the internal make --jobserver-fds one so that parallel builds can also happen when building perf from the toplevel directory.
Make it so #1!
--- Makefile | 4 ++-- tools/scripts/Makefile.include | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Makefile +2 -2
@@ -1330,11 +1330,11 @@ kernelversion: # Clear a bunch of variables before executing the submake tools/: FORCE $(Q)mkdir -p $(objtree)/tools - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ tools/%: FORCE $(Q)mkdir -p $(objtree)/tools - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS= O=$(objtree) subdir=tools -C $(src)/tools/ $* + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(filter --j% -j,$(MAKEFLAGS))" O=$(objtree) subdir=tools -C $(src)/tools/ $* # Single targets # ---------------------------------------------------------------------------
tools/scripts/Makefile.include +1 -1
@@ -70,7 +70,7 @@ ifndef V QUIET_BISON = @echo ' ' BISON $@; descend = \ - @echo ' ' DESCEND $(1); \ + +@echo ' ' DESCEND $(1); \ mkdir -p $(OUTPUT)$(1) && \ $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2) endif
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 4/15 perf tools: Correct Makefile.include
In reply to Arnaldo Carvalho de MeloFrom: Borislav Petkov <[email protected]>
It looks at O= and adjusts the $(OUTPUT) variable based on what the output directory will be. However, when O is defined but empty, it wrongly becomes the user's $HOME dir which is not what we want. So check it is not empty before working with it further.
--- tools/scripts/Makefile.include | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/scripts/Makefile.include +3 -1
@@ -1,3 +1,4 @@ +ifneq ($(O),) ifeq ($(origin O), command line) dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),) ABSOLUTE_O := $(shell cd $(O) ; pwd)
@@ -7,9 +8,10 @@ ifeq ($(objtree),) objtree := $(O) endif endif +endif -ifneq ($(OUTPUT),) # check that the output directory actually exists +ifneq ($(OUTPUT),) OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) endif
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 5/15 perf tools: Sort command-list.txt alphabetically
In reply to Arnaldo Carvalho de MeloFrom: liguang <[email protected]>
--- tools/perf/command-list.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
tools/perf/command-list.txt +7 -7
@@ -10,17 +10,17 @@ perf-buildid-list mainporcelain common perf-diff mainporcelain common perf-evlist mainporcelain common perf-inject mainporcelain common +perf-kmem mainporcelain common +perf-kvm mainporcelain common perf-list mainporcelain common -perf-sched mainporcelain common +perf-lock mainporcelain common +perf-probe mainporcelain full perf-record mainporcelain common perf-report mainporcelain common +perf-sched mainporcelain common +perf-script mainporcelain common perf-stat mainporcelain common +perf-test mainporcelain common perf-timechart mainporcelain common perf-top mainporcelain common perf-trace mainporcelain common -perf-script mainporcelain common -perf-probe mainporcelain full -perf-kmem mainporcelain common -perf-lock mainporcelain common -perf-kvm mainporcelain common -perf-test mainporcelain common
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 6/15 perf tests: Make attr script verbose friendly
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Making the attr test script runner to pass proper verbose option. Also making single '-v' be more reader friendly and display just the test name.
Making the current output to be display for '-vv'.
--- tools/perf/tests/attr.c | 9 +++++++-- tools/perf/tests/attr.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-)
tools/perf/tests/attr.c +7 -2
@@ -147,10 +147,15 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,static int run_dir (const char *d,const char *perf) { +char v[] ="-vvvvv" ; +int vcnt =min (verbose, (int )sizeof (v) -1 );char cmd[3 *PATH_MAX ]; -snprintf (cmd,3 *PATH_MAX ,PYTHON " %s/attr.py -d %s/attr/ -p %s %s" , - d, d, perf, verbose ?"-v" :"" ); +if (verbose) + vcnt++; + +snprintf (cmd,3 *PATH_MAX ,PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s" , + d, d, perf, vcnt, v);return system (cmd); }
tools/perf/tests/attr.py +2 -2
@@ -121,7 +121,7 @@ class Test(object): parser = ConfigParser.SafeConfigParser() parser.read(path) - log.debug("running '%s'" % path) + log.warning("running '%s'" % path) self.path = path self.test_dir = options.test_dir
@@ -172,7 +172,7 @@ class Test(object): self.perf, self.command, tempdir, self.args) ret = os.WEXITSTATUS(os.system(cmd)) - log.warning(" running '%s' ret %d " % (cmd, ret)) + log.info(" '%s' ret %d " % (cmd, ret)) if ret != int(self.ret): raise Unsup(self)
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 7/15 perf tests: Make attr script test event cpu
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Make attr script to check for 'cpu' when testing event properties. This will allow us to check the '-C X' option for both record and stat commands.
--- tools/perf/tests/attr.py | 1 + tools/perf/tests/attr/base-record | 1 + tools/perf/tests/attr/base-stat | 1 + 3 files changed, 3 insertions(+)
tools/perf/tests/attr.py +1 -0
@@ -24,6 +24,7 @@ class Unsup(Exception): class Event(dict): terms = [ + 'cpu', 'flags', 'type', 'size',
tools/perf/tests/attr/base-record +1 -0
@@ -2,6 +2,7 @@ fd=1 group_fd=-1 flags=0 +cpu=* type=0|1 size=96 config=0
tools/perf/tests/attr/base-stat +1 -0
@@ -2,6 +2,7 @@ fd=1 group_fd=-1 flags=0 +cpu=* type=0 size=96 config=0
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 8/15 perf tests: Add attr record -C cpu test
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding test to validate perf_event_attr data for command:
'record -C 0'
--- tools/perf/tests/attr/test-record-C0 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tools/perf/tests/attr/test-record-C0
tools/perf/tests/attr/test-record-C0 new file +13 -0
@@ -0,0 +1,13 @@ +[config] +command = record +args = -C 0 kill >/dev/null 2>&1 + +[event:base-record] +cpu=0 + +# no enable on exec for CPU attached +enable_on_exec=0 + +# PERF_SAMPLE_IP | PERF_SAMPLE_TID PERF_SAMPLE_TIME | # PERF_SAMPLE_PERIOD +# + PERF_SAMPLE_CPU added by -C 0 +sample_type=391
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 9/15 perf tests: Add attr stat -C cpu test
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Adding test to validate perf_event_attr data for command:
'stat -C 0'
--- tools/perf/tests/attr/test-stat-C0 | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tools/perf/tests/attr/test-stat-C0
tools/perf/tests/attr/test-stat-C0 new file +9 -0
@@ -0,0 +1,9 @@ +[config] +command = stat +args = -e cycles -C 0 kill >/dev/null 2>&1 +ret = 1 + +[event:base-stat] +# events are enabled by default when attached to cpu +disabled=0 +enable_on_exec=0
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 10/15 perf record: Fix -C option
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Currently the -C option does not work for record command, because of the targets mismatch when synthesizing threads.
Fixing this by using proper target interface for the synthesize decision.
--- tools/perf/builtin-record.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/builtin-record.c +4 -2
@@ -573,13 +573,15 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) perf_event__synthesize_guest_os, tool); } -if (!opts->target.system_wide) +if (perf_target__has_task (&opts->target)) err =perf_event__synthesize_thread_map (tool, evsel_list->threads, process_synthesized_event, machine); -else +else if (perf_target__has_cpu (&opts->target)) err =perf_event__synthesize_threads (tool, process_synthesized_event, machine); +else /* command specified */ + err =0 ;if (err !=0 ) goto out_delete_session;
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 11/15 perf tools: Introduce tools/lib/lk library
In reply to Arnaldo Carvalho de MeloFrom: Borislav Petkov <[email protected]>
This introduces the tools/lib/lk library, that will gradually have the routines that now are used in tools/perf/ and other tools and that can be shared.
Start by carving out debugfs routines for general use.
--- tools/Makefile | 16 ++++- tools/lib/lk/Makefile | 35 +++++++++++ tools/lib/lk/debugfs.c | 116 +++++++++++++++++++++++++++++++++++++ tools/lib/lk/debugfs.h | 31 ++++++++++ tools/perf/MANIFEST | 1 + tools/perf/Makefile | 34 ++++++++--- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-probe.c | 2 +- tools/perf/perf.c | 2 +- tools/perf/tests/parse-events.c | 2 +- tools/perf/util/debugfs.c | 111 ----------------------------------- tools/perf/util/debugfs.h | 12 ---- tools/perf/util/evlist.c | 2 +- tools/perf/util/evsel.c | 2 +- tools/perf/util/parse-events.c | 2 +- tools/perf/util/probe-event.c | 2 +- tools/perf/util/python-ext-sources | 1 - tools/perf/util/setup.py | 3 +- tools/perf/util/trace-event-info.c | 2 +- 19 files changed, 235 insertions(+), 143 deletions(-) create mode 100644 tools/lib/lk/Makefile create mode 100644 tools/lib/lk/debugfs.c create mode 100644 tools/lib/lk/debugfs.h delete mode 100644 tools/perf/util/debugfs.c delete mode 100644 tools/perf/util/debugfs.h
tools/Makefile +14 -2
@@ -33,7 +33,13 @@ help: cpupower: FORCE $(call descend,power/$@) -firewire lguest perf usb virtio vm: FORCE +firewire guest usb virtio vm: FORCE + $(call descend,$@) + +liblk: FORCE + $(call descend,lib/lk) + +perf: liblk FORCE $(call descend,$@) selftests: FORCE
@@ -61,7 +67,13 @@ install: cpupower_install firewire_install lguest_install perf_install \ cpupower_clean: $(call descend,power/cpupower,clean) -firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean: +firewire_clean lguest_clean usb_clean virtio_clean vm_clean: + $(call descend,$(@:_clean=),clean) + +liblk_clean: + $(call descend,lib/lk,clean) + +perf_clean: liblk_clean $(call descend,$(@:_clean=),clean) selftests_clean:
tools/lib/lk/Makefile new file +35 -0
@@ -0,0 +1,35 @@ +include ../../scripts/Makefile.include + +# guard against environment variables +LIB_H= +LIB_OBJS= + +LIB_H += debugfs.h + +LIB_OBJS += $(OUTPUT)debugfs.o + +LIBFILE = liblk.a + +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC +EXTLIBS = -lpthread -lrt -lelf -lm +ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +ALL_LDFLAGS = $(LDFLAGS) + +RM = rm -f + +$(LIBFILE): $(LIB_OBJS) + $(QUIET_AR)$(RM) $@ && $(AR) rcs $(OUTPUT)$@ $(LIB_OBJS) + +$(LIB_OBJS): $(LIB_H) + +$(OUTPUT)%.o: %.c + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< +$(OUTPUT)%.s: %.c + $(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $< +$(OUTPUT)%.o: %.S + $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $< + +clean: + $(RM) $(LIB_OBJS) $(LIBFILE) + +.PHONY: clean
tools/lib/lk/debugfs.c new file +116 -0
116 lines not on this page · raw message
tools/lib/lk/debugfs.h new file +31 -0
@@ -0,0 +1,31 @@ +#ifndef __LK_DEBUGFS_H__ +#define __LK_DEBUGFS_H__ + +#define _STR (x) #x +#define STR (x) _STR(x) + +/* +* On most systems <limits.h> would have given us this, but not on some systems +* (e.g. GNU/Hurd). +*/ +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + +#ifndef DEBUGFS_MAGIC +#define DEBUGFS_MAGIC 0x64626720 +#endif + +#ifndef PERF_DEBUGFS_ENVIRONMENT +#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" +#endif + +const char *debugfs_find_mountpoint (void ); +int debugfs_valid_mountpoint (const char *debugfs); +char *debugfs_mount (const char *mountpoint); +void debugfs_set_path (const char *mountpoint); + +extern char debugfs_mountpoint[]; +extern char tracing_events_path[]; + +#endif /* __LK_DEBUGFS_H__ */
tools/perf/MANIFEST +1 -0
@@ -1,6 +1,7 @@ tools/perf tools/scripts tools/lib/traceevent +tools/lib/lk include/linux/const.h include/linux/perf_event.h include/linux/rbtree.h
tools/perf/Makefile +27 -7
@@ -215,6 +215,7 @@ BASIC_CFLAGS = \ -Iutil \ -I. \ -I$(TRACE_EVENT_DIR) \ + -I../lib/ \ -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE BASIC_LDFLAGS =
@@ -240,19 +241,28 @@ SCRIPT_SH += perf-archive.sh grep-libs = $(filter -l%,$(1)) strip-libs = $(filter-out -l%,$(1)) +LK_DIR = ../lib/lk/ TRACE_EVENT_DIR = ../lib/traceevent/ +LK_PATH=$(LK_DIR) + ifneq ($(OUTPUT),) TE_PATH=$(OUTPUT) +ifneq ($(subdir),) + LK_PATH=$(OUTPUT)$(LK_DIR) +else + LK_PATH=$(OUTPUT) +endif else TE_PATH=$(TRACE_EVENT_DIR) endif LIBTRACEEVENT = $(TE_PATH)libtraceevent.a -TE_LIB := -L$(TE_PATH) -ltraceevent - export LIBTRACEEVENT +LIBLK = $(LK_PATH)liblk.a +export LIBLK + # python extension build directories PYTHON_EXTBUILD := $(OUTPUT)python_ext_build/ PYTHON_EXTBUILD_LIB := $(PYTHON_EXTBUILD)lib/
@@ -355,7 +365,6 @@ LIB_H += util/cache.h LIB_H += util/callchain.h LIB_H += util/build-id.h LIB_H += util/debug.h -LIB_H += util/debugfs.h LIB_H += util/sysfs.h LIB_H += util/pmu.h LIB_H += util/event.h
@@ -416,7 +425,6 @@ LIB_OBJS += $(OUTPUT)util/annotate.o LIB_OBJS += $(OUTPUT)util/build-id.o LIB_OBJS += $(OUTPUT)util/config.o LIB_OBJS += $(OUTPUT)util/ctype.o -LIB_OBJS += $(OUTPUT)util/debugfs.o LIB_OBJS += $(OUTPUT)util/sysfs.o LIB_OBJS += $(OUTPUT)util/pmu.o LIB_OBJS += $(OUTPUT)util/environment.o
@@ -536,7 +544,7 @@ BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o BUILTIN_OBJS += $(OUTPUT)builtin-inject.o BUILTIN_OBJS += $(OUTPUT)tests/builtin-test.o -PERFLIBS = $(LIB_FILE) $(LIBTRACEEVENT) +PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT) # # Platform specific tweaks
@@ -1051,6 +1059,18 @@ $(LIBTRACEEVENT): $(LIBTRACEEVENT)-clean: $(QUIET_SUBDIR0)$(TRACE_EVENT_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean +# if subdir is set, we've been called from above so target has been built +# already +$(LIBLK): +ifeq ($(subdir),) + $(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) liblk.a +endif + +$(LIBLK)-clean: +ifeq ($(subdir),) + $(QUIET_SUBDIR0)$(LK_DIR) $(QUIET_SUBDIR1) O=$(OUTPUT) clean +endif + help: @echo 'Perf make targets:' @echo ' doc - make *all* documentation (see below)'
@@ -1171,7 +1191,7 @@ $(INSTALL_DOC_TARGETS): ### Cleaning rules -clean: $(LIBTRACEEVENT)-clean +clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean $(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS) $(RM) $(ALL_PROGRAMS) perf $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
@@ -1181,6 +1201,6 @@ clean: $(LIBTRACEEVENT)-clean $(RM) $(OUTPUT)util/*-flex* $(python-clean) -.PHONY: all install clean strip $(LIBTRACEEVENT) +.PHONY: all install clean strip $(LIBTRACEEVENT) $(LIBLK) .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope .FORCE-PERF-CFLAGS
tools/perf/builtin-kvm.c +1 -1
@@ -12,7 +12,7 @@#include "util/parse-options.h" #include "util/trace-event.h" #include "util/debug.h" -#include "util/debugfs.h" +#include <lk/debugfs.h> #include "util/tool.h" #include "util/stat.h"
tools/perf/builtin-probe.c +1 -1
@@ -37,7 +37,7 @@#include "util/strfilter.h" #include "util/symbol.h" #include "util/debug.h" -#include "util/debugfs.h" +#include <lk/debugfs.h> #include "util/parse-options.h" #include "util/probe-finder.h" #include "util/probe-event.h"
tools/perf/perf.c +1 -1
@@ -13,7 +13,7 @@#include "util/quote.h" #include "util/run-command.h" #include "util/parse-events.h" -#include "util/debugfs.h" +#include <lk/debugfs.h> #include <pthread.h> const char perf_usage_string[] =
tools/perf/tests/parse-events.c +1 -1
@@ -3,7 +3,7 @@#include "evsel.h" #include "evlist.h" #include "sysfs.h" -#include "debugfs.h" +#include <lk/debugfs.h> #include "tests.h" #include <linux/hw_breakpoint.h>
tools/perf/util/debugfs.c deleted +0 -111
111 lines not on this page · raw message
tools/perf/util/debugfs.h deleted +0 -12
@@ -1,12 +0,0 @@ -#ifndef __DEBUGFS_H__ -#define __DEBUGFS_H__ - -const char *debugfs_find_mountpoint (void ); -int debugfs_valid_mountpoint (const char *debugfs); -char *debugfs_mount (const char *mountpoint); -void debugfs_set_path (const char *mountpoint); - -extern char debugfs_mountpoint[]; -extern char tracing_events_path[]; - -#endif /* __DEBUGFS_H__ */
tools/perf/util/evlist.c +1 -1
@@ -7,7 +7,7 @@* Released under the GPL v2. (and only v2, not any later version) */ #include "util.h" -#include "debugfs.h" +#include <lk/debugfs.h> #include <poll.h> #include "cpumap.h" #include "thread_map.h"
tools/perf/util/evsel.c +1 -1
@@ -10,7 +10,7 @@#include <byteswap.h> #include <linux/bitops.h> #include "asm/bug.h" -#include "debugfs.h" +#include <lk/debugfs.h> #include "event-parse.h" #include "evsel.h" #include "evlist.h"
tools/perf/util/parse-events.c +1 -1
@@ -10,7 +10,7 @@#include "symbol.h" #include "cache.h" #include "header.h" -#include "debugfs.h" +#include <lk/debugfs.h> #include "parse-events-bison.h" #define YY_EXTRA_TYPE int#include "parse-events-flex.h"
tools/perf/util/probe-event.c +1 -1
@@ -40,7 +40,7 @@#include "color.h" #include "symbol.h" #include "thread.h" -#include "debugfs.h" +#include <lk/debugfs.h> #include "trace-event.h" /* For __maybe_unused */ #include "probe-event.h" #include "probe-finder.h"
tools/perf/util/python-ext-sources +0 -1
@@ -15,7 +15,6 @@ util/thread_map.c util/util.c util/xyarray.c util/cgroup.c -util/debugfs.c util/rblist.c util/strlist.c util/sysfs.c
tools/perf/util/setup.py +2 -1
@@ -24,6 +24,7 @@ cflags += getenv('CFLAGS', '').split() build_lib = getenv('PYTHON_EXTBUILD_LIB') build_tmp = getenv('PYTHON_EXTBUILD_TMP') libtraceevent = getenv('LIBTRACEEVENT') +liblk = getenv('LIBLK') ext_sources = [f.strip() for f in file('util/python-ext-sources') if len(f.strip()) > 0 and f[0] != '#']
@@ -32,7 +33,7 @@ perf = Extension('perf', sources = ext_sources, include_dirs = ['util/include'], extra_compile_args = cflags, - extra_objects = [libtraceevent], + extra_objects = [libtraceevent, liblk], ) setup(name='perf',
tools/perf/util/trace-event-info.c +1 -1
@@ -38,7 +38,7 @@#include "../perf.h" #include "trace-event.h" -#include "debugfs.h" +#include <lk/debugfs.h> #include "evsel.h" #define VERSION "0.5"
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 12/15 perf tools: Extract perf-specific stuff from debugfs.c
In reply to Arnaldo Carvalho de MeloFrom: Borislav Petkov <[email protected]>
Move them to util.c and simplify code a bit.
--- tools/lib/lk/debugfs.c | 15 --------------- tools/lib/lk/debugfs.h | 2 -- tools/perf/perf.c | 6 +++--- tools/perf/util/trace-event-info.c | 2 +- tools/perf/util/util.c | 27 +++++++++++++++++++++++++++ tools/perf/util/util.h | 7 +++++-- 6 files changed, 36 insertions(+), 23 deletions(-)
tools/lib/lk/debugfs.c +0 -15
@@ -11,7 +11,6 @@#include "debugfs.h" char debugfs_mountpoint[PATH_MAX +1 ] ="/sys/kernel/debug" ; -char tracing_events_path[PATH_MAX +1 ] ="/sys/kernel/debug/tracing/events" ;static const char *const debugfs_known_mountpoints[] = {"/sys/kernel/debug/" ,
@@ -75,14 +74,7 @@ int debugfs_valid_mountpoint(const char *debugfs)return 0 ; } -static void debugfs_set_tracing_events_path (const char *mountpoint) -{ -snprintf (tracing_events_path,sizeof (tracing_events_path),"%s/%s" , - mountpoint,"tracing/events" ); -} -/* mount the debugfs somewhere if it's not mounted */ -char *debugfs_mount (const char *mountpoint) {/* see if it's already mounted */
@@ -105,12 +97,5 @@ char *debugfs_mount(const char *mountpoint) debugfs_found = true;strncpy (debugfs_mountpoint, mountpoint,sizeof (debugfs_mountpoint)); out: -debugfs_set_tracing_events_path (debugfs_mountpoint);return debugfs_mountpoint; } - -void debugfs_set_path (const char *mountpoint) -{ -snprintf (debugfs_mountpoint,sizeof (debugfs_mountpoint),"%s" , mountpoint); -debugfs_set_tracing_events_path (mountpoint); -}
tools/lib/lk/debugfs.h +0 -2
@@ -23,9 +23,7 @@const char *debugfs_find_mountpoint (void );int debugfs_valid_mountpoint (const char *debugfs);char *debugfs_mount (const char *mountpoint); -void debugfs_set_path (const char *mountpoint);extern char debugfs_mountpoint[]; -extern char tracing_events_path[];#endif /* __LK_DEBUGFS_H__ */
tools/perf/perf.c +3 -3
@@ -193,13 +193,13 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)fprintf (stderr,"No directory given for --debugfs-dir.\n" );usage (perf_usage_string); } -debugfs_set_path ((*argv)[1 ]); +perf_debugfs_set_path ((*argv)[1 ]);if (envchanged) *envchanged =1 ; (*argv)++; (*argc)--; }else if (!prefixcmp (cmd,CMD_DEBUGFS_DIR )) { -debugfs_set_path (cmd +strlen (CMD_DEBUGFS_DIR )); +perf_debugfs_set_path (cmd +strlen (CMD_DEBUGFS_DIR ));fprintf (stderr,"dir: %s\n" , debugfs_mountpoint);if (envchanged) *envchanged =1 ;
@@ -461,7 +461,7 @@ int main(int argc, const char **argv)if (!cmd) cmd ="perf-help" ;/* get debugfs mount point from /proc/mounts */ -debugfs_mount (NULL ); +perf_debugfs_mount (NULL );/* * "perf-xxxx" is the same as "perf xxxx", but we obviously: *
tools/perf/util/trace-event-info.c +1 -1
@@ -80,7 +80,7 @@ static void *malloc_or_die(unsigned int size)static const char *find_debugfs (void ) { -const char *path =debugfs_mount (NULL ); +const char *path =perf_debugfs_mount (NULL );if (!path)die ("Your kernel not support debugfs filesystem" );
tools/perf/util/util.c +27 -0
@@ -17,6 +17,8 @@ bool test_attr__enabled;bool perf_host = true;bool perf_guest = false; +char tracing_events_path[PATH_MAX +1 ] ="/sys/kernel/debug/tracing/events" ; +void event_attr_init (struct perf_event_attr *attr) {if (!perf_host)
@@ -242,3 +244,28 @@ void get_term_dimensions(struct winsize *ws) ws->ws_row =25 ; ws->ws_col =80 ; } + +static void set_tracing_events_path (const char *mountpoint) +{ +snprintf (tracing_events_path,sizeof (tracing_events_path),"%s/%s" , + mountpoint,"tracing/events" ); +} + +const char *perf_debugfs_mount (const char *mountpoint) +{ +const char *mnt; + + mnt =debugfs_mount (mountpoint); +if (!mnt) +return NULL ; + +set_tracing_events_path (mnt); + +return mnt; +} + +void perf_debugfs_set_path (const char *mntpt) +{ +snprintf (debugfs_mountpoint,strlen (debugfs_mountpoint),"%s" , mntpt); +set_tracing_events_path (mntpt); +}
tools/perf/util/util.h +5 -2
@@ -73,10 +73,14 @@#include <linux/magic.h> #include "types.h" #include <sys/ttydefaults.h> +#include <lk/debugfs.h> extern const char *graph_line;extern const char *graph_dotted_line;extern char buildid_dir[]; +extern char tracing_events_path[]; +extern void perf_debugfs_set_path (const char *mountpoint); +const char *perf_debugfs_mount (const char *mountpoint);/* On most systems <limits.h> would have given us this, but * not on some systems (e.g. GNU/Hurd).
@@ -274,5 +278,4 @@ extern unsigned int page_size;struct winsize ;void get_term_dimensions (struct winsize *ws); - -#endif +#endif /* GIT_COMPAT_UTIL_H */
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 13/15 tools/vm: Switch to liblk library
In reply to Arnaldo Carvalho de MeloFrom: Borislav Petkov <[email protected]>
page-flags.c had some older version of debugfs_mount copied from perf so convert it to using the version in the tools library.
--- tools/vm/Makefile | 17 +++++++++-- tools/vm/page-types.c | 85 +++++---------------------------------------------- 2 files changed, 21 insertions(+), 81 deletions(-)
tools/vm/Makefile +14 -3
@@ -1,11 +1,22 @@ # Makefile for vm tools +# +TARGETS=page-types slabinfo + +LK_DIR = ../lib/lk +LIBLK = $(LK_DIR)/liblk.a CC = $(CROSS_COMPILE)gcc -CFLAGS = -Wall -Wextra +CFLAGS = -Wall -Wextra -I../lib/ +LDFLAGS = $(LIBLK) + +$(TARGETS): liblk + +liblk: + make -C $(LK_DIR) -all: page-types slabinfo %: %.c - $(CC) $(CFLAGS) -o $@ $^ + $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) clean: $(RM) page-types slabinfo + make -C ../lib/lk clean
tools/vm/page-types.c +7 -78
109 lines not on this page · raw message
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 14/15 perf annotate: Fix build with NO_NEWT=1
In reply to Arnaldo Carvalho de MeloFrom: Michael Ellerman <[email protected]>
Commit 18c9e5c "Make it to be able to skip unannotatable symbols" broke the build with NO_NEWT=1:
CC builtin-annotate.obuiltin-annotate.c: In function 'hists__find_annotations':
builtin-annotate.c:161:4: error: duplicate case value builtin-annotate.c:154:4: error: previously used here
make: *** [builtin-annotate.o] Error 1
This is because without NEWT support K_LEFT is #defined to -1 in utils/hist.h
Fix it by shifting the K_LEFT/K_RIGHT #defines out of the likely range of error values.
--- tools/perf/util/hist.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/hist.h +2 -2
@@ -208,8 +208,8 @@ static inline int script_browse(const char *script_opt __maybe_unused) return 0; } -#define K_LEFT -1 -#define K_RIGHT -2 +#define K_LEFT -1000 +#define K_RIGHT -2000#endif #ifdef GTK2_SUPPORT
Signature · 1 line
1.8.1.1.361.gec3ae6e
PATCH 15/15 perf report: Fix build with NO_NEWT=1
In reply to Arnaldo Carvalho de MeloFrom: Michael Ellerman <[email protected]>
Commit ad0de09 "Enable the runtime switching of perf data file" broke the build with NO_NEWT=1:
CC builtin-report.obuiltin-report.c: In function '__cmd_report':
builtin-report.c:479:15: error: 'K_SWITCH_INPUT_DATA' undeclared (first use in this function) builtin-report.c:479:15: note: each undeclared identifier is reported only once for each function it appears in builtin-report.c: In function 'cmd_report':
builtin-report.c:823:13: error: 'K_SWITCH_INPUT_DATA' undeclared (first use in this function)
make: *** [builtin-report.o] Error 1
Fix it by adding a dummy definition of K_SWITCH_INPUT_DATA.
--- tools/perf/util/hist.h | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/hist.h +1 -0
@@ -210,6 +210,7 @@ static inline int script_browse(const char *script_opt __maybe_unused)#define K_LEFT -1000#define K_RIGHT -2000 +#define K_SWITCH_INPUT_DATA -3000#endif #ifdef GTK2_SUPPORT
Signature · 1 line
1.8.1.1.361.gec3ae6e