1. 13 7月, 2016 1 次提交
    • A
      tools: Introduce str_error_r() · c8b5f2c9
      Arnaldo Carvalho de Melo 提交于
      The tools so far have been using the strerror_r() GNU variant, that
      returns a string, be it the buffer passed or something else.
      
      But that, besides being tricky in cases where we expect that the
      function using strerror_r() returns the error formatted in a provided
      buffer (we have to check if it returned something else and copy that
      instead), breaks the build on systems not using glibc, like Alpine
      Linux, where musl libc is used.
      
      So, introduce yet another wrapper, str_error_r(), that has the GNU
      interface, but uses the portable XSI variant of strerror_r(), so that
      users rest asured that the provided buffer is used and it is what is
      returned.
      
      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-d4t42fnf48ytlk8rjxs822tf@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c8b5f2c9
  2. 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
  3. 23 6月, 2016 1 次提交
  4. 22 6月, 2016 1 次提交
  5. 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
  6. 10 5月, 2016 1 次提交
  7. 27 4月, 2016 1 次提交
  8. 30 3月, 2016 1 次提交
  9. 27 2月, 2016 1 次提交
  10. 25 2月, 2016 1 次提交
  11. 17 2月, 2016 1 次提交
  12. 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
  13. 18 12月, 2015 1 次提交
  14. 17 12月, 2015 2 次提交
  15. 10 12月, 2015 1 次提交
  16. 24 11月, 2015 1 次提交
  17. 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
  18. 06 10月, 2015 1 次提交
  19. 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
  20. 04 9月, 2015 1 次提交
  21. 03 9月, 2015 2 次提交
  22. 29 8月, 2015 1 次提交
  23. 28 2月, 2015 2 次提交
  24. 25 2月, 2015 1 次提交
  25. 09 12月, 2014 1 次提交
  26. 15 8月, 2014 1 次提交
  27. 28 7月, 2014 1 次提交
  28. 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
  29. 09 6月, 2014 1 次提交
  30. 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
  31. 17 12月, 2013 1 次提交
    • B
      tools/: Convert to new topic libraries · 553873e1
      Borislav Petkov 提交于
      Move debugfs.* to api/fs/. We have a common tools/lib/api/ place where
      the Makefile lives and then we place the headers in subdirs.
      
      For example, all the fs-related stuff goes to tools/lib/api/fs/ from
      which we get libapikfs.a (acme got almost the naming he wanted :-)) and
      we link it into the tools which need it - in this case perf and
      tools/vm/page-types.
      
      acme:
      
      "Looking at the implementation, I think some tools can even link
      directly to the .o files, avoiding the .a file altogether.
      
      But that is just an optimization/finer granularity tools/lib/
      cherrypicking that toolers can make use of."
      
      Fixup documentation cleaning target while at it.
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Robert Richter <rric@kernel.org>
      Cc: Stanislav Fomichev <stfomichev@yandex-team.ru>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/1386605664-24041-2-git-send-email-bp@alien8.deSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      553873e1
  32. 11 10月, 2013 1 次提交
    • A
      perf trace: Add 'trace' alias to 'perf trace' · b52bc234
      Arnaldo Carvalho de Melo 提交于
      Make 'perf trace' more accessible by aliasing it to just 'trace':
      
        [root@zoo linux]# trace --duration 15 -a -e futex sleep 1
         110.092 (16.188 ms): libvirtd/1166 futex(uaddr: 0x185b344, op: WAIT|PRIV, val: 174293                    ) = 0
         110.101 (15.903 ms): libvirtd/1171 futex(uaddr: 0x185b3dc, op: WAIT|PRIV, val: 139265                    ) = 0
         111.594 (15.776 ms): libvirtd/1165 futex(uaddr: 0x185b344, op: WAIT|PRIV, val: 174295                    ) = 0
         111.610 (15.969 ms): libvirtd/1169 futex(uaddr: 0x185b3dc, op: WAIT|PRIV, val: 139267                    ) = 0
         113.556 (16.216 ms): libvirtd/1168 futex(uaddr: 0x185b3dc, op: WAIT|PRIV, val: 139269                    ) = 0
         291.265 (199.508 ms): chromium-brows/15830 futex(uaddr: 0x7fff2986bcb4, op: WAIT_BITSET|PRIV|CLKRT, val: 1, utime: 0x7fff2986bab0, val3: 4294967295) = -1 ETIMEDOUT Connection timed out
           360.354 (69.053 ms): chromium-brows/15830 futex(uaddr: 0x7fff2986bcb4, op: WAIT_BITSET|PRIV|CLKRT, val: 1, utime: 0x7fff2986bab0, val3: 4294967295) = -1 ETIMEDOUT Connection timed out
        [root@zoo linux]#
      
      I.e. looking for futex calls that take at least 15ms, system wide, during a one
      second window. Now to get callchains into 'trace' to figure out what are those
      locks :-)
      Requested-by: NIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      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-ch4smqz8b5fmgrte7c5e4fuw@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b52bc234
  33. 09 10月, 2013 2 次提交
  34. 01 4月, 2013 2 次提交
  35. 16 3月, 2013 1 次提交