Ingo Molnar [Sun, 22 Mar 2015 09:54:44 +0000 (10:54 +0100)]
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
User visible changes:
- Bash completion for subcommands (Yunlong Song)
- Allow annotating entries in callchains in the hists browser (top/report).
TODO: give some visual cue to what entries in callchains have samples and thus
can be annotated and/or allow showing the source code for functions without
samples (Arnaldo Carvalho de Melo)
- Don't allow empty argument for '-t' in perf report, fixing segfault (Wang Nan)
Infrastructure:
- Prep work for moving the perf feature tests build system to tools/build (Jiri Olsa)
- Fix perf-read-vdsox32 not building and lib64 install dir (H.J. Lu)
- ARM64: fix building error and eh/debug frame offset cache fixes (Wang Nan)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Jiri Olsa [Tue, 17 Feb 2015 16:29:57 +0000 (17:29 +0100)]
perf tools: Use kmod_path__parse for machine__new_dso
Using kmod_path__parse to get the module name and update the dso short
name within machine__new_dso function.
This way it's done only first time when dso is created, unlike the
current way when we update it all the time we process memory map of the
kernel module.
Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-8gjmt1ggf5ls1xkk7qi2ko4k@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Jiri Olsa [Thu, 12 Feb 2015 21:10:52 +0000 (22:10 +0100)]
perf tools: Add machine__module_dso function
Separate the dso object addition and update when adding new kernel
module.
Currently we update dso's symtab_type any time we find it in the list,
because we can't distinguish between new and found dso from
__dsos__findnew function.
Adding machine__module_dso that separates finding and adding new dso
objects, so there's no superfluous update of dso.
Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-uvqgs5tyq4wssnq6fm43hgvk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
parse kernel module @path and updates @m argument like:
@comp - true if @path contains supported compression suffix,
false otherwise
@kmod - true if @path contains '.ko' suffix in right position,
false otherwise
@name - if (@alloc_name && @kmod) is true, it contains strdup-ed base name
of the kernel module without suffixes, otherwise strudup-ed
base name of @path
@ext - if (@alloc_ext && @comp) is true, it contains strdup-ed string
the compression suffix
It returns 0 if there's no strdup error, -ENOMEM otherwise.
Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-9t6eqg8j610r94l743hkntiv@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
David Ahern [Thu, 19 Mar 2015 18:36:21 +0000 (12:36 -0600)]
tools lib traceevent: Add destructor for format_field
Move the calls that frees the resources allocated for a struct format_field to
a separate routine.
Signed-off-by: David Ahern <dsahern@gmail.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/1426790181-19118-1-git-send-email-dsahern@gmail.com
[ Split this part from a larger patch, added pevent_ prefix as requested by Steven ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
perf hists browser: Indicate which callchain entries are annotated
Now that we can annotate entries in a callchain, show which ones have an
associated symbol and samples, by adding a right arrow just before the
symbol name when in verbose mode.
To toggle verbose mode press 'V'.
Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-d2rf1p3h5gdp7hdl2gf2bozl@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
David Ahern [Thu, 19 Mar 2015 18:23:03 +0000 (12:23 -0600)]
perf trace: Fix summary_only option
The intent of the -s/--summary-only option is to just show a summary of
the system calls and statistics without any of the individual events.
Commit e596663ebb2 broke that by showing the interrupted lines:
He Kuang [Fri, 20 Mar 2015 01:56:56 +0000 (09:56 +0800)]
perf probe: Fix failure to add multiple probes without debuginfo
Perf tries to find probe function addresses from map when debuginfo
could not be found.
To the first added function, the value of ref_reloc_sym was set in
maps__set_kallsyms_ref_reloc_sym() and can be obtained from
host_machine->kmaps->maps. After that, new maps are added to
host_machine->kmaps->maps in dso__load_kcore(), all these new added maps
do not have a valid ref_reloc_sym.
When adding a second function, get_target_map() may get a map without
valid ref_reloc_sym, and raise the error "Relocated base symbol is not
found".
Fix this by using kernel_get_ref_reloc_sym() to get ref_reloc_sym.
This problem can be reproduced as following:
$ perf probe --add='sys_write' --add='sys_open'
Relocated base symbol is not found!
Error: Failed to add events.
After this patch:
$ perf probe --add='sys_write' --add='sys_open'
Added new event:
probe:sys_write (on sys_write)
You can now use it in all perf tools, such as:
perf record -e probe:sys_write -aR sleep 1
Added new event:
probe:sys_open (on sys_open)
You can now use it in all perf tools, such as:
perf record -e probe:sys_open -aR sleep 1
Signed-off-by: He Kuang <hekuang@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426816616-2394-1-git-send-email-hekuang@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
$ git status
nothing to commit, working directory clean
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426821638-11227-3-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Fri, 20 Mar 2015 03:20:37 +0000 (11:20 +0800)]
perf build: Use FEATURE-DUMP instead of PERF-FEATURES in the .gitignore file
Since commit 4ae61202b31c ("perf build: Rename PERF-FEATURES into
FEATURE-DUMP") renames PERF-FEATURES into FEATURE-DUMP, the .gitignore
file should also do this thing for consistency.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426821638-11227-2-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Wang Nan [Fri, 20 Mar 2015 02:57:52 +0000 (02:57 +0000)]
perf tools: Don't allow empty argument for field-separator
Both 'perf diff' and 'perf mem' have 'field-separator' option, which
causes segfault if passed with empty string. This patch uses previously
introduced 'OPT_STRING_NOEMPTY' option macro to prevent fault.
Signed-off-by: Wang Nan <wangnan0@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: pi3orama@163.com Cc: Namhyung Kim <namhyung@kernel.org> Cc: Zefan Li <lizefan@huawei.com> Link: http://lkml.kernel.org/r/1426820272-23302-1-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Milos Vyletel [Fri, 20 Mar 2015 10:37:25 +0000 (11:37 +0100)]
perf tools: Fix race in build_id_cache__add_s()
int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
const char *name, bool is_kallsyms, bool is_vdso)
{
...
if (access(filename, F_OK)) {
^--------------------------------------------------------- [1]
if (is_kallsyms) {
if (copyfile("/proc/kallsyms", filename))
goto out_free;
} else if (link(realname, filename) && copyfile(name, filename))
^-----------------------------^------------- [2]
\------------ [3]
goto out_free;
}
...
When multiple instances of perf record get to [1] at more or less same time and
run access() one or more may get failure because the file does not exist yet
(since the first instance did not have chance to link it yet).
At this point the race moves to link() at [2] where first thread to get
there links file and goes on but second one gets -EEXIST so it runs
copyfile [3] which truncates the file.
reproducer:
rm -rf /root/.debug
for cpu in $(awk '/processor/ {print $3}' /proc/cpuinfo); do
perf record -a -v -T -F 1000 -C $cpu \
-o perf-${cpu}.data sleep 5 2> /dev/null &
done
wait
and simply search for empty files by:
find /lib/modules/`uname -r`/kernel/* -size 0
Signed-off-by: Milos Vyletel <milos@redhat.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1426847846-11112-1-git-send-email-milos@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Wang Nan [Fri, 13 Mar 2015 12:51:54 +0000 (12:51 +0000)]
perf report: Don't allow empty argument for '-t'.
Without this patch, perf report cause segfault if pass "" as '-t':
$ perf report -t ""
# To display the perf.data header info, please use --header/--header-only options.
#
# Samples: 37 of event 'syscalls:sys_enter_write'
# Event count (approx.): 37
#
# Children SelfCommand Shared Object Symbol
Segmentation fault
Since -t is used to add field-separator for generate table, -t "" is
actually meanless. This patch defines a new OPT_STRING_NOEMPTY() option
generator to ensure user never pass empty string to that option.
Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: pi3orama@163.com Cc: Jiri Olsa <jolsa@kernel.org> Cc: Zefan Li <lizefan@huawei.com> Link: http://lkml.kernel.org/r/1426251114-198991-1-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Wang Nan [Fri, 13 Mar 2015 07:02:56 +0000 (15:02 +0800)]
perf callchain: Separate eh/debug frame offset cache.
Commit f1f13af99a90 ("perf callchain: Cache eh/debug frame offset for
dwarf unwind") introduces a cache for .debug_frame and .eh_frame_hdr.
Unfortunately, it makes them share a same cache (dso->frame_offset).
Which causes unwind failure on ARM:
$ perf test unwind
Test dwarf unwind: FAILED!
The reason is that, if a dso has '.debug_frame' but doesn't have
'.eh_frame_hdr' (like ARM), dso->frame_offset will be filled by offset
of '.debug_frame' during the first time calling of find_proc_info() ->
read_unwind_spec_debug_frame(), and be regarded to '.eh_frame_hdr' when
the second time calling of find_proc_info() ->
read_unwind_spec_eh_frame(), since '.eh_frame_hdr' is checked prior to
'.debug_frame'.
This patch solves the problem by creating two cache fields for
'.eh_frame_hdr' and '.debug_frame'.
Signed-off-by: Wang Nan <wangnan0@huawei.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Li Zefan <lizefan@huawei.com> Link: http://lkml.kernel.org/r/55028BA0.1030701@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:58 +0000 (21:35 +0800)]
perf tools: Avoid confusion with preloaded bash function for perf bash completion
Since some functions (e.g. '_get_comp_words_by_ref()') in perf bash
completion script are originally taken from git bash completion script,
these functions may be preloaded before perf bash completion script
runs.
In order to avoid repeating loading the same function twice, some test
constraints are used before these function definitions in the perf bash
completion script (e.g. 'type _get_comp_words_by_ref &>/dev/null ||').
The problem is that, if these functions in perf bash completion script
are changed for some reason, perf will still use the preloaded bash
functions rather than the customized functions of its own.
As a result, the perf bash completion will behave incorrectly. To get
rid of this problem, a flag can be defined to determine the proper
situation.
And to avoid overwriting the preloaded functions, the names of these
functions in perf bash completion script should be renamed to the
perf-customized ones.
Example:
Before this patch:
$ type _get_comp_words_by_ref
_get_comp_words_by_ref is a function
_get_comp_words_by_ref ()
{
local exclude flag i OPTIND=1;
local cur cword words=();
local upargs=() upvars=() vcur vcword vprev vwords;
while getopts "c:i:n:p:w:" flag "$@"; do
case $flag in
c)
vcur=$OPTARG
;;
i)
vcword=$OPTARG
;;
n)
exclude=$OPTARG
;;
p)
vprev=$OPTARG
;;
w)
vwords=$OPTARG
;;
esac;
done;
while [[ $# -ge $OPTIND ]]; do
case ${!OPTIND} in
cur)
vcur=cur
;;
prev)
vprev=prev
;;
cword)
vcword=cword
;;
words)
vwords=words
;;
*)
echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" 1>&2;
return 1
;;
esac;
let "OPTIND += 1";
done;
__get_cword_at_cursor_by_ref "$exclude" words cword cur;
[[ -n $vcur ]] && {
upvars+=("$vcur");
upargs+=(-v $vcur "$cur")
};
[[ -n $vcword ]] && {
upvars+=("$vcword");
upargs+=(-v $vcword "$cword")
};
[[ -n $vprev && $cword -ge 1 ]] && {
upvars+=("$vprev");
upargs+=(-v $vprev "${words[cword - 1]}")
};
[[ -n $vwords ]] && {
upvars+=("$vwords");
upargs+=(-a${#words[@]} $vwords "${words[@]}")
};
(( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}"
}
As shown above, the _get_comp_words_by_ref is the preloaded function in
fact, rather than the function defined in perf-completion.sh. So if we
happen to change the function for some reason, the result will behave in
a wrong state.
After this patch:
We can set preload_get_comp_words_by_ref="false" to not use the preloaded
function. Instead, it will use the function defined in perf-completion.sh,
which is renamed as __perf_get_comp_words_by_ref to avoid overwriting
the preloaded function _get_comp_words_by_ref.
$ type __perf_get_comp_words_by_ref
__perf_get_comp_words_by_ref is a function
__perf_get_comp_words_by_ref ()
{
local exclude cur_ words_ cword_;
if [ "$1" = "-n" ]; then
exclude=$2;
shift 2;
fi;
__my_reassemble_comp_words_by_ref "$exclude";
cur_=${words_[cword_]};
while [ $# -gt 0 ]; do
case "$1" in
cur)
cur=$cur_
;;
prev)
prev=${words_[$cword_-1]}
;;
words)
words=("${words_[@]}")
;;
cword)
cword=$cword_
;;
esac;
shift;
done
}
As shown above, the function __perf_get_comp_words_by_ref is loaded and
can work this time.
Note that we do not change the original behavior when those functions are
not preloaded before perf bash completion script runs. In this case,
although the flag is set to "true", the code will still change it to
"false" to use the function defined in perf-completion.sh.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-14-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:57 +0000 (21:35 +0800)]
perf tools: Add the bash completion for listing subsubcommands of perf trace
The bash completion does not support listing subsubcommands for 'perf
trace <TAB>', so fix it.
Example:
Before this patch:
$ perf trace <TAB>
$
As shown above, the subsubcommands of perf trace does not come out.
After this patch:
$ perf trace <TAB>
record
As shown above, the subsubcommands of perf trace can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-13-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:56 +0000 (21:35 +0800)]
perf tools: Add the bash completion for listing subsubcommands of perf timechart
The bash completion does not support listing subsubcommands for 'perf
timechart <TAB>', so fix it.
Example:
Before this patch:
$ perf timechart <TAB>
$
As shown above, the subsubcommands of perf timechart does not come out.
After this patch:
$ perf timechart <TAB>
record
As shown above, the subsubcommands of perf timechart can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-12-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:55 +0000 (21:35 +0800)]
perf tools: Add the bash completion for listing subsubcommands of perf test
The bash completion does not support listing subsubcommands for 'perf
test <TAB>', so fix it.
Example:
Before this patch:
$ perf test <TAB>
$
As shown above, the subsubcommands of perf test does not come out.
After this patch:
$ perf test <TAB>
list
As shown above, the subsubcommands of perf test can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-11-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:54 +0000 (21:35 +0800)]
perf tools: Add the bash completion for listing subsubcommands of perf script
The bash completion does not support listing subsubcommands for 'perf
script <TAB>', so fix it.
Example:
Before this patch:
$ perf script <TAB>
$
As shown above, the subsubcommands of perf script does not come out.
After this patch:
$ perf script <TAB>
record report
As shown above, the subsubcommands of perf script can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-10-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:53 +0000 (21:35 +0800)]
perf tools: Add the bash completion for listing subsubcommands of perf help
The bash completion does not support listing subsubcommands for 'perf
help <TAB>', so fix it.
Example:
Before this patch:
$ perf help <TAB>
$
As shown above, the subsubcommands of perf help does not come out.
After this patch:
$ perf help <TAB>
annotate buildid-cache data evlist inject
kvm lock probe report script
test top
bench buildid-list diff help kmem
list mem record sched stat
timechart trace
As shown above, the subsubcommands of perf help can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-9-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:52 +0000 (21:35 +0800)]
perf tools: Add the bash completion for listing subsubcommands of perf data
The bash completion does not support listing subsubcommands for 'perf
data <TAB>', so fix it.
Example:
Before this patch:
$ perf data <TAB>
$
As shown above, the subsubcommands of perf data does not come out.
After this patch:
$ perf data <TAB>
convert
As shown above, the subsubcommands of perf data can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-8-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:51 +0000 (21:35 +0800)]
perf tools: Fix the bash completion for listing subcommands of perf
The bash completion does not support listing subcommands for 'perf
--<long option> <TAB>'.
Example:
Before this patch:
$ perf --debug <TAB>
$
As shown above, the subcommands of perf does not come out.
After this patch:
$ perf --debug <TAB>
annotate buildid-cache data evlist inject
kvm lock probe report script
test top version
bench buildid-list diff help kmem
list mem record sched stat
timechart trace
As shown above, the subcommands of perf can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-7-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
As shown above, the events of record can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-6-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:49 +0000 (21:35 +0800)]
perf tools: Fix the bash completion for listing events of perf subcommand record|stat|top -e
The bash completion does not support listing events for 'perf kvm|kmem|
mem|lock|sched record|stat|top -e <TAB>', where 'kvm|kmem|mem|lock|sched'
are all subcommands of perf.
Example:
Before this patch:
$ perf kvm record -e <TAB>
$
As shown above, the events of record does not come out.
As shown above, the events of record can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-5-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:48 +0000 (21:35 +0800)]
perf tools: Provide the right bash completion for listing options of perf subcommand subsubcommand
The bash completion gives wrong options for 'perf kvm|kmem|mem|lock|
sched subsubcommand --<TAB>', where 'kvm|kmem|mem|lock|sched' are all
subcommands of perf and 'subsubcommand' is a subcommand of 'kvm|kmem|mem
|lock|sched'. In fact, the result incorrectly lists the bash completion
of 'perf subcommand' rather than 'perf subcommand subsubcommand'.
As shown above, the result is exactly the options of record as we wished.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-4-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:47 +0000 (21:35 +0800)]
perf tools: Fix the bash completion for listing subsubcommands of perf subcommand
The bash completion does not support listing subsubcommands for 'perf
kvm|kmem|mem|lock|sched --<long option> <TAB>', where 'kvm|kmem|mem|
lock|sched' are all subcommands of perf.
Example:
Before this patch:
$ perf kvm --verbose <TAB>
$
As shown above, the subsubcommands of perf kvm does not come out.
After this patch:
$ perf kvm --verbose <TAB>
buildid-list diff record report stat
top
As shown above, the subsubcommands of perf kvm can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-3-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Yunlong Song [Wed, 18 Mar 2015 13:35:46 +0000 (21:35 +0800)]
perf tools: Fix the bash completion for listing options of perf subcommand
The bash completion does not support listing options for 'perf
kvm|kmem|mem|lock|sched --<TAB>', where 'kvm|kmem|mem|lock|sched' are
all subcommands of perf.
Example:
Before this patch:
$ perf kvm --<TAB>
$
As shown above, the options of perf kvm does not come out.
As shown above, the options of perf kvm can come out now.
Signed-off-by: Yunlong Song <yunlong.song@huawei.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426685758-25488-2-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
H.J. Lu [Tue, 17 Mar 2015 22:27:48 +0000 (15:27 -0700)]
perf tools: Fix perf-read-vdsox32 not building and lib64 install dir
Commit:
c6e5e9fbc3ea ("perf tools: Fix building error in x86_64 when dwarf unwind is on")
removed the definition of IS_X86_64 but not all places using it, with
the consequence that perf-read-vdsox32 would not be built anymore, and
the default lib install directory was 'lib' instead of 'lib64'.
Jiri Olsa [Sun, 1 Mar 2015 19:44:18 +0000 (20:44 +0100)]
perf build: Get rid of VF_FEATURE_TESTS
It only contains (FEATURE_TESTS - FEATURE_DISPLAY) tests to display the
rest of the checks on 'make VF=1'. But we can actually compute this
list, which is less confusing.
Also renaming LIB_FEATURE_TESTS into FEATURE_DISPLAY, so it reflects
what this variable actually does - display its tests status to user.
Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <david.ahern@oracle.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/n/tip-gs160y03hpmx5ezpcr4gunxc@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Jiri Olsa [Wed, 11 Mar 2015 08:01:26 +0000 (09:01 +0100)]
perf build: Move features build output under features directory
Following commit introduced features build dump: 443a70541c56 perf tools: Output feature detection's gcc output to a file
Moving them into to have code more compact and renaming build dump
files. For each feature 'test-X' new file 'test-X.make.output' is
created and contains the build out. It's created in the same directory
as the feature itself.
Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <david.ahern@oracle.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/n/tip-dk6svnhcephrzgz4mfpcmtm7@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Wang Nan [Tue, 17 Mar 2015 13:29:47 +0000 (13:29 +0000)]
perf tools: Fix building error for arm64.
Commit b11db6581beaccef8ae9a388ae96074aa5cc144f ("perf tools: Fix build
error on ARCH=i386/x86_64/sparc64") uses sed on ARCH, which triggers a
bug in sequence of sed expression, where 's/arm.*/arm/' will replace
'arm64' to 'arm', causes arm64 building failure.
This patch prevent 'arm64' to be mached for 'arm.*' case.
perf hists browser: Allow annotating entries in callchains
Instead of annotating just the top level hist_entry, allow instead
annotating a map_symbol, i.e. the top level hist_entry or one of the
callchains for which there were samples.
Suggested-by: Stephane Eranian <eranian@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/n/tip-k1zxj5564je9jei4yd15ouwn@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Eugene Shatokhin [Tue, 17 Mar 2015 10:09:18 +0000 (19:09 +0900)]
kprobes/x86: Return correct length in __copy_instruction()
On x86-64, __copy_instruction() always returns 0 (error) if the
instruction uses %rip-relative addressing. This is because
kernel_insn_init() is called the second time for 'insn' instance
in such cases and sets all its fields to 0.
Because of this, trying to place a kprobe on such instruction
will fail, register_kprobe() will return -EINVAL.
Ingo Molnar [Fri, 13 Mar 2015 12:30:10 +0000 (13:30 +0100)]
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
User visible changes:
- Fix UI bug after zoom into thread/dso/symbol and another, after fold/unfold,
in the TUI hists browser (He Kuang)
- Fixes for 'perf probe' to better handle aliased symbols, for instance in glibc (Masami Hiramatsu, Namhyung Kim)
- 'perf kmem' improvements and fixes: (Namhyung Kim)
- Fix segfault when invalid sort key is given
- Allow -v option
- Fix alignment of slab result table
- 'perf stat' improvements and fixes: (Andi Kleen)
- Output running time and run/enabled ratio in CSV mode
- Fix IPC and other formulas with -A
- Always correctly indent ratio column
- Add tracepoint events fields CTF conversion support to 'perf data' (Sebastian Andrzej Siewior)
Infrastructure changes:
- Output feature detection's gcc output to a file, to help in debugging (Arnaldo Carvalho de Melo)
- Fix 'perf probe' compiles due to declarations using perf_probe_point (David Ahern)
- Fix possible double free on error in 'perf probe' (He Kuang)
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jeremie Galarneau <jgalar@efficios.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1424470628-5969-6-git-send-email-jolsa@kernel.org Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Namhyung Kim [Thu, 12 Mar 2015 07:32:47 +0000 (16:32 +0900)]
perf kmem: Allow -v option
Current perf kmem fails when -v option is used. As it's very useful for
debugging, let's allow it.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Joonsoo Kim <js1304@gmail.com> Cc: Minchan Kim <minchan@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1426145571-3065-3-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Andi Kleen [Wed, 11 Mar 2015 15:28:02 +0000 (08:28 -0700)]
perf stat: Always correctly indent ratio column
When cycles or instructions do not print anything, as in being,
--per-socket or --per-core modi, the ratio column was not correctly
indented for them. This lead to some ratios not lining up with the
others. Always indent correctly when nothing is printed.
Andi Kleen [Wed, 11 Mar 2015 15:28:01 +0000 (08:28 -0700)]
perf stat: Fix IPC and other formulas with -A
perf stat didn't compute the IPC and other formulas for individual CPUs
with -A. Fix this for the easy -A case. As before, --per-core and
--per-socket do not handle it, they simply print nothing.
He Kuang [Thu, 12 Mar 2015 07:21:49 +0000 (15:21 +0800)]
perf hists browser: Fix UI bug after fold/unfold
In perf hists browser, the fold/unfold stat of each hist entry is
recorded but hb->nr_callchain_rows loses its value after zoom out and
zoom in back. This causes a wrong row cursor range that restrict user to
move down anymore.
This bug can be reproduced as follows:
$ perf record -g -e syscalls:* ls
$ perf report
Available samples
================================================================
2 syscalls:sys_enter_mprotect <= [enter one of the entries]
2 syscalls:sys_exit_mprotect
13 syscalls:sys_enter_brk
...
In the hists brower, unfold some of the items, now the cursor can reach
to any rows:
Children Self Command Shared Object Symbol
================================================================
- 100.00% 100.00% ls libuClibc-0.9.33.2.so [.] lstat64
- lstat64
16.67% 0x6469702e64
8.33% 0x646970
8.33% 0x617461
8.33% 0x65
- 16.67% 0.00% ls [unknown] [.]0x6469702e64
0x6469702e64 <= [cursor can reach to bottom line, everything is ok]
Now, zoom back to "Available samples" and enter again:
Children Self Command Shared Object Symbol
================================================================
- 100.00% 100.00% ls libuClibc-0.9.33.2.so [.] lstat64
- lstat64
16.67% 0x6469702e64
8.33% 0x646970
8.33% 0x617461 <= [cursor may stop here, can't move down anymore]
8.33% 0x65
- 16.67% 0.00% ls [unknown] [.]0x6469702e64
0x6469702e64
This patch recalculates hb->nr_callchain_rows to fix the bug.
Signed-off-by: He Kuang <hekuang@huawei.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426144909-18951-1-git-send-email-hekuang@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
David Ahern [Wed, 11 Mar 2015 14:36:20 +0000 (10:36 -0400)]
perf probe: Fix compiles due to declarations using perf_probe_point
perf fails to build with gcc "(GCC) 4.4.7 20120313 (Red Hat
4.4.7-4.0.9)" (a.k.a., RHEL6 / CentOS 6 / OL 6):
cc1: warnings being treated as errors
util/probe-event.c: In function ‘get_alternative_line_range’:
util/probe-event.c:359: error: missing initializer
util/probe-event.c:359: error: (near initialization for ‘pp.file’)
util/probe-event.c:359: error: missing initializer
util/probe-event.c:359: error: (near initialization for ‘result.function’)
He Kuang [Wed, 11 Mar 2015 12:36:03 +0000 (20:36 +0800)]
perf hists browser: Fix UI bug after zoom into thread/dso/symbol
When zoom into thread/dso/symbol, the fold/unfold stat is cleared in
hists__filter_by_thread/dso/symbol(), but h->nr_rows is not cleared. So
if we toggle fold stat on the unfold entires, nr_entries got a wrong
value.
This bug can be reproduced as follows:
$ perf record -g -e syscalls:sys_enter_open ls
$ perf report
Children Self Command Shared Object Symbol
================================================================
+ 50.00% 0.00% ls ld64.so [.] _dl_get_ready_to_run
- 50.00% 0.00% ls ld64.so [.] _dl_load_shared_library
_dl_load_shared_library <= [Zoom into thread/dso]
_dl_get_ready_to_run
_start
...
In the new thread hists, all entries reset to fold, if we unfold the
same entry as we previously unfolded, nr_entries got wrong value, and we
can't move down cursor to bottom row.
Thread: ls
Children Self Command Shared Object Symbol
================================================================
+ 50.00% 0.00% ls ld64.so [.] _dl_get_ready_to_run
- 50.00% 0.00% ls ld64.so [.] _dl_load_shared_library
_dl_load_shared_library
_dl_get_ready_to_run <= [cursor may stop here, can't move down]
_start
...
This patch clear h->nr_rows to fix this bug.
Signed-off-by: He Kuang <hekuang@huawei.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1426077363-855-2-git-send-email-hekuang@huawei.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
He Kuang [Wed, 4 Mar 2015 10:01:42 +0000 (18:01 +0800)]
perf probe: Fix possible double free on error
A double free occurred when get source file path failed. If lr->path
failed to assign a new value, it will be freed as the old path and then
be freed again during line_range__clear(), and causes this:
perf tools: Output feature detection's gcc output to a file
So that we can debug feature detection problems.
It will appear on $(OUTPUT)feature-checks/.make-libbabeltrace.output,
using the libbabeltrace feature test.
Whole process:
[acme@ssdandy linux]$ make -C tools/perf install-bin
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j8' parallel build
config/Makefile:425: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
config/Makefile:709: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev
Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ on ]
... libbabeltrace: [ OFF ]
<SNIP>
[acme@ssdandy linux]$ find tools/perf -name ".make-*.output" | grep lib | tail -5
tools/perf/config/feature-checks/.make-libdw-dwarf-unwind.output
tools/perf/config/feature-checks/.make-libbabeltrace.output
tools/perf/config/feature-checks/.make-zlib.output
tools/perf/config/feature-checks/.make-liberty.output
tools/perf/config/feature-checks/.make-liberty-z.output
[acme@ssdandy linux]$
[acme@ssdandy linux]$ cat tools/perf/config/feature-checks/.make-libbabeltrace.output
make[1]: Entering directory `/home/acme/git/linux/tools/perf/config/feature-checks'
gcc -MD -Wall -Werror -o test-libbabeltrace.bin test-libbabeltrace.c -Wl,-z,noexecstack -lbabeltrace-ctf # -lbabeltrace provided by
test-libbabeltrace.c:2:42: fatal error: babeltrace/ctf-writer/writer.h: No such file or directory
#include <babeltrace/ctf-writer/writer.h>
^
compilation terminated.
make[1]: *** [test-libbabeltrace.bin] Error 1
make[1]: Leaving directory `/home/acme/git/linux/tools/perf/config/feature-checks'
[acme@ssdandy linux]$
So the libbabeltrace feature will not be builtin, but if we do what is required for it
to be built, namely point where we have it installed:
[acme@ssdandy linux]$ time make -C tools/perf LIBBABELTRACE_DIR=/opt/libbabeltrace install-bin
make: Entering directory `/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j8' parallel build
config/Makefile:425: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
Auto-detecting system features:
... dwarf: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ on ]
... libbabeltrace: [ on ]
... zlib: [ on ]
... DWARF post unwind library: libdw
<SNIP>
[acme@ssdandy linux]$ find tools/perf -name ".make-libbabel*.output" | grep lib | tail -5
tools/perf/config/feature-checks/.make-libbabeltrace.output
[acme@ssdandy linux]$ cat tools/perf/config/feature-checks/.make-libbabeltrace.output
make[1]: Entering directory `/home/acme/git/linux/tools/perf/config/feature-checks'
gcc -MD -I/opt/libbabeltrace/include -Wall -Werror -o test-libbabeltrace.bin test-libbabeltrace.c -Wl,-z,noexecstack -L/opt/libbabeltrace/lib -lbabeltrace-ctf # -lbabeltrace provided by
make[1]: Leaving directory `/home/acme/git/linux/tools/perf/config/feature-checks'
[acme@ssdandy linux]$
Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jeremie Galarneau <jgalar@efficios.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-h53xwueqwdeeiqcv9f50nqqb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Jiri Olsa [Tue, 10 Mar 2015 12:00:35 +0000 (13:00 +0100)]
perf build: Fix libbabeltrace detection
Following patch added -Werror for feature builds:
b49f1a4be701 perf tools: Improve feature test debuggability
and exposed a problem in the libbabeltrace feature build, because it was
including wrong header and gcc couldn't find the used symbol definition.
Adding proper header and keeping the old one as it is needed also
(libbabeltrace quirk).
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jeremie Galarneau <jgalar@efficios.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/20150310120035.GA4333@krava.redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This change will result in duplicate probes when strong and weak symbols
co-exist in a binary. But I think it's not a big problem since probes
at the weak symbol will never be hit anyway.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Naohiro Aota <naota@elisp.net> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150306073129.6904.41078.stgit@localhost.localdomain Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Namhyung Kim [Fri, 6 Mar 2015 07:31:27 +0000 (16:31 +0900)]
perf symbols: Allow symbol alias when loading map for symbol name
When perf probe tries to add a probe in a binary using symbol name, it
sometimes failed since some symbols were discard during loading dso.
When it resolves an address to symbol, it'd be better to have just one
symbol at given address. But for finding address from symbol, it'd be
better to keep all names (including aliases).
So allow tools to state that they want to allow aliases via
symbol_conf.allow_aliases.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: David Ahern <dsahern@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Naohiro Aota <naota@elisp.net> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150306073127.6904.3232.stgit@localhost.localdomain
[ Original patch passwd allow_alias to many functions, use symbol_conf.allow_aliases instead ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
perf probe: Fix to handle aliased symbols in glibc
Fix perf probe to handle aliased symbols correctly in glibc. In the
glibc, several symbols are defined as an alias of __libc_XXX, e.g.
malloc is an alias of __libc_malloc.
In such cases, dwarf has no subroutine instances of the alias functions
(e.g. no "malloc" instance), but the map has that symbol and its
address.
Thus, if we search the alieased symbol in debuginfo, we always fail to
find it, but it is in the map.
To solve this problem, this fails back to address-based alternative
search, which searches the symbol in the map, translates its address to
alternative (correct) function name by using debuginfo, and retry to
find the alternative function point from debuginfo.
This adds fail-back process to --vars, --lines and --add options. So,
now you can use those on malloc@libc :)
Without this patch;
-----
# ./perf probe -x /usr/lib64/libc-2.17.so -V malloc
Failed to find the address of malloc
Error: Failed to show vars.
# ./perf probe -x /usr/lib64/libc-2.17.so -a "malloc bytes"
Probe point 'malloc' not found in debuginfo.
Error: Failed to add events.
-----
With this patch;
-----
# ./perf probe -x /usr/lib64/libc-2.17.so -V malloc
Available variables at malloc
@<__libc_malloc+0>
size_t bytes
# ./perf probe -x /usr/lib64/libc-2.17.so -a "malloc bytes"
Added new event:
probe_libc:malloc (on malloc in /usr/lib64/libc-2.17.so with bytes)
You can now use it in all perf tools, such as:
perf record -e probe_libc:malloc -aR sleep 1
-----
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Naohiro Aota <naota@elisp.net> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150306073120.6904.13779.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
We were keeping the session around just because we kept pointers to
struct thread instances, but now we reference count them, so no need
for deferring the perf_session__delete call to after we traverse the
work_list entries.
Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-9agtck6jdr3rebdp39z1lo0e@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
We need to do that to stop accumulating entries in the dead_threads
linked list, i.e. we were keeping references to threads in struct hists
that continue to exist even after a thread exited and was removed from
the machine threads rbtree.
We still keep the dead_threads list, but just for debugging, allowing us
to iterate at any given point over the threads that still are referenced
by things like struct hist_entry.
Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-3ejvfyed0r7ue61dkurzjux4@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
perf probe: Remove bias offset to find probe point by address
Remove bias offset to find probe point by address.
Without this patch, probe points on kernel and executables are shown
correctly, but do not work with libraries:
# ./perf probe -l
probe:do_fork (on do_fork@kernel/fork.c)
probe_libc:malloc (on malloc in /usr/lib64/libc-2.17.so)
probe_perf:strlist__new (on strlist__new@util/strlist.c in /home/mhiramat/ksrc/linux-3/tools/perf/perf)
Removing bias allows it to show it as real place:
# ./perf probe -l
probe:do_fork (on do_fork@kernel/fork.c)
probe_libc:malloc (on __libc_malloc@malloc/malloc.c in /usr/lib64/libc-2.17.so)
probe_perf:strlist__new (on strlist__new@util/strlist.c in /home/mhiramat/ksrc/linux-3/tools/perf/perf)
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Naohiro Aota <naota@elisp.net> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150302124946.9191.64085.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Masami Hiramatsu [Sat, 28 Feb 2015 02:53:29 +0000 (11:53 +0900)]
perf probe: Warn if given uprobe event accesses memory on older kernel
Warn if given uprobe event accesses memory on older kernel.
Until 3.14, uprobe event only supports accessing registers so this warns
to upgrade kernel if uprobe-event returns -EINVAL and an argument of the
event accesses memory ($stack, @+offset, and +|-offs() symtax).
With this patch (on 3.10.0-123.13.2.el7.x86_64);
-----
# ./perf probe -x ./perf warn_uprobe_event_compat stack=-0\(%sp\)
Added new event:
Failed to write event: Invalid argument
Please upgrade your kernel to at least 3.14 to have access to feature -0(%sp)
Error: Failed to add events.
-----
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/20150228025329.32106.70581.stgit@localhost.localdomain Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Ingo Molnar [Sat, 28 Feb 2015 09:16:27 +0000 (10:16 +0100)]
perf tools: Improve feature test debuggability
Certain feature tests fail with link errors:
triton:~/tip/tools/perf/config/feature-checks> make test-libbabeltrace.bin
gcc -MD -o test-libbabeltrace.bin test-libbabeltrace.c # -lbabeltrace provided by
/tmp/cc6dRSqd.o: In function `main':
test-libbabeltrace.c:(.text+0xf): undefined reference to `bt_ctf_stream_class_get_packet_context_type'
although they should already fail with a build error due to lack of a
proper prototype for the function. Due to this I first tried to find
which library was missing - while it was the whole feature that was
missing from the .h file already.
To solve this, propagate -Wall -Werror to all testcases and remove them
from testcase Makefile rules that used them explicitly.
A missing feature now outputs:
triton:~/tip/tools/perf/config/feature-checks> make test-libbabeltrace.bin
gcc -MD -Wall -Werror -o test-libbabeltrace.bin test-libbabeltrace.c # -lbabeltrace provided by
test-libbabeltrace.c: In function ‘main’:
test-libbabeltrace.c:6:2: error: implicit declaration of function ‘bt_ctf_stream_class_get_packet_context_type’ [-Werror=implicit-function-declaration]
Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: David Ahern <david.ahern@oracle.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150228091627.GF31887@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
config/Makefile:566: No python-config tool was found
config/Makefile:566: Python support will not be built
config/Makefile:565: No 'python-config' tool was found: disables Python support - please install python-devel/python-dev
It's now a standard one-line message with a package install suggestion,
and it also uses the standard language used by other feature detection
messages.
Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: David Ahern <david.ahern@oracle.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150228083345.GB31887@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Ingo Molnar [Sat, 28 Feb 2015 08:17:50 +0000 (09:17 +0100)]
perf tools: Remove annoying extra message from the features build
This message:
Makefile:153: The path 'python-config' is not executable.
Appears on every perf build that does not have a sufficient python
environment installed. It's really just an internal detail of python
configuration pass and users should not see it - and it's pretty
meaningless to them in any case because the message is not very helpful.
(So it's not executable. Why does that matter? What can the user do
about it?)
Remove the warning, the missing python feature warning is sufficient:
config/Makefile:566: No python-config tool was found
config/Makefile:566: Python support will not be built
although even that one isn't very helpful to users: so no Python support
will be built, what can the user do to fix that? Most other such
warnings give package install suggestions.
Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: David Ahern <david.ahern@oracle.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20150228081750.GA31887@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Namhyung Kim [Mon, 2 Mar 2015 03:13:33 +0000 (12:13 +0900)]
perf record: Document --group option
The 'perf record --group' option lacks documentation and confuses users.
As -e/--event option already supports group spec, it should not be used
anymore.
Also add a short description of event group itself.
Reported-by: Stephane Eranian <eranian@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1425266013-5034-1-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Namhyung Kim [Mon, 2 Mar 2015 04:31:03 +0000 (13:31 +0900)]
perf tools: Fix build error on ARCH=i386/x86_64/sparc64
He Kuang reported that current perf tools failed to build when ARCH
variable was given like above.
It was because the name is different that internal directory name. I
can see that David's sparc64 build has same problem.
So fix it by applying the sed conversion script to the command line ARCH
variable also, and fixing the converted name there (i.e. i386/x86_64 ->
x86, sparc64 -> sparc).
Reported-by: He Kuang <hekuang@huawei.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Tested-by: He Kuang <hekuang@huawei.com>
Acked: Jiri Olsa <jolsa@redhat.com> Cc: David Ahern <david.ahern@oracle.com> Cc: He Kuang <hekuang@huawei.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1425270663-10215-1-git-send-email-namhyung@kernel.org
[ Resolved conflict with 4861f87cd3d1 "Make sparc64 arch point to sparc" ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
We ended up emitting PERF_RECORD_FORK events after their corresponding
PERF_RECORD_COMM, so the code below will remove the "existing thread"
and then recreates it, unnecessarily:
[root@ssdandy ~]# perf probe -x ~/bin/perf fork_after_comm=machine__process_fork_event:12
Added new event:
probe_perf:fork_after_comm (on machine__process_fork_event:12 in /home/acme/bin/perf)
You can now use it in all perf tools, such as:
perf record -e probe_perf:fork_after_comm -aR sleep 1
[root@ssdandy ~]#
[root@ssdandy ~]# perf record -g -e probe_perf:* trace -o /tmp/bla
^C[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.021 MB perf.data (30 samples) ]
Terminated
[root@ssdandy ~]#
[root@ssdandy ~]# perf report --no-children --show-total-period --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
# Samples: 30 of event 'probe_perf:fork_after_comm'
# Event count (approx.): 30
#
# Overhead Period Command Shared Object Symbol
# ........ ............ ....... ............. ...............................
#
100.00% 30 trace trace [.] machine__process_fork_event
|
---machine__process_fork_event
__event__synthesize_thread.part.2
perf_event__synthesize_threads
cmd_trace
main
__libc_start_main
Fix it by more closely mimicking how the kernel generates those records
when a new fork happens, i.e. first a PERF_RECORD_FORK, then a
PERF_RECORD_COMM.
Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-h0emvymi2t3mw8dlqd6d6z73@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This patch fixes the issues by checking if the counter is supported,
before reading and logging the counter value.
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com> Acked-by: David Ahern <dsahern@gmail.com> Tested-by: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/1423852858-8455-1-git-send-email-suzuki.poulose@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>