Commit Graph

561055 Commits

Author SHA1 Message Date
Wang Nan 26812d466b perf data: Add u32_hex data type
Add hexadecimal u32 to base data type, which is useful for raw output
because raw data is u32 aligned.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1449541544-67621-12-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-11 09:12:09 -03:00
Wang Nan 77ba9a5b48 tools lib bpf: Fetch map names from correct strtab
Namhyung Kim pointed out a potential problem in original code that it
fetches names of maps from section header string table, which is used
to store section names.

Original code doesn't cause error because of a LLVM behavior that, it
combines shstrtab into strtab. For example:

 $ echo 'int func() {return 0;}' | x86_64-oe-linux-clang -x c -o temp.o -c -
 $ readelf -h ./temp.o
 ELF Header:
   Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00
   ...
   Section header string table index: 1
 $ readelf -S ./temp.o
 There are 10 section headers, starting at offset 0x288:

 Section Headers:
   [Nr] Name              Type             Address           Offset
        Size              EntSize          Flags  Link  Info  Align
   [ 0]                   NULL             0000000000000000  00000000
        0000000000000000  0000000000000000           0     0     0
   [ 1] .strtab           STRTAB           0000000000000000  00000230
        0000000000000051  0000000000000000           0     0     1
        ...
 $ readelf -p .strtab ./temp.o

 String dump of section '.strtab':
   [     1]  .text
   [     7]  .comment
   [    10]  .bss
   [    15]  .note.GNU-stack
   [    25]  .rela.eh_frame
   [    34]  func
   [    39]  .strtab
   [    41]  .symtab
   [    49]  .data
   [    4f]  -

 $ readelf -p .shstrtab ./temp.o
 readelf: Warning: Section '.shstrtab' was not dumped because it does not exist!

Where, 'section header string table index' points to '.strtab', and
symbol names are also stored there.

However, in case of gcc:

 $ echo 'int func() {return 0;}' | gcc -x c -o temp.o -c -
 $ readelf -p .shstrtab ./temp.o

 String dump of section '.shstrtab':
   [     1]  .symtab
   [     9]  .strtab
   [    11]  .shstrtab
   [    1b]  .text
   [    21]  .data
   [    27]  .bss
   [    2c]  .comment
   [    35]  .note.GNU-stack
   [    45]  .rela.eh_frame
 $ readelf -p .strtab ./temp.o

 String dump of section '.strtab':
   [     1]  func

They are separated sections.

