1. 26 6月, 2015 2 次提交
  2. 24 6月, 2015 1 次提交
  3. 22 6月, 2015 2 次提交
  4. 20 6月, 2015 1 次提交
  5. 16 6月, 2015 1 次提交
  6. 08 6月, 2015 1 次提交
    • A
      perf tools: Reference count struct dso · d3a7c489
      Arnaldo Carvalho de Melo 提交于
      This has a different model than the 'thread' and 'map' struct lifetimes:
      there is not a definitive "don't use this DSO anymore" event, i.e. we may
      get many 'struct map' holding references to the '/usr/lib64/libc-2.20.so'
      DSO but then at some point some DSO may have no references but we still
      don't want to straight away release its resources, because "soon" we may
      get a new 'struct map' that needs it and we want to reuse its symtab or
      other resources.
      
      So we need some way to garbage collect it when crossing some memory
      usage threshold, which is left for anoter patch, for now it is
      sufficient to release it when calling dsos__exit(), i.e. when deleting
      the whole list as part of deleting the 'struct machine' containing it,
      which will leave only referenced objects being used.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/n/tip-majzgz07cm90t2tejrjy4clf@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d3a7c489
  7. 03 6月, 2015 1 次提交
    • W
      perf tools: Deal with kernel module names in '[]' correctly · 1f121b03
      Wang Nan 提交于
      Before patch ba92732e ('perf kmaps: Check kmaps to make code more
      robust'), 'perf report' and 'perf annotate' will segfault if trace data
      contains kernel module information like this:
      
       # perf report -D -i ./perf.data
       ...
       0 0 0x188 [0x50]: PERF_RECORD_MMAP -1/0: [0xffffffbff1018000(0xf068000) @ 0]: x [test_module]
       ...
      
       # perf report -i ./perf.data --objdump=/path/to/objdump --kallsyms=/path/to/kallsyms
      
       perf: Segmentation fault
       -------- backtrace --------
       /path/to/perf[0x503478]
       /lib64/libc.so.6(+0x3545f)[0x7fb201f3745f]
       /path/to/perf[0x499b56]
       /path/to/perf(dso__load_kallsyms+0x13c)[0x49b56c]
       /path/to/perf(dso__load+0x72e)[0x49c21e]
       /path/to/perf(map__load+0x6e)[0x4ae9ee]
       /path/to/perf(thread__find_addr_map+0x24c)[0x47deec]
       /path/to/perf(perf_event__preprocess_sample+0x88)[0x47e238]
       /path/to/perf[0x43ad02]
       /path/to/perf[0x4b55bc]
       /path/to/perf(ordered_events__flush+0xca)[0x4b57ea]
       /path/to/perf[0x4b1a01]
       /path/to/perf(perf_session__process_events+0x3be)[0x4b428e]
       /path/to/perf(cmd_report+0xf11)[0x43bfc1]
       /path/to/perf[0x474702]
       /path/to/perf(main+0x5f5)[0x42de95]
       /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fb201f23bd4]
       /path/to/perf[0x42dfc4]
      
      This is because __kmod_path__parse treats '[' leading names as kernel
      name instead of names of kernel module.
      
      If perf.data contains build information and the buildid of such modules
      can be found, the dso->kernel of it will be set to DSO_TYPE_KERNEL by
      __event_process_build_id(), not kernel module.
      
      It will then be passed to dso__load() -> dso__load_kernel_sym() ->
      dso__load_kcore() if --kallsyms is provided.
      
      The refered patch adds NULL pointer checker to avoid segfault. However,
      such kernel modules are still processed incorrectly.
      
      This patch fixes __kmod_path__parse, makes it treat names like
      '[test_module]' as kernel modules.
      
      kmod-path.c is also update to reflect the above changes.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/1433321541-170245-1-git-send-email-wangnan0@huawei.com
      [ Fixed the merged with 0443f36b ("perf machine: Fix the search
        for the kernel DSO on the unified list" ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1f121b03
  8. 29 5月, 2015 6 次提交
  9. 28 5月, 2015 1 次提交
  10. 27 5月, 2015 3 次提交
  11. 16 5月, 2015 1 次提交
  12. 12 5月, 2015 3 次提交
    • A
      perf tests: Fix map_groups refcount test · 8b00f469
      Arnaldo Carvalho de Melo 提交于
      When introducing reference counting for struct thread instances I forgot
      to remove the synthetic threads from the machine's rbtree so that it
      then the threads would have just one reference and thus the
      thread__put() replacing the thread__delete() really turns into a
      thread__delete() (thread->refcnt == 1 at thread__put() time) and thus
      drop the thread->mg refcount, as expected by the this test.
      
      Fix it by calling machine__remove_thread() (the counterpart of
      machine__findnew_thread()) on all the synthetic threads after the
      checks that involves the rbtree were done.
      
      Before:
      
        # perf test -v mg
        30: Test thread mg sharing                                 :
        --- start ---
        test child forked, pid 26995
        FAILED tests/thread-mg-share.c:68 wrong refcnt (4 != 3)
        test child finished with -1
        ---- end ----
        Test thread mg sharing: FAILED!
        #
      
      After:
      
        # perf test mg
        30: Test thread mg sharing: Ok
        #
      
      Fixes: b91fc39f ("perf machine: Protect the machine->threads with a rwlock")
      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-uoqq0fjei90ohhhcboz6ay33@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8b00f469
    • A
      perf tests: Show refcounting broken expectations in thread-mg-share test · 8f196013
      Arnaldo Carvalho de Melo 提交于
      To help understand the failure.
      
        [acme@zoo linux]$ perf test -v 30
        30: Test thread mg sharing                                 :
        --- start ---
        test child forked, pid 12275
        FAILED tests/thread-mg-share.c:68 wrong refcnt (4 != 3)
        test child finished with -1
        ---- end ----
        Test thread mg sharing: FAILED!
        [acme@zoo linux]$
      
      This is under investigation, the thread__delete() calls were replaced
      with thread__put(), and those cause mismatches because now we need to be
      more judicious with the thread lifetime management.
      
      I.e. previously the thread__delete() would drop the map_group refcount,
      but now since thread__put doesn't call thread__delete() necessarily.
      because we have other refcount holders, the map_group refcount will not
      be as we expected when this test was implemented.
      
      Will be fixed soon...
      
      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-9y8e3f7ukzco5loxvnlitpfq@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8f196013
    • H
      perf tests: Fix to get negative exit codes · 189c466f
      He Kuang 提交于
      WEXITSTATUS consists of the least significant 8 bits of the status
      argument, so we should convert the value to signed char if we have valid
      negative exit codes. And the return value of test->func() contains
      negative values:
      
        enum {
                TEST_OK   =  0,
                TEST_FAIL = -1,
                TEST_SKIP = -2,
        };
      
      Before this patch:
      
        $ perf test -v 1
        ...
        test child finished with 254
        ---- end ----
        vmlinux symtab matches kallsyms: FAILED!
      
      After this patch:
      
        $ perf test -v 1
        ...
        test child finished with -2
        ---- end ----
        vmlinux symtab matches kallsyms: Skip
      Signed-off-by: NHe Kuang <hekuang@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1431347316-30401-1-git-send-email-hekuang@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      189c466f
  13. 09 5月, 2015 1 次提交
    • A
      perf machine: Protect the machine->threads with a rwlock · b91fc39f
      Arnaldo Carvalho de Melo 提交于
      In addition to using refcounts for the struct thread lifetime
      management, we need to protect access to machine->threads from
      concurrent access.
      
      That happens in 'perf top', where a thread processes events, inserting
      and deleting entries from that rb_tree while another thread decays
      hist_entries, that end up dropping references and ultimately deleting
      threads from the rb_tree and releasing its resources when no further
      hist_entry (or other data structures, like in 'perf sched') references
      it.
      
      So the rule is the same for refcounts + protected trees in the kernel,
      get the tree lock, find object, bump the refcount, drop the tree lock,
      return, use object, drop the refcount if no more use of it is needed,
      keep it if storing it in some other data structure, drop when releasing
      that data structure.
      
      I.e. pair "t = machine__find(new)_thread()" with a "thread__put(t)", and
      "perf_event__preprocess_sample(&al)" with "addr_location__put(&al)".
      
      The addr_location__put() one is because as we return references to
      several data structures, we may end up adding more reference counting
      for the other data structures and then we'll drop it at
      addr_location__put() time.
      Acked-by: NDavid Ahern <dsahern@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      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-bs9rt4n0jw3hi9f3zxyy3xln@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b91fc39f
  14. 06 5月, 2015 1 次提交
  15. 29 4月, 2015 3 次提交
    • J
      perf tools: Add term support for parse_events_error · e64b020b
      Jiri Olsa 提交于
      Allowing event's term processing to report back error, like:
      
        $ perf record -e 'cpu/even=0x1/' ls
        event syntax error: 'cpu/even=0x1/'
                                 \___ unknown term
      
        valid terms: pc,any,inv,edge,cmask,event,in_tx,ldlat,umask,in_tx_cp,offcore_rsp,config,config1,config2,name,period,branch_type
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1429729824-13932-7-git-send-email-jolsa@kernel.org
      [ Renamed 'error' variables to 'err', not to clash with util.h error() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e64b020b
    • J
      perf tools: Add parse_events_error interface · b39b8393
      Jiri Olsa 提交于
      Adding support to return error information from parse_events function.
      Following struct will be populated by parse_events function on return:
      
        struct parse_events_error {
          int   idx;
          char *str;
          char *help;
        };
      
      where 'idx' is the position in the string where the parsing failed,
      'str' contains dynamically allocated error string describing the error
      and 'help' is optional help string.
      
      The change contains reporting function, which currently does not display
      anything. The code changes to supply error data for specific event types
      are coming in next patches. However this is what the expected output is:
      
        $ sudo perf record -e 'sched:krava' ls
        event syntax error: 'sched:krava'
                             \___ unknown tracepoint
        ...
      
        $ perf record -e 'cpu/even=0x1/' ls
        event syntax error: 'cpu/even=0x1/'
                                 \___ unknown term
      
        valid terms: pc,any,inv,edge,cmask,event,in_tx,ldlat,umask,in_tx_cp,offcore_rsp,config,config1,config2,name,period,branch_type
        ...
      
        $ perf record -e cycles,cache-mises ls
        event syntax error: '..es,cache-mises'
                                       \___ parser error
        ...
      
      The output functions cut the beginning of the event string so the error
      starts up to 10th character and cut the end of the string of it crosses
      the terminal width.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1429729824-13932-2-git-send-email-jolsa@kernel.org
      [ Renamed 'error' variables to 'err', not to clash with util.h error() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b39b8393
    • J
      perf tests: Add build tests for building perf from kernel source root and tools · c41c6647
      Jiri Olsa 提交于
      Adding build tests for following make commands:
        $ make -C <kernelsrc> tools/perf
        $ make -C <kernelsrc>/tools perf
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Brian Norris <computersforpeace@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Michal Marek <mmarek@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: linux-kbuild@vger.kernel.org
      Link: http://lkml.kernel.org/r/1429389280-18720-4-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c41c6647
  16. 08 4月, 2015 2 次提交
  17. 22 3月, 2015 1 次提交
    • J
      perf tools: Add kmod_path__parse function · 3c8a67f5
      Jiri Olsa 提交于
      Provides united way of parsing kernel module path
      into several components.
      
      The new kmod_path__parse function and few defines:
      
        int __kmod_path__parse(struct kmod_path *m, const char *path,
                               bool alloc_name, bool alloc_ext);
      
        #define kmod_path__parse(__m, __p)      __kmod_path__parse(__m, __p, false, false)
        #define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , false)
        #define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, true)
      
      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: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung 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.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3c8a67f5
  18. 20 3月, 2015 2 次提交
  19. 12 2月, 2015 1 次提交
  20. 11 2月, 2015 1 次提交
  21. 06 2月, 2015 2 次提交
  22. 23 1月, 2015 1 次提交
  23. 22 1月, 2015 2 次提交