Namhyung Kim [Wed, 11 Sep 2013 05:09:33 +0000 (14:09 +0900)]
perf tools: Fix srcline sort key behavior
Currently the srcline sort key compares ip rather than srcline info. I
guess this was due to a performance reason to run external addr2line
utility. Now we have implemented the functionality inside, use the
srcline info when comparing hist entries.
Also constantly print "??:0" string for unknown srcline rather than
printing ip.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1378876173-13363-10-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tools: Implement addr2line directly using libbfd
When the srcline sort key is used , the external addr2line utility needs
to be run for each hist entry to get the srcline info. This can consume
quite a time if one has a huge perf.data file.
So rather than executing the external utility, implement it internally
and just call it. We can do it since we've linked with libbfd already.
Signed-off-by: Roberto Agostino Vitillo <ravitillo@lbl.gov> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1378876173-13363-9-git-send-email-namhyung@kernel.org
[ Use a2l_data struct instead of static globals ] Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Namhyung Kim [Wed, 11 Sep 2013 05:09:28 +0000 (14:09 +0900)]
perf annotate: Factor out get/free_srcline()
Currently external addr2line tool is used for srcline sort key and
annotate with srcline info. Separate the common code to prepare
upcoming enhancements.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1378876173-13363-5-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Namhyung Kim [Wed, 11 Sep 2013 05:09:26 +0000 (14:09 +0900)]
perf annotate: Reuse path from the result of addr2line
In the symbol__get_source_line(), path and src_line->path will have same
value, but they were allocated separately, and leaks one. Just share
path to src_line->path.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1378876173-13363-3-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Namhyung Kim [Fri, 13 Sep 2013 06:27:43 +0000 (15:27 +0900)]
perf tools: Separate out GTK codes to libperf-gtk.so
Separate out GTK codes to a shared object called libperf-gtk.so. This
time only GTK codes are built with -fPIC and libperf remains as is. Now
run GTK hist and annotation browser using libdl.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> Reviewed-by: Pekka Enberg <penberg@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1379053663-13706-1-git-send-email-namhyung@kernel.org
[ Fix it up wrt Ingo's tools/perf build speedups ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
perf symbols: Add new option --ignore-vmlinux for perf top
Running "perf top" on a machine with possibly invalid or non-matching
vmlinux at the various places results in no symbol resolving despite
/proc/kallsyms being present and valid.
Add a new option --ignore-vmlinux to explicitly indicate that we do not
want to use these kernels and just use what we have (kallsyms).
Jiri Olsa [Sun, 1 Sep 2013 10:36:13 +0000 (12:36 +0200)]
perf tools: Add possibility to specify mmap size
Adding possibility to specify mmap size via -m/--mmap-pages
by appending unit size character (B/K/M/G) to the
number, like:
$ perf record -m 8K ls
$ perf record -m 2M ls
The size is rounded up appropriately to follow perf
mmap restrictions.
If no unit is specified the number provides pages as
of now, like:
$ perf record -m 8 ls
Signed-off-by: Jiri Olsa <jolsa@redhat.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1378031796-17892-3-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
While perf-lock currently reports both the total wait time and the
number of contentions, it doesn't explicitly show the average wait time.
Having this value immediately in the report can be quite useful when
looking into performance issues.
Furthermore, allowing report to sort by averages is another handy
feature to have - and thus do not only print the value, but add it to
the lock_stat structure.
This function should be straightforward, and we can remove some trivial
logic by moving the functionality of read_events() into __cmd_report() -
thus allowing a new session to be properly deleted.
Since the 'info' subcommand also needs to process the recorded events,
add a 'display_info' flag to differentiate between report and info
commands.
Furthermore, this patch also calls perf_session__has_traces(), making
sure that we don't compare apples and oranges, fixing a segfault when
using an perf.data file generated by a different subcommand. ie:
./perf mem record sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.017 MB perf.data (~724 samples) ]
perf lock: Return proper code in report_lock_*_event
The report_lock_*_event() functions return -1 when lock_stat_findnew(),
thread_stat_findnew() or get_seq() return NULL. These functions only
return this value when failing to allocate memory, this return -ENOMEM
instead.
_filedir is defined in the bash-completion package, but there is no need
to depend on it. Instead, call complete with multiple -o arguments
before the -F argument like in git.git's completion script.
limits the locations in which to look for the perf program. Moreover,
it depends on the bash-completion package to be installed. Replace it
with a call to `type perf`.
David Ahern [Wed, 4 Sep 2013 18:37:43 +0000 (12:37 -0600)]
perf trace: Add option to show full timestamp
Current timestamp shown for output is time relative to firt sample. This
patch adds an option to show the absolute perf_clock timestamp which is
useful when comparing output across commands (e.g., perf-trace to
perf-script).
Signed-off-by: David Ahern <dsahern@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1378319865-55695-1-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Taking into account the fact that the SOCK_ types can be overriden for
ABI reasons on MIPS and also masking and interpreting the socket flags
(NONBLOCK and CLOEXEC), printing whatever is left in the flags bits
as an hex number, or'ed.
Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-cbn57082gq9v0sbsd67edwjq@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
So that we can have generic formatters that act upon specific
parameters.
Start using them with a simple string table that assumes entries
will be indexes to a string table, like with the 'which' parm
for the set and getitimer syscalls
Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-r0dqhapr8j6150v1wctgg340@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Ingo Molnar [Mon, 7 Oct 2013 15:51:29 +0000 (17:51 +0200)]
tools/perf/build: Pass through LDFLAGS to feature tests
David Ahern reported that when passing in LDFLAGS=-static then
the feature checks still succeed - causing build failures down
the line because the static libraries are missing.
Solve this by passing through LDFLAGS to the feature-check
Makefile.
Reported-by: David Ahern <dsahern@gmail.com> Tested-by: David Ahern <dsahern@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/20131007155129.GA1066@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar [Mon, 7 Oct 2013 11:27:23 +0000 (13:27 +0200)]
tools/perf/build: Harmonize the style of the feature testcases
The various testcases used different styles, which was not really
visible as long as they hid in feature-tests.mak. Now that they
are out in the open make them prettier.
( Also delete the leftover, empty feature-tests.mak file. )
Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-drDWk8xltndjdsespzjbhu6w@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
The build might even fail, if a target depends on other targets:
hubble:~/tip/tools/perf> make O=/tmp/perf perf.o
...
perf.c: In function ‘handle_options’:
perf.c:155:21: error: ‘PERF_HTML_PATH’ undeclared (first use in this function)
The correct way to invoke such targets is:
hubble:~/tip/tools/perf> make O=/tmp/perf /tmp/perf/perf.o
BUILD: Doing 'make -j8' parallel build
GEN /tmp/perf/common-cmds.h
CC /tmp/perf/perf.o
But that's unnecessary typing and it's also easy to mistakenly build into the
source directory.
To fix this remove the generic suffix rules and add redirection to $(OUTPUT)
for the most popular .o targets.
Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-mk0oiukmhgSbrll6chrPkkqr@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar [Thu, 3 Oct 2013 12:32:10 +0000 (14:32 +0200)]
tools/perf/build: Pass through all targets to Makefile.perf
Jiri reported that 'make .o' stopped working:
> [jolsa@krava perf]$ make -f Makefile perf.o
> cc -c -o perf.o perf.c
> In file included from builtin.h:4:0,
> from perf.c:9:
> util/util.h:74:24: fatal error: lk/debugfs.h: No such file or directory
> compilation terminated.
> make: *** [perf.o] Error 1
This is due to GNU make having built-in rules for popular targets such
as *.o. Clear them out so that all targets as passed through to Makefile.perf.
Reported-by: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Link: http://lkml.kernel.org/n/tip-5wkuvmlaaxtfgepKcvRij8sh@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar [Wed, 2 Oct 2013 09:49:08 +0000 (11:49 +0200)]
tools/perf/build: Flip Makefile.parallel and Makefile.perf
To make it more apparent that there is not change in functionality we introduced
Makefile.parallel separately and now flip it with the main Makefile, which
moves into Makefile.perf.
On GNU make achieving this is not particularly easy, it requires a separate
makefile, which then invokes the main Makefile.
( Note: this patch adds Makefile.parallel to show the concept - the two
makefiles will be flipped in the next patch to avoid having to specify -f
to get parallelism in the default build. )
Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-dvBjwqiTyzrufzkz8oanhpf9@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar [Wed, 2 Oct 2013 08:01:42 +0000 (10:01 +0200)]
tools/perf/build: Improve printout-of auto-detected features
Change the print-out of auto-detected features by making sure that
repeat invocations of 'make' when all features are successfully
detected do not produce the (rather lengthy) autodetection printout.
( When one or more features are missing then we still print out the
feature detection table, to make sure people are aware of the
resulting limitations. )
Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-qd8sMsshcjomxqx9bQcufmaa@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar [Wed, 2 Oct 2013 04:51:27 +0000 (06:51 +0200)]
tools/perf: Fix double/triple-build of the feature detection logic during 'make install' et al
Linus reported the following perf build system bug:
'Another annoyance during that make was that "make install" seems to
want to re-make the thing I just built. That's absolutely horrible, [...]'
The thing that got re-built were 'only' the (numerous) feature checks,
not the whole project - but still it was mighty annoying as the feature
checks took 9+ seconds even on reasonably fast boxes.
Even with the autodep patches where feature detection is much faster
it wastes resources, wastes screen real estate and confuses users if
we execute feature detection twice.
There were two sources for these unnecessary re-builds of the feature
checks:
- Unnecessary nested invocations of $(MAKE), apparently to be able
to do conditional compilation dependent on documentation tools
presence. Use straight dependencies instead, with no nesting.
- A direct invocation of $(MAKE) to rebuild the PERF-VERSION-FILE.
This is apparently done to be able to include it into the
Makefile:
-include $(OUTPUT)PERF-VERSION-FILE
but that's entirely pointless for two reasons: 1) the version file
gets regenerated by the initial build pass anyway, 2) including it
is futile, given its contents:
#define PERF_VERSION "3.12.rc3.g8510c7"
'make' will interpret that as a comment line...
So just remove this part of the doc-generation logic.
With these things fixed a 'make install' now rebuilds only what is needed.
A repeated 'make install' on an already built tree is super fast now,
it finishes in under 0.3 seconds:
#
# After the patch:
#
$ time make install
...
real 0m0.280s
user 0m0.162s
sys 0m0.054s
Prior all the autodep changes and prior this fix, a repeat 'make install'
took 24.1 seconds (!) on the same system:
#
# Before the patches:
#
$ time make install
...
real 0m24.109s
user 0m21.171s
sys 0m2.449s
Which almost entirely was caused by fixable build system fat.
We are now literally ~86 times faster.
A fresh rebuild and install now takes just 11.4 seconds:
#
# After the patch:
#
$ make clean
$ time make -j16 install
...
real 0m11.457s
user 1m43.411s
sys 0m7.610s
Without the patches it took 27.8 seconds:
#
# Before the patches:
#
$ make clean
$ time make -j16 install
...
real 0m27.801s
user 1m59.242s
sys 0m9.749s
So even in the complete rebuild case we are now ~2.5 times faster.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-x4qjnxjGrgxpribq8sdakfTp@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar [Tue, 1 Oct 2013 15:17:22 +0000 (17:17 +0200)]
tools/perf/build: Speed up the final link
libtraceevent.a and liblk.a rules have always-missed dependencies,
which causes python.so to be relinked at every build attempt - even
if none of the affected code changes.
This slows down re-builds unnecessarily, by adding more than a second
to the build time:
comet:~/tip/tools/perf> time make
...
SUBDIR /fast/mingo/tip/tools/lib/lk/
make[1]: `liblk.a' is up to date.
SUBDIR /fast/mingo/tip/tools/lib/traceevent/
LINK perf
GEN python/perf.so
real 0m1.701s
user 0m1.338s
sys 0m0.301s
Add the (trivial) dependencies to not force a re-link.
This speeds up an empty re-build enormously:
comet:~/tip/tools/perf> time make
...
real 0m0.207s
user 0m0.134s
sys 0m0.028s
[ This adds some coupling between the build dependencies of
libtraceevent and liblk - but until those stay relatively
simple this should not be an issue. ]
Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-wvmlrurufuk6mo1ovtNigguT@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar [Tue, 1 Oct 2013 14:28:09 +0000 (16:28 +0200)]
tools/perf/build: Speed up git-version test on re-make
util/PERF-VERSION-GEN is currently executed on every build attempt,
and this script can take a lot of time on trees that are at a
significant git-distance from Linus's tree:
$ time util/PERF-VERSION-GEN
real 0m4.343s
user 0m4.176s
sys 0m0.140s
It also takes a lot of time if the Git repository is network attached, etc.,
because the commands it uses:
has to count commits from the nearest tag and thus has to access (and
decompress) every git commit blob on the relevant version path.
Even on Linus's tree it takes 0.28 seconds on a fast box to count all the
commits and get the git version string:
$ time util/PERF-VERSION-GEN
real 0m0.279s
user 0m0.247s
sys 0m0.025s
But the version string only has to be regenerated if the git repository's
head commit changes. So add a dependency of ../../.git/HEAD and touch
the file every time it's regenerated, so that Make's build rules can
pick it up and cache the result:
make: `PERF-VERSION-FILE' is up to date.
real 0m0.184s
user 0m0.117s
sys 0m0.026s
Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/n/tip-wvmlrurufuk6mo1ovtNigguT@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>