Although original code doesn't cause error, we'd better use canonical
method for fetching symbol names to avoid potential behavior changing.
This patch learns from readelf's code, fetches string from sh_link
of .symbol section.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Reported-and-Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1449541544-67621-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-11 08:53:04 -03:00
Wang Nan 973170e667 tools lib bpf: Check return value of strdup when reading map names
Commit 561bbccac7 ("tools lib bpf:
Extract and collect map names from BPF object file") forgets checking
return value of strdup(). This patch fixes it. It also checks names
pointer before strcmp() for safety.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Fixes: 561bbccac7 ("tools lib bpf: Extract and collect map names from BPF object file")
Link: http://lkml.kernel.org/r/1449541544-67621-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-11 08:51:09 -03:00
Namhyung Kim beefb8d0e5 perf top: Cleanup condition in perf_top__record_precise_ip()
The 'he' cannot be NULL since it's caller hist_iter__top_callback() is
called only if iter->he is not NULL (see hist_entry_iter__add).  So
setting 'sym' before the condition to simplify the code.

Also make it clearer that the top->symbol_filter_entry check is only
meaningful on stdio mode (i.e. when use_browser is 0).

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449802616-16170-4-git-send-email-namhyung@kernel.org
[ Complete the simplification replacing one more he->ms.sym with sym ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-11 08:38:10 -03:00
Namhyung Kim 448f13b2d1 perf top: Fix annotation on --stdio
The ui__has_annotation() inside perf_top__record_precise_ip() should be
removed since it returns true only for TUI (and when sort key has
symbol).  However the 'perf top --stdio' also supports annotation for a
symbol which was specified by 's' key action.

Actually it already does the necessary checks before calling the
function.  So it's ok to get rid of the check here.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449802616-16170-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-11 08:36:18 -03:00
Namhyung Kim 151ee834cc perf top: Access hists->lock only if needed
The perf_top__record_precise_ip() releases and regrabs the
he->hists->lock because it can sleep if there's an error.  But it should
be done conditionally as it slows down the fast path.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449802616-16170-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-11 08:34:49 -03:00
Namhyung Kim 64226bcf64 perf top: Do not convert address for perf_top__record_precise_ip()
We call map->unmap_ip() before the function and call map->map_ip()
inside the function.  This is meaningless and look strange since only
one of the two checks 'map'.  Let's use al->addr directly.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449802616-16170-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-11 08:33:18 -03:00
Masami Hiramatsu e7a7865cc0 perf symbols: Fix dso__load_sym to put dso
Fix dso__load_sym to put dso because dsos__add already got it.

Refcnt debugger explain the problem:
  ----
  ==== [0] ====
  Unreclaimed dso: 0x19dd200
  Refcount +1 => 1 at
    ./perf(dso__new+0x1ff) [0x4a62df]
    ./perf(dso__load_sym+0xe89) [0x503509]
    ./perf(dso__load_vmlinux+0xbf) [0x4aa77f]
    ./perf(dso__load_vmlinux_path+0x8c) [0x4aa8dc]
    ./perf() [0x50539a]
    ./perf(convert_perf_probe_events+0xd79) [0x50ad39]
    ./perf() [0x45600f]
    ./perf(cmd_probe+0x6c) [0x4566bc]
    ./perf() [0x47abc5]
    ./perf(main+0x610) [0x421f90]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
    ./perf() [0x4220a9]
  Refcount +1 => 2 at
    ./perf(dso__get+0x34) [0x4a65f4]
    ./perf(map__new2+0x76) [0x4be216]
    ./perf(dso__load_sym+0xee1) [0x503561]
    ./perf(dso__load_vmlinux+0xbf) [0x4aa77f]
    ./perf(dso__load_vmlinux_path+0x8c) [0x4aa8dc]
    ./perf() [0x50539a]
    ./perf(convert_perf_probe_events+0xd79) [0x50ad39]
    ./perf() [0x45600f]
    ./perf(cmd_probe+0x6c) [0x4566bc]
    ./perf() [0x47abc5]
    ./perf(main+0x610) [0x421f90]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
    ./perf() [0x4220a9]
  Refcount +1 => 3 at
    ./perf(dsos__add+0xf3) [0x4a6bc3]
    ./perf(dso__load_sym+0xfc1) [0x503641]
    ./perf(dso__load_vmlinux+0xbf) [0x4aa77f]
    ./perf(dso__load_vmlinux_path+0x8c) [0x4aa8dc]
    ./perf() [0x50539a]
    ./perf(convert_perf_probe_events+0xd79) [0x50ad39]
    ./perf() [0x45600f]
    ./perf(cmd_probe+0x6c) [0x4566bc]
    ./perf() [0x47abc5]
    ./perf(main+0x610) [0x421f90]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
    ./perf() [0x4220a9]
  Refcount -1 => 2 at
    ./perf(dso__put+0x2f) [0x4a664f]
    ./perf(map_groups__exit+0xb9) [0x4bee29]
    ./perf(machine__delete+0xb0) [0x4b93d0]
    ./perf(exit_probe_symbol_maps+0x28) [0x506718]
    ./perf() [0x45628a]
    ./perf(cmd_probe+0x6c) [0x4566bc]
    ./perf() [0x47abc5]
    ./perf(main+0x610) [0x421f90]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
    ./perf() [0x4220a9]
  Refcount -1 => 1 at
    ./perf(dso__put+0x2f) [0x4a664f]
    ./perf(machine__delete+0xfe) [0x4b941e]
    ./perf(exit_probe_symbol_maps+0x28) [0x506718]
    ./perf() [0x45628a]
    ./perf(cmd_probe+0x6c) [0x4566bc]
    ./perf() [0x47abc5]
    ./perf(main+0x610) [0x421f90]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
    ./perf() [0x4220a9]
  ----
So, in the dso__load_sym, dso is gotten 3 times, by dso__new,
map__new2, and dsos__add. The last 2 is actually released by
map_groups and machine__delete correspondingly. However, the
first reference by dso__new, is never released.

Committer note:

Changed the place where the reference count is dropped to:

Fix it by dropping it right after creating curr_map, since we know that
either that operation failed and we need to drop the dso refcount or
that it succeed and we have it referenced via curr_map->dso.

Then only drop the curr_map refcount after we call dsos__add() to make
sure we hold a reference to it via curr_map->dso.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021118.10245.49869.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 16:29:32 -03:00
Masami Hiramatsu 9d8b172f29 perf tools: Make perf_session__register_idle_thread drop the refcount
Note that since the thread was already inserted to the session
list, it will be released when the session is released.
Also, in perf_session__register_idle_thread() failure path,
the thread should be put before returning.

Refcnt debugger shows that the perf_session__register_idle_thread
gets the returned thread, but the caller (__cmd_top) does not
put the returned idle thread.

  ----
  ==== [0] ====
  Unreclaimed thread@0x24e6240
  Refcount +1 => 0 at
    ./perf(thread__new+0xe5) [0x4c8a75]
    ./perf(machine__findnew_thread+0x9a) [0x4bbdba]
    ./perf(perf_session__register_idle_thread+0x28) [0x4c63c8]
    ./perf(cmd_top+0xd7d) [0x43cf6d]
    ./perf() [0x47ba35]
    ./perf(main+0x617) [0x4225b7]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f06027c5af5]
    ./perf() [0x42272d]
  Refcount +1 => 1 at
    ./perf(thread__get+0x2c) [0x4c8bcc]
    ./perf(machine__findnew_thread+0xee) [0x4bbe0e]
    ./perf(perf_session__register_idle_thread+0x28) [0x4c63c8]
    ./perf(cmd_top+0xd7d) [0x43cf6d]
    ./perf() [0x47ba35]
    ./perf(main+0x617) [0x4225b7]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f06027c5af5]
    ./perf() [0x42272d]
  Refcount +1 => 2 at
    ./perf(thread__get+0x2c) [0x4c8bcc]
    ./perf(machine__findnew_thread+0x112) [0x4bbe32]
    ./perf(perf_session__register_idle_thread+0x28) [0x4c63c8]
    ./perf(cmd_top+0xd7d) [0x43cf6d]
    ./perf() [0x47ba35]
    ./perf(main+0x617) [0x4225b7]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f06027c5af5]
    ./perf() [0x42272d]
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021122.10245.69707.stgit@localhost.localdomain
[ Drop the refcount in perf_session__register_idle_thread() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 16:28:58 -03:00
Arnaldo Carvalho de Melo 8488335c03 Revert "perf tools: Improve setting of gcc debug option"
This reverts commit e8b7ea4356.

Martin created a gcc PR:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68836

Reported-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Martin Liska <mliska@suse.cz>
Cc: Namhyung Kim <namhyung@kernel.org>,
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20151202164827.GA21124@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 16:09:40 -03:00
Namhyung Kim 61fa0e94ca perf top: Delete half-processed hist entries when exit
After sample processing is done, hist entries are in both of
hists->entries and hists->entries_in (or hists->entries_collapsed).  So
I guess perf report does not have leaks on hists.

But for perf top, it's possible to have half-processed entries which are
only in hists->entries_in.  Eventually they will go to the
hists->entries and get freed but they cannot be deleted by current
hists__delete_entries().  This patch adds hists__delete_all_entries
function to delete those entries.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-and-Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
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/1449734015-9148-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 15:56:58 -03:00
Namhyung Kim 3f86eb6b07 perf tools: Get rid of exit_browser() from usage_with_options()
Since all of its users call before setup_browser(), there's no need to
call exit_browser() inside of the function.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449716459-23004-8-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 15:47:52 -03:00
Namhyung Kim 7ecb48fde3 perf thread_map: Free strlist on constructor error path
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449716459-23004-7-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 15:47:51 -03:00
Arnaldo Carvalho de Melo f8a5c0b24b perf top: Do show usage message when failing to create cpu/thread maps
This is necessary to get rid of the browser dependency from
usage_with_options() and its friends.  Because we validate the targets
which are used to create the cpu/thread maps and inform the user about
any override performed via the chosen UI, we don't need to call the
usage routine for that.

Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-slu7lj7buzpwgop1vo9la8ma@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 15:47:47 -03:00
Namhyung Kim b3f38fc242 perf report: Check argument before calling setup_browser()
This is necessary to get rid of the browser dependency from
usage_with_options() and its friends.  Because there's no code
changing the argc and argv, it'd be ok to check it early.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449716459-23004-5-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 14:35:58 -03:00
Namhyung Kim 1b0344e64d perf kvm: Remove invocation of setup/exit_browser()
Calling setup_browser(false) with use_browser = 0 is meaningless.
Just get rid of it.  This is necessary to remove the browser
dependency from usage_with_options() and friends.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449716459-23004-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 14:35:35 -03:00
Namhyung Kim 3df668e74a perf annotate: Delay UI browser setup after initialization is done
Move setup_browser after all necessary initialization is done.  This is
to remove the browser dependency from usage_with_options and friends.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449716459-23004-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 14:33:54 -03:00
Namhyung Kim 50e19ef978 perf annotate: Check argument before calling setup_browser()
This is necessary to get rid of the browser dependency from
usage_with_options() and its friends.  Because there's no code changing
the argc and argv, it'd be ok to check it early.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449716459-23004-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-10 14:32:33 -03:00
Ingo Molnar d18929e9fd perf/core improvements and fixes:
User visible:
 
 - Change default selection TUI background color to yellow (Ingo Molnar)
 
 Infrastructure:
 
 - Start paving the way to reuse some cmdline functions with other tools/
   living utilities (Josh Poimboeuf)
 
 - Reference count fixes using the refcount debugger, unleaking some objects
   (Masami Hiramatsu)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWaFvZAAoJENZQFvNTUqpAYioP/1EPE4kJUUSc4QNWaN39vIWq
 /saTLPiEPWZOQpG0AbY4D01NQvBSbVS+6zu8akr4v5I/pR7sP6Xb7k4k0GjVsMkA
 dy8xmDKzdzfmZQpd6jrIhUzOG/vCO7rki51gWqxGgpZ+4izA2/Lpd3Q5lvViRHi8
 h1wOfW5w3Y6R7Y2gF8NIm2/+SZDAmn166X+vy71xV2HOYpGBJ4rSl1hwH5AZFqH3
 9Buxxlb3VHebqZ/0Zo+jbDYSIGe0lSKmnj/Osd4FXhJTrTIXTbmrA8jMwjIXvu33
 TejnpboGT6dAJxIL6wSoyspPF8eR6HaWiSn+tN5nT4ePTACQ1tC4V61ZJHSrcYz3
 DH5KKUwQrCD7VOZhx+FqchJ6pTQ2ZbsJCVCjjARa19MVawpWVBuyM+ui11GsJECg
 tDSQIy/wFJMJekviimPY8OFJkwyvOur6vK7vt0X65ZGSGMjDkRwyJpJoxeHXGe0K
 wYalhHrtoMwaXQmhEHk9Q9YDtAsTNxXQjLFCX25Qf0UBcN9fNyT+gqNS1Gb1bG98
 nvqjKJfbvWnV/nmRRuB32aOLuJrBGXMfQz7E10nhPHTBG7P8a7a8uAftVFm9HGad
 5sLYQXNKM9fXi+4BCYD0j949O6S3k2K4Xt5wm9PuYTBe0TMtVc2aF90dLJlfCIgP
 145mFIEtsFOtvQJj+tAY
 =OkaH
 -----END PGP SIGNATURE-----

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:

User visible changes:

  - Change default selection TUI background color to yellow (Ingo Molnar)

Infrastructure changes:

  - Start paving the way to reuse some cmdline functions with other tools/
    living utilities (Josh Poimboeuf)

  - Reference count fixes using the refcount debugger, unleaking some objects
    (Masami Hiramatsu)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-12-10 09:10:40 +01:00
Josh Poimboeuf 0a4bb5da95 perf tools: Move cmd_version() to builtin-version.c
Move cmd_version() to its own file so that help.c can be moved to a
library.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.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/e908b1b68f20ab6d8d33941d5571c23110622e60.1449548395.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:42:03 -03:00
Josh Poimboeuf 2bdb2c2729 perf tools: Save cmdline arguments earlier
perf_env__set_cmdline() only saves the arguments the first time it's
called.  It doesn't need to be called every time the options and
suboptions are parsed.  Instead it can just be called once.

This also has the advantage of making the option parsing code less
perf-specific so it can be moved out to a library.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.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/19b76a5aa1b688bd635bd65d80bbc103a978d75e.1449548395.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:42:03 -03:00
Josh Poimboeuf 1fe143c5f9 perf tools: Move term functions out of util.c
The term functions are needed by help.c which is going to be moved into
a separate library.  Move them out of util.c and into their own file.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.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/9a39c854dd156b55ebda57e427594c9a59dcb40f.1449548395.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:42:02 -03:00
Josh Poimboeuf de7cf7cadc perf tools: Remove unused pager_use_color variable
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.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/e540c61b3068761181db6d9b1b3411990bafdb2f.1449548395.git.jpoimboe@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:42:02 -03:00
Masami Hiramatsu 5191d88768 perf tools: Fix write_numa_topology to put cpu_map instead of free
Fix write_numa_topology to put cpu_map instead of free because cpu_map
is managed based on refcnt.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021135.10245.79046.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:42:01 -03:00
Masami Hiramatsu cc1121ab96 perf machine: Fix machine.vmlinux_maps to make sure to clear the old one
Fix machine.vmlinux_maps to make sure to clear the old one if it is
renewal. This can leak the previous maps on the vmlinux_maps because
those are just overwritten.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021133.10245.93730.stgit@localhost.localdomain
[ Simplified the memset, same end result ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:42:00 -03:00
Masami Hiramatsu d91130e90a perf tools: Fix maps__fixup_overlappings to put used maps
Since the __map_groups__insert got the given map, we don't need to keep
it. So put the maps.

Refcnt debugger shows that map_groups__fixup_overlappings() got a map
twice but the group released it just once. This pattern usually
indicates the leak happens in caller site.

  ----
  ==== [0] ====
  Unreclaimed map@0x39d3ae0
  Refcount +1 => 1 at
    ./perf(map_groups__fixup_overlappings+0x335) [0x4c1865]
    ./perf(thread__insert_map+0x30) [0x4c8e00]
    ./perf(machine__process_mmap2_event+0x106) [0x4bd876]
    ./perf() [0x4c378e]
    ./perf() [0x4c4393]
    ./perf(perf_session__process_events+0x38a) [0x4c654a]
    ./perf(cmd_record+0xe24) [0x42fc94]
    ./perf() [0x47b745]
    ./perf(main+0x617) [0x422547]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2eca2deaf5]
    ./perf() [0x4226bd]
  Refcount +1 => 2 at
    ./perf(map_groups__fixup_overlappings+0x3c5) [0x4c18f5]
    ./perf(thread__insert_map+0x30) [0x4c8e00]
    ./perf(machine__process_mmap2_event+0x106) [0x4bd876]
    ./perf() [0x4c378e]
    ./perf() [0x4c4393]
    ./perf(perf_session__process_events+0x38a) [0x4c654a]
    ./perf(cmd_record+0xe24) [0x42fc94]
    ./perf() [0x47b745]
    ./perf(main+0x617) [0x422547]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2eca2deaf5]
    ./perf() [0x4226bd]
  Refcount -1 => 1 at
    ./perf(map_groups__exit+0x92) [0x4c0962]
    ./perf(map_groups__put+0x60) [0x4c0bc0]
    ./perf(thread__put+0x90) [0x4c8a40]
    ./perf(machine__delete_threads+0x7e) [0x4bad9e]
    ./perf(perf_session__delete+0x4f) [0x4c499f]
    ./perf(cmd_record+0xb6d) [0x42f9dd]
    ./perf() [0x47b745]
    ./perf(main+0x617) [0x422547]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2eca2deaf5]
    ./perf() [0x4226bd]
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021131.10245.41485.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:42:00 -03:00
Masami Hiramatsu 17577decb2 perf hists: Fix hists_evsel to release hists
Since hists__init doesn't set the destructor of hists_evsel (which is an
extended evsel structure), when hists_evsel is released, the extended
part of the hists_evsel is not deleted (note that the hists_evsel object
itself is freed).

