1. 27 1月, 2017 1 次提交
    • A
      perf tools: Propagate perf_config() errors · ecc4c561
      Arnaldo Carvalho de Melo 提交于
      Previously these were being ignored, sometimes silently.
      
      Stop doing that, emitting debug messages and handling the errors.
      
      Testing it:
      
        $ cat ~/.perfconfig
        cat: /home/acme/.perfconfig: No such file or directory
        $ perf stat -e cycles usleep 1
      
         Performance counter stats for 'usleep 1':
      
                 938,996      cycles:u
      
             0.003813731 seconds time elapsed
      
        $ perf top --stdio
        Error:
        You may not have permission to collect system-wide stats.
      
        Consider tweaking /proc/sys/kernel/perf_event_paranoid,
        <SNIP>
        [ perf record: Captured and wrote 0.019 MB perf.data (7 samples) ]
        [acme@jouet linux]$ perf report --stdio
        # To display the perf.data header info, please use --header/--header-only options.
        # Overhead  Command  Shared Object      Symbol
        # ........  .......  .................  .........................
          71.77%  usleep   libc-2.24.so       [.] _dl_addr
          27.07%  usleep   ld-2.24.so         [.] _dl_next_ld_env_entry
           1.13%  usleep   [kernel.kallsyms]  [k] page_fault
        $
        $ touch ~/.perfconfig
        $ ls -la ~/.perfconfig
        -rw-rw-r--. 1 acme acme 0 Jan 27 12:14 /home/acme/.perfconfig
        $
        $ perf stat -e instructions usleep 1
      
         Performance counter stats for 'usleep 1':
      
                 244,610      instructions:u
      
             0.000805383 seconds time elapsed
      
        $
        [root@jouet ~]# chown acme.acme ~/.perfconfig
        [root@jouet ~]# perf stat -e cycles usleep 1
          Warning: File /root/.perfconfig not owned by current user or root, ignoring it.
      
         Performance counter stats for 'usleep 1':
      
                 937,615      cycles
      
             0.000836931 seconds time elapsed
        #
      
      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>
      Link: http://lkml.kernel.org/n/tip-j2rq96so6xdqlr8p8rd6a3jx@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ecc4c561
  2. 26 1月, 2017 1 次提交
    • N
      perf ftrace: Introduce new 'ftrace' tool · d01f4e8d
      Namhyung Kim 提交于
      The 'perf ftrace' command is a simple wrapper of kernel's ftrace
      functionality.  It only supports single thread tracing currently and
      just reads trace_pipe in text and then write it to stdout.
      
      Committer notes:
      
      Testing it:
      
        # perf ftrace -f function_graph usleep 123456
        <SNIP>
        2)               |  SyS_nanosleep() {
        2)               |    _copy_from_user() {
        <SNIP>
        2)   0.900 us    |      }
        2)   1.354 us    |    }
        2)               |    hrtimer_nanosleep() {
        2)   0.062 us    |      __hrtimer_init();
        2)               |      do_nanosleep() {
        2)               |        hrtimer_start_range_ns() {
        <SNIP>
        2)   5.025 us    |        }
        2)               |        schedule() {
        2)   0.125 us    |          rcu_note_context_switch();
        2)   0.057 us    |          _raw_spin_lock();
        2)               |          deactivate_task() {
        2)   0.369 us    |            update_rq_clock.part.77();
        2)               |            dequeue_task_fair() {
        <SNIP>
        2) + 22.453 us   |            }
        2) + 23.736 us   |          }
        2)               |          pick_next_task_fair() {
        <SNIP>
        2) + 47.167 us   |          }
        2)               |          pick_next_task_idle() {
        <SNIP>
        2)   4.462 us    |          }
        ------------------------------------------
        2)  usleep-20387  =>    <idle>-0
        ------------------------------------------
      
        2)   0.806 us    |  switch_mm_irqs_off();
        ------------------------------------------
        2)    <idle>-0    =>  usleep-20387
        ------------------------------------------
      
        2)   0.151 us    |          finish_task_switch();
        2) @ 123597.2 us |        }
        2)   0.037 us    |        _cond_resched();
        2)               |        hrtimer_try_to_cancel() {
        2)   0.064 us    |          hrtimer_active();
        2)   0.353 us    |        }
        2) @ 123605.3 us |      }
        2) @ 123606.2 us |    }
        2) @ 123608.3 us |  } /* SyS_nanosleep */
        2)               |  __do_page_fault() {
       <SNIP>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jeremy Eder <jeder@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>,
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/n/tip-r1hgmsj4dxny8arn3o9mw512@git.kernel.org
      [ Various foward port fixes, add man page ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d01f4e8d
  3. 17 1月, 2017 1 次提交
  4. 12 1月, 2017 1 次提交
    • A
      perf kallsyms: Introduce tool to look for extended symbol information on the running kernel · 35563771
      Arnaldo Carvalho de Melo 提交于
      Its similar to doing grep on a /proc/kallsyms, but it also shows extra
      information like the path to the kernel module and the unrelocated
      addresses in it, to help in diagnosing problems.
      
      It is also helps demonstrate the use of the symbols routines so that
      tool writers can use them more effectively.
      
      Using it:
      
        $ perf kallsyms e1000_xmit_frame netif_rx usb_stor_set_xfer_buf
        e1000_xmit_frame: [e1000e] /lib/modules/4.9.0+/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko 0xffffffffc046fc10-0xffffffffc0470bb0 (0x19c80-0x1ac20)
        netif_rx: [kernel] [kernel.kallsyms] 0xffffffff916f03a0-0xffffffff916f0410 (0xffffffff916f03a0-0xffffffff916f0410)
        usb_stor_set_xfer_buf: [usb_storage] /lib/modules/4.9.0+/kernel/drivers/usb/storage/usb-storage.ko 0xffffffffc057aea0-0xffffffffc057af19 (0xf10-0xf89)
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-79bk9pakujn4l4vq0f90klv3@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      35563771
  5. 20 10月, 2016 1 次提交
  6. 15 7月, 2016 1 次提交
  7. 13 7月, 2016 2 次提交
  8. 24 6月, 2016 1 次提交
    • T
      perf config: Introduce new init() and exit() · 8a0a9c7e
      Taeung Song 提交于
      Many sub-commands use perf_config() but everytime perf_config() is
      called, perf_config() always read config files.  (i.e. user config
      '~/.perfconfig' and system config '$(sysconfdir)/perfconfig')
      
      But it is better to use the config set that already contains all config
      key-value pairs to avoid this repetitive work reading the config files
      in perf_config(). (the config set mean a static variable 'config_set')
      
      In other words, if new perf_config__init() is called, only first time
      'config_set' is initialized collecting all configs from the config
      files.  And then we could use new perf_config() like old perf_config().
      When a sub-command finished, free the config set by perf_config__exit()
      at run_builtin().
      
      If we do, 'config_set' can be reused wherever perf_config() is called
      and a feature of old perf_config() is the same as new perf_config() work
      without the repetitive work that read the config files.
      
      In summary, in order to use features about configuration,
      we can call the functions at perf.c and other source files as below.
      
          # initialize a config set
          perf_config__init()
      
          # configure actual variables from a config set
          perf_config()
      
          # eliminate allocated config set
          perf_config__exit()
      
          # destroy existing config set and initialize a new config set.
          perf_config__refresh()
      Signed-off-by: NTaeung Song <treeze.taeung@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1466691272-24117-3-git-send-email-treeze.taeung@gmail.com
      [ 'init' counterpart is 'exit', not 'finish' ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8a0a9c7e
  9. 23 6月, 2016 1 次提交
  10. 22 6月, 2016 1 次提交
  11. 17 5月, 2016 1 次提交
    • A
      perf tools: Separate accounting of contexts and real addresses in a stack trace · a29d5c9b
      Arnaldo Carvalho de Melo 提交于
      The perf_sample->ip_callchain->nr value includes all the entries in the
      ip_callchain->ip[] array, real addresses and PERF_CONTEXT_{KERNEL,USER,etc},
      while what the user expects is that what is in the kernel.perf_event_max_stack
      sysctl or in the upcoming per event perf_event_attr.sample_max_stack knob be
      honoured in terms of IP addresses in the stack trace.
      
      So match the kernel support and validate chain->nr taking into account
      both kernel.perf_event_max_stack and kernel.perf_event_max_contexts_per_stack.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/n/tip-mgx0jpzfdq4uq4abfa40byu0@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a29d5c9b
  12. 10 5月, 2016 1 次提交
  13. 27 4月, 2016 1 次提交
  14. 30 3月, 2016 1 次提交
  15. 27 2月, 2016 1 次提交
  16. 25 2月, 2016 1 次提交
  17. 17 2月, 2016 1 次提交
  18. 09 1月, 2016 1 次提交
    • N
      perf report: Show random usage tip on the help line · 14cbfbeb
      Namhyung Kim 提交于
      Currently perf report only shows a help message "For a higher level
      overview, try: perf report --sort comm,dso" unconditionally (even if
      the sort keys were used).  Add more help tips and show randomly.
      
      Load tips from ${prefix}/share/doc/perf-tip/tips.txt file.
      
        $ perf report | tail
            0.10%  swapper  [kernel.vmlinux]   [k] irq_exit
            0.09%  swapper  [kernel.vmlinux]   [k] flush_smp_call_function_queue
            0.08%  swapper  [kernel.vmlinux]   [k] native_write_msr_safe
            0.03%  swapper  [kernel.vmlinux]   [k] group_sched_in
            0.01%  perf     [kernel.vmlinux]   [k] native_write_msr_safe
      
        #
        # (Tip: Search options using a keyword: perf report -h <keyword>)
        #
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NIngo Molnar <mingo@kernel.org>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1452166913-27046-1-git-send-email-namhyung@kernel.org
      [ Renamed it to perf_tip() and the parameter dirname to dirpath to fix the build on older distros ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      14cbfbeb
  19. 18 12月, 2015 1 次提交
  20. 17 12月, 2015 2 次提交
  21. 10 12月, 2015 1 次提交
  22. 24 11月, 2015 1 次提交
  23. 28 10月, 2015 1 次提交
    • W
      perf tools: Enable passing bpf object file to --event · 84c86ca1
      Wang Nan 提交于
      By introducing new rules in tools/perf/util/parse-events.[ly], this
      patch enables 'perf record --event bpf_file.o' to select events by an
      eBPF object file. It calls parse_events_load_bpf() to load that file,
      which uses bpf__prepare_load() and finally calls bpf_object__open() for
      the object files.
      
      After applying this patch, commands like:
      
       # perf record --event foo.o sleep
      
      become possible.
      
      However, at this point it is unable to link any useful things onto the
      evsel list because the creating of probe points and BPF program
      attaching have not been implemented.  Before real events are possible to
      be extracted, to avoid perf report error because of empty evsel list,
      this patch link a dummy evsel. The dummy event related code will be
      removed when probing and extracting code is ready.
      
      Commiter notes:
      
      Using it:
      
        $ ls -la foo.o
        ls: cannot access foo.o: No such file or directory
        $ perf record --event foo.o sleep
        libbpf: failed to open foo.o: No such file or directory
        event syntax error: 'foo.o'
                             \___ BPF object file 'foo.o' is invalid
      
        (add -v to see detail)
        Run 'perf list' for a list of valid events
      
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
        $
      
        $ file /tmp/build/perf/perf.o
        /tmp/build/perf/perf.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
        $ perf record --event /tmp/build/perf/perf.o sleep
        libbpf: /tmp/build/perf/perf.o is not an eBPF object file
        event syntax error: '/tmp/build/perf/perf.o'
                             \___ BPF object file '/tmp/build/perf/perf.o' is invalid
      
        (add -v to see detail)
        Run 'perf list' for a list of valid events
      
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
        $
      
        $ file /tmp/foo.o
        /tmp/foo.o: ELF 64-bit LSB relocatable, no machine, version 1 (SYSV), not stripped
        $ perf record --event /tmp/foo.o sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.013 MB perf.data ]
        $ perf evlist
        /tmp/foo.o
        $ perf evlist  -v
        /tmp/foo.o: type: 1, size: 112, config: 0x9, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
        $
      
      So, type 1 is PERF_TYPE_SOFTWARE, config 0x9 is PERF_COUNT_SW_DUMMY, ok.
      
        $ perf report --stdio
        Error:
        The perf.data file has no samples!
        # To display the perf.data header info, please use --header/--header-only options.
        #
        $
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1444826502-49291-4-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      84c86ca1
  24. 06 10月, 2015 1 次提交
  25. 14 9月, 2015 1 次提交
    • A
      perf env: Introduce read_cpu_topology_map() method · aa36ddd7
      Arnaldo Carvalho de Melo 提交于
      Out of the code to write the cpu topology map in the perf.data file
      header.
      
      Now if one needs the CPU topology map for the running machine, one needs
      to call perf_env__read_cpu_topology_map(perf_env) and the info will be
      stored in perf_env.cpu.
      
      For now we're using a global perf_env variable, that will have its
      contents freed after we run a builtin.
      
      v2: Check perf_env__read_cpu_topology_map() return in
          write_cpu_topology() (Kan Liang)
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1441828225-667-5-git-send-email-acme@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      aa36ddd7
  26. 04 9月, 2015 1 次提交
  27. 03 9月, 2015 2 次提交
  28. 29 8月, 2015 1 次提交
  29. 28 2月, 2015 2 次提交
  30. 25 2月, 2015 1 次提交
  31. 09 12月, 2014 1 次提交
  32. 15 8月, 2014 1 次提交
  33. 28 7月, 2014 1 次提交
  34. 17 7月, 2014 1 次提交
    • J
      perf tools: Add --debug optionto set debug variable · bbb2cea7
      Jiri Olsa 提交于
      Adding --debug option as a way to setup debug variables.  Starting with
      support for verbose, more will come.
      
      It's possible to use it now with report command:
        $ perf --debug verbose   ...
        $ perf --debug verbose=2 ...
      
      I'll need this support to add separated debug variable for ordered
      events change in order to separate debug output out of standard verbose
      stream.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@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/20140717105500.GG516@krava.redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bbb2cea7
  35. 09 6月, 2014 1 次提交
  36. 04 6月, 2014 1 次提交
    • A
      perf trace: Warn the user when not available · 1b572622
      Arnaldo Carvalho de Melo 提交于
      When the audit-libs devel package is not found at build time we disable
      the 'trace' command, as we are not able to map syscall numbers to
      strings, but then the message the user is presented is cryptic:
      
        [root@zoo linux]# trace ls
        perf: 'ls' is not a perf-command. See 'perf --help'.
      
      Fix it by presenting a more helpful message:
      
        [root@zoo linux]# trace l
        trace command not available: missing audit-libs devel package at build time.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-uxeunqetd0sgxyibusapen9a@git.kernel.orgSigned-off-by: NJiri Olsa <jolsa@kernel.org>
      1b572622