1. 22 2月, 2016 3 次提交
    • N
      perf tools: Fix segfault on dynamic entries · 665aa757
      Namhyung Kim 提交于
      A dynamic entry is created for each tracepoint event.  When it sets up
      the sort key, it checks with existing keys using ->equal() callback.
      But it missed to set the ->equal for dynamic entries.  The following
      segfault was due to the missing ->equal() callback.
      
        (gdb) bt
        #0  0x0000000000140003 in ?? ()
        #1  0x0000000000537769 in fmt_equal (b=0x2106980, a=0x21067a0) at ui/hist.c:548
        #2  perf_hpp__setup_output_field (list=0x8c6d80 <perf_hpp_list>) at ui/hist.c:560
        #3  0x00000000004e927e in setup_sorting (evlist=<optimized out>) at util/sort.c:2642
        #4  0x000000000043cf50 in cmd_report (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>)
            at builtin-report.c:932
        #5  0x00000000004865a1 in run_builtin (p=p@entry=0x8bbce0 <commands+192>, argc=argc@entry=7,
            argv=argv@entry=0x7ffd24d56ce0) at perf.c:390
        #6  0x000000000042dc1f in handle_internal_command (argv=0x7ffd24d56ce0, argc=7) at perf.c:451
        #7  run_argv (argv=0x7ffd24d56a70, argcp=0x7ffd24d56a7c) at perf.c:495
        #8  main (argc=7, argv=0x7ffd24d56ce0) at perf.c:620
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1456064558-13086-2-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      665aa757
    • A
      perf tools: Remove duplicate typedef config_term_func_t definition · 58de6ed0
      Arnaldo Carvalho de Melo 提交于
      Older compilers don't like this, for instance, on RHEL6.7:
      
          CC       /tmp/build/perf/util/parse-events.o
        util/parse-events.c:844: error: redefinition of typedef ‘config_term_func_t’
        util/parse-events.c:353: note: previous declaration of ‘config_term_func_t’ was here
      
      So remove the second definition, that should've been just moved in 43d0b978
      ("perf tools: Enable config and setting names for legacy cache events"), not copied.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 43d0b978 ("perf tools: Enable config and setting names for legacy cache events")
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      58de6ed0
    • A
      perf tools: Fix build on older systems · 2c97b0d4
      Arnaldo Carvalho de Melo 提交于
      In RHEL 6.7:
      
        CC       /tmp/build/perf/util/parse-events.o
        cc1: warnings being treated as errors
        util/parse-events.c: In function ‘parse_events_add_cache’:
        util/parse-events.c:366: error: declaration of ‘error’ shadows a global declaration
        util/util.h:136: error: shadowed declaration is here
      
      Rename it to 'err'.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 43d0b978 ("perf tools: Enable config and setting names for legacy cache events")
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2c97b0d4
  2. 20 2月, 2016 20 次提交
  3. 18 2月, 2016 2 次提交
    • J
      perf record: Add --all-user/--all-kernel options · 85723885
      Jiri Olsa 提交于
      Allow user to easily switch all events to user or kernel space with simple
      --all-user or --all-kernel options.
      
      This will be handy within perf mem/c2c wrappers to switch easily monitoring
      modes.
      
      Committer note:
      
      Testing it:
      
        # perf record --all-kernel --all-user -a sleep 2
         Error: option `all-user' cannot be used with all-kernel
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
              --all-user        Configure all used events to run in user space.
              --all-kernel      Configure all used events to run in kernel space.
        # perf record --all-user --all-kernel -a sleep 2
         Error: option `all-kernel' cannot be used with all-user
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
              --all-kernel      Configure all used events to run in kernel space.
              --all-user        Configure all used events to run in user space.
        # perf record --all-user -a sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.416 MB perf.data (162 samples) ]
        # perf report | grep '\[k\]'
        # perf record --all-kernel -a sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.423 MB perf.data (296 samples) ]
        # perf report | grep '\[\.\]'
        #
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1455525293-8671-2-git-send-email-jolsa@kernel.org
      [ Made those options to be mutually exclusive ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      85723885
    • A
      perf evlist: Reference count the cpu and thread maps at set_maps() · a55e5663
      Arnaldo Carvalho de Melo 提交于
      We were dropping the reference we possibly held but not obtaining one
      for the new maps, which we will drop at perf_evlist__delete(), fix it.
      
      This was caught by Steven Noonan in some of the machines which would
      produce this output when caught by glibc debug mechanisms:
      
        $ sudo perf test 21
        21: Test object code reading                                 :***
        Error in `perf': corrupted double-linked list: 0x00000000023ffcd0 ***
        ======= Backtrace: =========
        /usr/lib/libc.so.6(+0x72055)[0x7f25be0f3055]
        /usr/lib/libc.so.6(+0x779b6)[0x7f25be0f89b6]
        /usr/lib/libc.so.6(+0x7a0ed)[0x7f25be0fb0ed]
        /usr/lib/libc.so.6(__libc_calloc+0xba)[0x7f25be0fceda]
        perf(parse_events_lex_init_extra+0x38)[0x4cfff8]
        perf(parse_events+0x55)[0x4a0615]
        perf(perf_evlist__config+0xcf)[0x4eeb2f]
        perf[0x479f82]
        perf(test__code_reading+0x1e)[0x47ad4e]
        perf(cmd_test+0x5dd)[0x46452d]
        perf[0x47f4e3]
        perf(main+0x603)[0x42c723]
        /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f25be0a1610]
        perf(_start+0x29)[0x42c859]
      
      Further investigation using valgrind led to the reference count imbalance fixed
      in this patch.
      Reported-and-Tested-by: NSteven Noonan <steven@uplinklabs.net>
      Report-Link: http://lkml.kernel.org/r/CAKbGBLjC2Dx5vshxyGmQkcD+VwiAQLbHoXA9i7kvRB2-2opHZQ@mail.gmail.com
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: f30a79b0 ("perf tools: Add reference counting for cpu_map object")
      Link: http://lkml.kernel.org/n/tip-j0u1bdhr47sa511sgg76kb8h@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a55e5663
  4. 17 2月, 2016 10 次提交
  5. 16 2月, 2016 1 次提交
    • A
      perf tests: Fix build on older systems where 'signal' is reserved · 1ad826ba
      Arnaldo Carvalho de Melo 提交于
      fixing the following problems, for instance, on RHEL6.7:
      
          CC       /tmp/build/perf/tests/bp_signal.o
        cc1: warnings being treated as errors
        tests/bp_signal.c: In function ‘__event’:
        tests/bp_signal.c:106: error: declaration of ‘signal’ shadows a global declaration
        /usr/include/signal.h:101: error: shadowed declaration is here
        tests/bp_signal.c: In function ‘bp_event’:
        tests/bp_signal.c:144: error: declaration of ‘signal’ shadows a global declaration
        /usr/include/signal.h:101: error: shadowed declaration is here
        tests/bp_signal.c: In function ‘wp_event’:
        tests/bp_signal.c:149: error: declaration of ‘signal’ shadows a global declaration
        /usr/include/signal.h:101: error: shadowed declaration is here
        mv: cannot stat `/tmp/build/perf/tests/.bp_signal.o.tmp': No such file or directory
        make[3]: *** [/tmp/build/perf/tests/bp_signal.o] Error 1
        make[2]: *** [tests] Error 2
        make[1]: *** [/tmp/build/perf/perf-in.o] Error 2
        make[1]: *** Waiting for unfinished jobs....
      Reported-by: NVinson Lee <vlee@freedesktop.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: pi3orama@163.com
      Fixes: 8fd34e1c ("perf test: Improve bp_signal")
      Link: http://lkml.kernel.org/n/tip-wlpx6tik1b0jirlkw64bv400@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1ad826ba
  6. 13 2月, 2016 4 次提交
    • W
      perf data: Fix releasing event_class · 5141d735
      Wang Nan 提交于
      A new patch in libbabeltrace [1] reveals a object leak problem in
      'perf data' CTF support: perf code never releases the event_class
      which is allocated in add_event() and stored in evsel's private field.
      
      If libbabeltrace has the above patch applied, leaking event_class
      prevents the writer from being destroyed and flushing metadata. For
      example:
      
        $ perf record ls
        perf.data
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.012 MB perf.data (12 samples) ]
        $ perf data convert --to-ctf ./out.ctf
        [ perf data convert: Converted 'perf.data' into CTF data './out.ctf' ]
        [ perf data convert: Converted and wrote 0.000 MB (12 samples) ]
        $ cat ./out.ctf/metadata
        $ ls -l  ./out.ctf/metadata
        -rw-r----- 1 w00229757 mm 0 Jan 27 10:49 ./out.ctf/metadata
      
      The correct result should be:
        ...
        $ cat ./out.ctf/metadata
        /* CTF 1.8 */
      
        trace {
        [SNIP]
      
        $ ls -l  ./out.ctf/metadata
        -rw-r----- 1 w00229757 mm 2446 Jan 27 10:52 ./out.ctf/metadata
      
      The full story is:
      
      Patch [1] of babeltrace redesigns its reference counting scheme. In that
      patch:
      
       * writer <- trace (bt_ctf_writer_create)
       * trace <- stream_class (bt_ctf_trace_add_stream_class)
       * stream_class <- event_class (bt_ctf_stream_class_add_event_class)
       ('<-' means 'is a parent of')
      
      Holding of event_class causes reference count of corresponding 'writer'
      to increase through parent chain. Perf expects that 'writer' is released
      (so metadata is flushed) through bt_ctf_writer_put() in
      ctf_writer__cleanup(). However, since it never releases event_class, the
      reference of 'writer' won't be dropped, so bt_ctf_writer_put() won't
      lead to the release of writer.
      
      Before this CTF patch, !(writer <- trace). Even with event_class leaking,
      the writer ends up being released.
      
      [1] https://github.com/efficios/babeltrace/commit/e6a8e8e4744633807083a077ff9f101eb97d9801Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Cody P Schafer <dev@codyps.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
      Cc: Kirill Smelkov <kirr@nexedi.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1454680939-24963-6-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5141d735
    • A
      perf tools: Rename parse_events__free_terms() to parse_events_terms__delete() · 2146afc6
      Arnaldo Carvalho de Melo 提交于
      To follow convention used in other tools/perf/ areas. Also remove the
      need to check if it is NULL before calling the destructor, again, to
      follow convention that goes back to free().
      
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/n/tip-w6owu7rb8a46gvunlinxaqwx@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2146afc6
    • W
      perf tools: Free the terms list_head in parse_events__free_terms() · d20a5f2b
      Wang Nan 提交于
      Fixing a leak, since code calling parse_events__free_terms() expect it
      to free the list_head too.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      [ Spun off from another patch ]
      Link: http://lkml.kernel.org/r/1454680939-24963-2-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d20a5f2b
    • A
      perf tools: Use perf_event_terms__purge() for non-malloced terms · 682dc24c
      Arnaldo Carvalho de Melo 提交于
      In these two cases, a 'perf test' entry and in the PMU code the
      list_head is on the stack, so we can't use perf_event__free_terms()
      (soon to be renamed to perf_event_terms__delete()), because it will
      free the list_head as well.
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/n/tip-i956ryjhz97gnnqe8iqe7m7s@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      682dc24c