This fixes it to add a destructor for hists__evsel and to set it up.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021129.10245.28710.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:41:59 -03:00
Masami Hiramatsu 544c2ae7b1 perf stat: Fix cmd_stat to release cpu_map
Fix cmd_stat() to release cpu_map objects (aggr_map and
cpus_aggr_map) afterwards.

refcnt debugger shows that the cmd_stat initializes cpu_map
but not puts it.
  ----
  # ./perf stat -v ls
  ....
  REFCNT: BUG: Unreclaimed objects found.
  ==== [0] ====
  Unreclaimed cpu_map@0x29339c0
  Refcount +1 => 1 at
    ./perf(cpu_map__empty_new+0x6d) [0x4e64bd]
    ./perf(cmd_stat+0x5fe) [0x43594e]
    ./perf() [0x47b785]
    ./perf(main+0x617) [0x422587]
    /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2dff420af5]
    ./perf() [0x4226fd]
  REFCNT: Total 1 objects are not reclaimed.
    "cpu_map" leaks 1 objects
  ----

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021127.10245.93697.stgit@localhost.localdomain
[ Remove NULL checks before calling the put operation, it checks it already ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:41:59 -03:00
Masami Hiramatsu bae32b50ea perf tools: Fix map_groups__clone to put cloned map
Fix map_groups__clone to put cloned map after inserting it to the
map_groups.

Refcnt debugger shows:
  ----
  ==== [0] ====
  Unreclaimed map: 0x2a27ee0
  Refcount +1 => 1 at
    ./perf(map_groups__clone+0x8d) [0x4bb7ed]
    ./perf(thread__fork+0xbe) [0x4c1f9e]
    ./perf(machine__process_fork_event+0x216) [0x4b79a6]
    ./perf(perf_event__synthesize_threads+0x38b) [0x48135b]
    ./perf(cmd_top+0xdc6) [0x43cb76]
    ./perf() [0x477223]
    ./perf(main+0x617) [0x422077]
    /lib64/libc.so.6(__libc_start_main+0xf0) [0x7ff806af8fe0]
    ./perf() [0x4221ed]
  Refcount +1 => 2 at
    ./perf(map_groups__clone+0x128) [0x4bb888]
    ./perf(thread__fork+0xbe) [0x4c1f9e]
    ./perf(machine__process_fork_event+0x216) [0x4b79a6]
    ./perf(perf_event__synthesize_threads+0x38b) [0x48135b]
    ./perf(cmd_top+0xdc6) [0x43cb76]
    ./perf() [0x477223]
    ./perf(main+0x617) [0x422077]
    /lib64/libc.so.6(__libc_start_main+0xf0) [0x7ff806af8fe0]
    ./perf() [0x4221ed]
  Refcount -1 => 1 at
    ./perf(map_groups__exit+0x87) [0x4ba757]
    ./perf(map_groups__put+0x68) [0x4ba9a8]
    ./perf(thread__put+0x8b) [0x4c1aeb]
    ./perf(machine__delete_threads+0x81) [0x4b48f1]
    ./perf(perf_session__delete+0x4f) [0x4be63f]
    ./perf(cmd_top+0x1094) [0x43ce44]
    ./perf() [0x477223]
    ./perf(main+0x617) [0x422077]
    /lib64/libc.so.6(__libc_start_main+0xf0) [0x7ff806af8fe0]
    ./perf() [0x4221ed]
  ----

This shows map_groups__clone get the map twice and put it when
map_groups__exit.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20151209021120.10245.95388.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:41:58 -03:00
Ingo Molnar 8d7d377c2b perf tui: Change default selection background color to yellow
Boris reported that 'perf top' is unusable on his default 'black on
white' terminal, which uses (eye friendly) light-grey as a background
color.

The reason is that the TUI cursor for the current selection line uses
HE_COLORSET_SELECTED, and that has a default background color of
'lightgrey' - which is a common terminal background choice and thus
the colors conflict.

Use yellow as the background color instead: that should be an uncommon
terminal background, yet it's still ergonomic on both black and
white/grey terminals.

[ It would be a better solution to straight out detect color
  collisions and resolve them reasonably by converting them to RGB and
  calculating color space distances, but I was unable to find
  proper documentation for SLtt_get_color_object() to recover the
  current color scheme so I gave up ... Yellow works well enough. ]

Reported-and-Tested-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Binderman <dcb314@hotmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20150305103213.GA23046@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-09 13:41:55 -03:00
Ingo Molnar a30c99a0be Merge branch 'perf/urgent' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-12-08 06:06:20 +01:00
Ingo Molnar 03fba21adb perf/urgent fixes:
User visible:
 
 - Fix showing the running kernel build id using: (Michael Petlan)
 
     $ perf buildid-list -k
     03c2a89c595616188f02f0282762a75b47069bc0
 
 - hists browser (report, top) symbol filter segfault fixes (Wang Nan)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWZePcAAoJENZQFvNTUqpAH1AP/iyY2nCRxtuOsOnuoqanuf5H
 2hqEU1A2Ihsqm5EC2r9q3CymJAmcD+MNauh8qcdfmYBsLPqu/Z4AIl5TXEn96RB/
 GEEsLGcd0/fO7sbv1+d/RpHQP98LJUAEyi5TqDYniP07HY5epOOwCYA8lsF/5LNb
 S5x7eA5XzAGid9Qx1Uh0i/Jk1cp6PYEwZ9t43MhGY+tDczGKKs3OxbaYKdB8BX3B
 dxGmW5/kJlV3+ELtmAYdDXLe+MXCBxg5U29C6j3y3QQh29wIh0ary8qQh/PbHSGD
 qS/0VSvDjz/Fluvqqe0C9yZ7pr/V9zwGHf141R0yh9l2L2V0P9E7LoR10SouVzWE
 cmIeaWERtMrODjZvniLjOzychCt9etIyyImJHVoBGj2H8Esl56yGLV60iaj6EQPh
 lJbZn2OKnT60jceTsK1WC2YclGtqgTeO8mUO47R/aC7ZdDQOjWFgmlI3+IlYAhgW
 rDiq27skRQ0cbeo/KizU4ZzJycsAW1zZmL+VUGEFJMzjtsLb9ekBvNTAMw6h9Hjf
 9y41/Lx4DgzMYPOP0Rstyq1Vfwgqkhgst18XihfFoLQDp1mWSxshkmY36RBSb6NZ
 glLxNFrN7p7RpPOC6ecVZbFrBfhvp2pE5qMhqXRtWgsc1ZDORgS8fkVmF/eHG2t5
 ZyEkOrkWLNl9pl3uOC3O
 =bLf5
 -----END PGP SIGNATURE-----

Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

User visible fixes:

  - Fix showing the running kernel build id using: (Michael Petlan)

      $ perf buildid-list -k
      03c2a89c595616188f02f0282762a75b47069bc0

  - hists browser (report, top) symbol filter segfault fixes (Wang Nan)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-12-08 06:05:12 +01:00
Ingo Molnar 803ca41856 perf/core improvements and fixes:
User visible:
 
 - Fixes and improvements for supporting annotating ARM binaries, support ARM
   call and jump instructions, more work needed to have arch specific stuff
   separated into tools/perf/arch/*/annotate/ (Russell King)
 
 - Fix several 'perf test' entries broken by recent perf/core changes (Jiri Olsa)
 
 Infrastructure:
 
 - Consolidate perf_ev{list,sel}__{enable,disable}() calls (Jiri Olsa)
 
 - Pass correct string to dso__adjust_kmod_long_name (Wang Nan)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWZgMhAAoJENZQFvNTUqpAunUP/2x5II8HDGVTpjsV5jriyDNU
 vj1XnYaVrEoBQG2EXGRFnQYbrCogB8b5TjMWk01XibOoNPzNUJbTIfCpi0aPFNGl
 YrAUN3paz5lQliUlRV56913dnixammfjsy+c837Kk3HzaKpIdTpo1Unkz94Bjv5i
 4PVMk0YMM4fvBQF3Urg2x4BKhk7sZkDTJvuRtrCDr6WE8X2Eon7TXvYo2QEIUQ5e
 9totlruQFAvpbu08F1gd6RhqtIC3uDcJNX1eEebUJtf4EhJmTAyJ7QhtaRzcmaOk
 IusfXtCvhkLjprjOXLGt4nnhUw3Lnaxno6/Izm9eyJ2JAj8ERIfl9T7Yoc5Ab/Hc
 helKeCgaD2jJgPvldOjm4/ckKkxsxbK1oPZ5FvhKLMIz0mjKZcB5CpYxj0Zzos2g
 BjLIH9sXp9x1j8coeCRyfqOx7tMhY1vCVd4JVbl5/cIWt58+dAXJPcqxRAXUPlpt
 PN+uIaQ2IQa+K++dgQOsNDyUCRIJOvuCEYjhDkqagfccSF85K5v43HFIVS4c5Q1w
 znF9884UhiRhR5SuZqZCQUTwFOk5rsOcX8wliIJCWP2bEaMde1vaMhTAGMXe8Qk+
 6do62hAgSeUTlH2f7eMExRY8/CXQvJmu5O1ukb2mWcSJkNeL8npoCFER1W1gy9Yh
 NDU9dOoKMwOtzyI3STkg
 =CSRu
 -----END PGP SIGNATURE-----

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:

  - Fixes and improvements for supporting annotating ARM binaries, support ARM
    call and jump instructions, more work needed to have arch specific stuff
    separated into tools/perf/arch/*/annotate/ (Russell King)

  - Fix several 'perf test' entries broken by recent perf/core changes (Jiri Olsa)

Infrastructure changes:

  - Consolidate perf_ev{list,sel}__{enable,disable}() calls (Jiri Olsa)

  - Pass correct string to dso__adjust_kmod_long_name() (Wang Nan)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-12-08 05:23:09 +01:00
Russell King cfef25b8da perf annotate: ARM support
Add basic support to parse ARM assembly.

This:

* enables perf to correctly show the disassembly, rather than chopping
  some constants off at the '#' (which is not a comment character on
  ARM).

* allows perf to identify ARM instructions that branch to other parts
  within the same function, thereby properly annotating them.

* allows perf to identify function calls, allowing called functions to
  be followed in the annotated view.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Will Deacon <will.deacon@arm.com>
Link: http://lkml.kernel.org/n/tip-owp1uj0nmcgfrlppfyeetuyf@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:13:00 -03:00
Jiri Olsa c8280cec2a perf stat: Move enable_on_exec setup under earlier code
It's more readable this way and we can save one
perf_evsel__is_group_leader condition in current code.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449133606-14429-7-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:59 -03:00
Jiri Olsa 67ccdecd09 perf stat: Create events as disabled
Currently we have 2 kinds of stat counters based on when the event is
enabled:

  1) tracee command events, which are enable once the
     tracee executes exec syscall (enable_on_exec bit)
  2) all other events which get alive within the
     perf_event_open syscall

And 2) case could raise a problem in case we want additional filter to
be attached for event. In this case we want the event to be enabled
after it's configured with filter.

Changing the behaviour of 2) events, so they all are created as disabled
(disabled bit). Adding extra enable call to make them alive once they
finish setup.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449133606-14429-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:59 -03:00
Jiri Olsa ab46db0a33 perf stat: Use perf_evlist__enable in handle_initial_delay
No need to mimic the behaviour of perf_evlist__enable, we can use it
directly.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449133606-14429-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:58 -03:00
Jiri Olsa 3e27c92081 perf evlist: Factor perf_evlist__(enable|disable) functions
Use perf_evsel__(enable|disable) functions in perf_evlist__(enable|disable)
functions in order to centralize ioctl enable/disable calls. This way we
eliminate 2 places calling directly ioctl.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449133606-14429-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:58 -03:00
Jiri Olsa e98a4cbb01 perf evsel: Introduce disable() method
Adding perf_evsel__disable function to have complement for
perf_evsel__enable function. Both will be used in following patch to
factor perf_evlist__(enable|disable).

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449133606-14429-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:57 -03:00
Jiri Olsa 5cd95fc3f8 perf evsel: Use event maps directly in perf_evsel__enable
All events now share proper cpu and thread maps. There's no need to pass
those maps from evlist, it's safe to use evsel maps for enabling event.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1449133606-14429-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:57 -03:00
Jiri Olsa d6e94fa6b6 perf test: Create kernel maps properly for hist entries test
It fixes segfault within machine__exit, that's caused
but not creating kernel maps for machine.. We're calling
machine__destroy_kernel_maps in machine__exit since commit:

  ebe9729c8c perf machine: Fix to destroy kernel maps when machine exits

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/tip-k4snzv5t4dvdckggzwdzyljo@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:56 -03:00
Jiri Olsa c0651c41e4 perf test: Prevent using bpf-output event in round trip name test
The bpf-output is added under software events, but is not parse-able
within parse_events, which is what round trip test is expecting.

Checking software events only until dummy event.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1449131658-1841-6-git-send-email-jolsa@kernel.org
[ Make it a one liner by keeping __perf_evsel__name_array_test() around ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:56 -03:00
Jiri Olsa 7320b1b3d9 perf test: Fix cpus and thread maps reference in error path
In error path to try user space event, both cpus and threads map now
owned by evlist and freed by perf_evlist__set_maps call.  Getting
reference to keep them alive.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1449131658-1841-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:55 -03:00
Jiri Olsa 0fd4008ed7 perf test: Use machine__new_host in mmap thread code reading test
This is more straightforward than what we have now.

It also fixes a segfault within machine__exit, that's caused
by not creating kernel maps for machine.. We're calling
machine__destroy_kernel_maps in machine__exit since commit:

  ebe9729c8c perf machine: Fix to destroy kernel maps when machine exits

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1449131658-1841-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:55 -03:00
Jiri Olsa 0468479357 perf test: Use machine__new_host in mmap thread lookup test
This is more straightforward than what we have now.

It also fixes a segfault within machine__exit, that's caused by not
creating kernel maps for machine.. We're calling
machine__destroy_kernel_maps in machine__exit since commit:

  ebe9729c8c perf machine: Fix to destroy kernel maps when machine exits

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1449131658-1841-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:54 -03:00
Jiri Olsa bdaba8aee5 perf test: Use machine__new_host in dwarf unwind test
This is more straightforward than what we have now.

It also fixes a segfault within machine__exit, that's caused by not
creating kernel maps for machine.. We're calling
machine__destroy_kernel_maps in machine__exit since commit:

  ebe9729c8c perf machine: Fix to destroy kernel maps when machine exits

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1449131658-1841-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:54 -03:00
Wang Nan 5dcf16df3c perf machine: Pass correct string to dso__adjust_kmod_long_name
There's a mistake in dso__adjust_kmod_long_name() that it use strdup()
to dup the new long_name of a dso, but passes the original string to
dso__set_long_name(). Which causes random crash during cleanup.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Fixes: c03d5184f0 ("perf machine: Adjust dso->long_name for offline module")
Link: http://lkml.kernel.org/r/1449455785-42020-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 18:12:45 -03:00
Wang Nan 4938cf0c7a perf hists browser: Fix segfault if use symbol filter in cmdline
If feed perf a symbol filter in cmdline and the result is empty,
pressing 'Enter' in the hist browser causes crash:

 # ./perf report perf.data   <-- Common mistake for beginners

Then press 'Enter':

 perf: Segmentation fault
 -------- backtrace --------
 /home/wangnan/perf[0x53e578]
 /lib64/libc.so.6(+0x3545f)[0x7f76bafe045f]
 /home/wangnan/perf[0x539dd4]
 /home/wangnan/perf(perf_evlist__tui_browse_hists+0x96)[0x53d216]
 /home/wangnan/perf(cmd_report+0x1b9f)[0x442c7f]
 /home/wangnan/perf[0x47efa2]
 /home/wangnan/perf(main+0x5f5)[0x432fa5]
 /lib64/libc.so.6(__libc_start_main+0xf4)[0x7f76bafccbd4]
 /home/wangnan/perf[0x4330d4]

This is because 'perf.data' is interpreted as a symbol filter, and the
result is empty, so selection is empty. However,
hist_browser__toggle_fold() forgets to check it.

This patch simply return false when selection is NULL.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1449455746-41952-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 12:02:35 -03:00
Wang Nan 979d2cac11 perf hists browser: Reset selection when refresh
With the following steps:

 Step 1: perf report

 Step 2: Use UP/DOWN to select an entry, don't press 'ENTER'

 Step 3: Use '/' to filter symbols, use a filter which returns
         empty result

 Step 4: Press 'ENTER'

We see that, even if we have filtered all the symbols (and the main
interface is empty), pressing 'ENTER' still selects one symbol. This
behavior surprises the user.

This patch resets browser->{he_,}selection in hist_browser__refresh()
and lets it choose default selection. In this case
browser->{he_,}selection keeps NULL so user won't see annotation item in
menu.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1449455746-41952-4-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 12:02:12 -03:00
Wang Nan 837eeb7569 perf hists browser: Add NULL pointer check to prevent crash
Before this patch we can trigger a segfault by following steps:

 Step 0: Use 'perf record' to generate a perf.data without callchain

 Step 1: perf report

 Step 2: Use UP/DOWN to select an entry, don't press 'ENTER'

 Step 3: Use '/' to filter symbols, use a filter which returns
         empty result

 Step 4: Press 'ENTER' (notice here that the old selection is still
		        there. This is another problem)

 Step 5: Press 'ENTER' to annotate that symbol

 Step 6: Press 'LEFT' to go out.

 Result: segfault:

 perf: Segmentation fault
 -------- backtrace --------
 /home/wangnan/perf[0x53e568]
 /lib64/libc.so.6(+0x3545f)[0x7fba75d3245f]
 /home/wangnan/perf[0x537516]
 /home/wangnan/perf[0x533fef]
 /home/wangnan/perf[0x53b347]
 /home/wangnan/perf(perf_evlist__tui_browse_hists+0x96)[0x53d206]
 /home/wangnan/perf(cmd_report+0x1b9f)[0x442c7f]
 /home/wangnan/perf[0x47efa2]
 /home/wangnan/perf(main+0x5f5)[0x432fa5]
 /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fba75d1ebd4]
 /home/wangnan/perf[0x4330d4]

This is because in this case 'nd' could be NULL in
ui_browser__hists_seek(), but that function never checks it.

This patch adds checker for potential NULL pointer in that function.
After this patch the above steps won't segfault.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1449455746-41952-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-12-07 12:02:11 -03:00