1. 03 Mar, 2015 3 commits
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 94ac003b
      Ingo Molnar authored
      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:
      
        - Warn if given uprobe event accesses memory on older kernel (Masami Hiramatsu)
      
        - 'perf record' Documentation fixes (Namhyung Kim)
      
        - Report unsupported events properly in 'perf stat' (Suzuki K. Poulose)
      
      Infrastructure changes:
      
        - Avoid FORK after COMM when synthesizing records for pre-existing threads (Arnaldo Carvalho de Melo)
      
        - Reference count struct thread (Arnaldo Carvalho de Melo)
      
        - Don't keep the session around in 'perf sched', thread refcounting removes that need (Arnaldo Carvalho de Melo)
      
        - Initialize cpu set in pthread_attr_setaffinity_np() feature test (Adrian Hunter)
      
        - Only include tsc file for x86 (David Ahern)
      
        - Compare JOBS to 0 after grep (David Ahern)
      
        - Improve feature detection messages (Ingo Molnar)
      
        - Revert "perf: Remove the extra validity check on nr_pages" (Kan Liang)
      
        - Remove bias offset to find probe point by address (Masami Hiramatsu)
      
        - Fix build error on ARCH=i386/x86_64/sparc64 (Namhyung Kim)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      94ac003b
    • Arnaldo Carvalho de Melo's avatar
      perf sched: No need to keep the session around · ae536acf
      Arnaldo Carvalho de Melo authored
      We were keeping the session around just because we kept pointers to
      struct thread instances, but now we reference count them, so no need
      for deferring the perf_session__delete call to after we traverse the
      work_list entries.
      
      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-9agtck6jdr3rebdp39z1lo0e@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae536acf
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Reference count struct thread · f3b623b8
      Arnaldo Carvalho de Melo authored
      We need to do that to stop accumulating entries in the dead_threads
      linked list, i.e. we were keeping references to threads in struct hists
      that continue to exist even after a thread exited and was removed from
      the machine threads rbtree.
      
      We still keep the dead_threads list, but just for debugging, allowing us
      to iterate at any given point over the threads that still are referenced
      by things like struct hist_entry.
      
      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-3ejvfyed0r7ue61dkurzjux4@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f3b623b8
  2. 02 Mar, 2015 19 commits
  3. 01 Mar, 2015 1 commit
  4. 28 Feb, 2015 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 788b94ba
      Ingo Molnar authored
      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:
      
        - Fix SIGBUS failures due to misaligned accesses in Sparc64 (David Ahern)
      
        - Fix branch stack mode in 'perf report' (He Kuang)
      
        - Fix a 'perf probe' operator precedence bug (He Kuang)
      
        - Fix Support for different binaries with same name in 'perf diff' (Kan Liang)
      
        - Check kprobes blacklist when adding new events via 'perf probe' (Masami Hiramatsu)
      
        - Add --purge FILE to remove all caches of FILE in 'perf buildid-cache' (Masami Hiramatsu)
      
        - Show usage with some incorrect params (Masami Hiramatsu)
      
        - Add new buildid cache if update target is not cached in 'buildid-cache' (Masami Hiramatsu)
      
        - Allow listing events with 'tracepoint' prefix in 'perf list' (Yunlong Song)
      
        - Sort the output of 'perf list' (Yunlong Song)
      
        - Fix bash completion of 'perf --' (Yunlong Song)
      
      Developer Zone:
      
        - Handle strdup() failure path in 'perf probe' (Arnaldo Carvalho de Melo)
      
        - Fix get_real_path to free allocated memory in error path in 'perf probe' (Masami Hiramatsu)
      
        - Use pr_debug instead of verbose && pr_info perf buildid-cache (Masami Hiramatsu)
      
        - Fix building of 'perf data' with some gcc versions due to incorrect array struct
          entry (Yunlong Song)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      788b94ba
  5. 27 Feb, 2015 16 commits
    • He Kuang's avatar
      perf report: Fix branch stack mode cannot be set · fefd2d96
      He Kuang authored
      When perf.data file is obtained using 'perf record -b', perf report
      should use branch stack mode to generate output. But this function is
      broken by improper comparison between boolean and constant -1.
      
      before this patch:
      
        $ perf report -b -i perf.data
        Samples: 16  of event 'cycles', Event count (approx.): 3171896
        Overhead  Command  Shared Object      Symbol
          13.59%  ls       [kernel.kallsyms]  [k] prio_tree_remove
          13.16%  ls       [kernel.kallsyms]  [k] change_pte_range
          12.09%  ls       [kernel.kallsyms]  [k] page_fault
          12.02%  ls       [kernel.kallsyms]  [k] zap_pte_range
        ...
      
      after this patch:
      
        $ perf report -b -i perf.data
        Samples: 256  of event 'cycles', Event count (approx.): 256
        Overhead  Command  Source Shared Object  Source Symbol                               Target Shared Object  Target Symbol
           9.38%  ls       [unknown]             [k] 0000000000000000                        [unknown]             [k] 0000000000000000
           6.25%  ls       libc-2.19.so          [.] _dl_addr                                libc-2.19.so          [.] _dl_addr
           6.25%  ls       [kernel.kallsyms]     [k] zap_pte_range                           [kernel.kallsyms]     [k] zap_pte_range
           6.25%  ls       [kernel.kallsyms]     [k] change_pte_range                        [kernel.kallsyms]     [k] change_pte_range
           0.39%  ls       [kernel.kallsyms]     [k] prio_tree_remove                        [kernel.kallsyms]     [k] prio_tree_remove
        ...
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1423967617-28879-1-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fefd2d96
    • Masami Hiramatsu's avatar
      perf buildid-cache: Show usage with incorrect params · 0497d0a8
      Masami Hiramatsu authored
      Show usage if no action is specified or unexpected parameter is given.
      In other words, be more user friendly.
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      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/20150227045030.1999.44006.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0497d0a8
    • Masami Hiramatsu's avatar
      perf buildid-cache: Use pr_debug instead of verbose && pr_info · cc169c7c
      Masami Hiramatsu authored
      Use pr_debug instead of the combination of verbose and pr_info.
      
      "if (verbose) pr_info(...)" is same as "pr_debug(...)", replace it.
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Suggested-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20150227045028.1999.93137.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cc169c7c
    • Masami Hiramatsu's avatar
      perf buildid-cache: Add --purge FILE to remove all caches of FILE · 8d8c8e4c
      Masami Hiramatsu authored
      Add --purge FILE to remove all caches of FILE.
      
      Since the current --remove FILE removes a cache which has
      same build-id of given FILE. Since the command takes a
      FILE path, it can confuse user who tries to remove cache
      about FILE path.
      
        -----
        # ./perf buildid-cache -v --add ./perf
        Adding 133b7b5486d987a5ab5c3ebf4ea14941f45d4d4f ./perf: Ok
        # (update the ./perf binary)
        # ./perf buildid-cache -v --remove ./perf
        Removing 305bbd1be68f66eca7e2d78db294653031edfa79 ./perf: FAIL
        ./perf wasn't in the cache
        -----
      Actually, the --remove's FAIL is not shown, it just silently fails.
      
      So, this patch adds --purge FILE action for such usecase.
      
      perf buildid-cache --purge FILE removes all caches which has same FILE
      path.
      
      In other words, it removes all caches including old binaries.
      
        -----
        # ./perf buildid-cache -v --add ./perf
        Adding 133b7b5486d987a5ab5c3ebf4ea14941f45d4d4f ./perf: Ok
        # (update the ./perf binary)
        # ./perf buildid-cache -v --purge ./perf
        Removing 133b7b5486d987a5ab5c3ebf4ea14941f45d4d4f ./perf: Ok
        -----
      
      BTW, if you want to purge all the caches, remove ~/.debug/* .
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      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/20150227045026.1999.64084.stgit@localhost.localdomain
      [ s/dirname/dir_name/g to fix build on fedora14, where dirname is a global ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8d8c8e4c
    • Yunlong Song's avatar
      perf tools: Fix the bash completion problem of 'perf --*' · 7335399a
      Yunlong Song authored
      The perf-completion.sh uses a predefined string '--help --version
      --exec-path --html-path --paginate --no-pager --perf-dir --work-tree
      --debugfs-dir' for the bash completion of 'perf --*', which has two
      problems:
      
       Problem 1: If the options of perf are changed (see handle_options() in
       perf.c), the perf-completion.sh has to be changed at the same time. If
       not, the bash completion of 'perf --*' and the options which perf
       really supports will be inconsistent.
      
       Problem 2: When typing another single character after 'perf --', e.g.
       'h', and hit TAB key to get the bash completion of 'perf --h', the
       character 'h' disappears at once. This is not what we want, we wish the
       bash completion can return '--help --html-path' and then we can
       continue to choose one.
      
       To solve this problem, we add '--list-opts' to perf, which now supports
       'perf --list-opts' directly, and its result can be used in bash
       completion now.
      
      Example:
      
       Before this patch:
      
       $ perf --h                 <-- hit TAB key after character 'h'
       $ perf --                  <-- 'h' disappears and no required result
      
       After this patch:
      
       $ perf --h                 <-- hit TAB key after character 'h'
       --help       --html-path   <-- the required result
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425032491-20224-8-git-send-email-yunlong.song@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7335399a
    • Yunlong Song's avatar
      perf list: Extend raw-dump to certain kind of events · 5ef803ee
      Yunlong Song authored
      Extend 'perf list --raw-dump' to 'perf list --raw-dump [hw|sw|cache
      |tracepoint|pmu|event_glob]' in order to show the raw-dump of a certain
      kind of events rather than all of the events.
      
      Example:
      
      Before this patch:
      
       $ perf list --raw-dump hw
       branch-instructions branch-misses bus-cycles cache-misses
       cache-references cpu-cycles instructions stalled-cycles-backend
       stalled-cycles-frontend
       alignment-faults context-switches cpu-clock cpu-migrations
       emulation-faults major-faults minor-faults page-faults task-clock
       ...
       ...
       writeback:writeback_thread_start writeback:writeback_thread_stop
       writeback:writeback_wait_iff_congested
       writeback:writeback_wake_background writeback:writeback_wake_thread
      
      As shown above, all of the events are printed.
      
      After this patch:
      
       $ perf list --raw-dump hw
       branch-instructions branch-misses bus-cycles cache-misses
       cache-references cpu-cycles instructions stalled-cycles-backend
       stalled-cycles-frontend
      
      As shown above, only the hw events are printed.
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425032491-20224-5-git-send-email-yunlong.song@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5ef803ee
    • Yunlong Song's avatar
      perf list: Clean up the printing functions of hardware/software events · 705750f2
      Yunlong Song authored
      Do not need print_events_type or __print_events_type for listing hw/sw
      events, let print_symbol_events do its job instead. Moreover,
      print_symbol_events can also handle event_glob and name_only.
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425032491-20224-4-git-send-email-yunlong.song@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      705750f2
    • Yunlong Song's avatar
      perf tools: Remove the '--(null)' long_name for --list-opts · 3ef1e65c
      Yunlong Song authored
      If the long_name of a 'struct option' is defined as NULL, --list-opts
      will incorrectly print '--(null)' in its output. As a result, '--(null)'
      will finally appear in the case of bash completion, e.g. 'perf record
      --'.
      
      Example:
      
      Before this patch:
      
       $ perf record --list-opts
      
       --event --filter --pid --tid --realtime --no-buffering --raw-samples
       --all-cpus --cpu --count --output --no-inherit --freq --mmap-pages
       --group --(null) --call-graph --verbose --quiet --stat --data
       --timestamp --period --no-samples --no-buildid-cache --no-buildid
       --cgroup --delay --uid --branch-any --branch-filter --weight
       --transaction --per-thread --intr-regs
      
      After this patch:
      
       $ perf record --list-opts
      
       --event --filter --pid --tid --realtime --no-buffering --raw-samples
       --all-cpus --cpu --count --output --no-inherit --freq --mmap-pages
       --group --call-graph --verbose --quiet --stat --data --timestamp
       --period --no-samples --no-buildid-cache --no-buildid --cgroup --delay
       --uid --branch-any --branch-filter --weight --transaction --per-thread
       --intr-regs
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425032491-20224-7-git-send-email-yunlong.song@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3ef1e65c
    • Yunlong Song's avatar
      perf list: Avoid confusion of perf output and the next command prompt · ed457520
      Yunlong Song authored
      Distinguish the output of 'perf list --list-opts' or 'perf --list-cmds'
      with the next command prompt, which also happens in other cases (e.g.
      record, report ...).
      
      Example:
      
      Before this patch:
      
       $perf list --list-opts
       --raw-dump $          <-- the output and the next command prompt are at
                                 the same line
      
      After this patch:
      
       $perf list --list-opts
       --raw-dump
       $                     <-- the new line
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425032491-20224-6-git-send-email-yunlong.song@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ed457520
    • Yunlong Song's avatar
      perf list: Allow listing events with 'tracepoint' prefix · 16114951
      Yunlong Song authored
      If somebody happens to name an event with the beginning of 'tracepoint'
      (e.g. tracepoint_foo), then it will never be showed with perf list
      event_glob, thus we parse the argument 'tracepoint' more carefully for
      accuracy.
      
      Example:
      
      Before this patch:
      
       $ perf list tracepoint_foo:*
      
         jbd2:jbd2_start_commit                             [Tracepoint event]
         jbd2:jbd2_commit_locking                           [Tracepoint event]
         jbd2:jbd2_run_stats                                [Tracepoint event]
         block:block_rq_issue                               [Tracepoint event]
         block:block_bio_complete                           [Tracepoint event]
         block:block_bio_backmerge                          [Tracepoint event]
         block:block_getrq                                  [Tracepoint event]
         ...                                                ...
      
      As shown above, all of the tracepoint events are printed. In fact, the
      command's real intention is to print the events of tracepoint_foo.
      
      After this patch:
      
       $ perf list tracepoint_foo:*
      
         tracepoint_foo:tp_foo_enter                        [Tracepoint event]
         tracepoint_foo:tp_foo_exit                         [Tracepoint event]
      
      As shown above, only the events of tracepoint_foo are printed.
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425032491-20224-3-git-send-email-yunlong.song@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      16114951
    • Yunlong Song's avatar
      perf list: Sort the output of 'perf list' to view more clearly · ab0e4800
      Yunlong Song authored
      Sort the output according to ASCII character list (using strcmp), which
      supports both number sequence and alphabet sequence.
      
      Example:
      
      Before this patch:
      
       $ perf list
      
       List of pre-defined events (to be used in -e):
         cpu-cycles OR cycles                               [Hardware event]
         instructions                                       [Hardware event]
         cache-references                                   [Hardware event]
         cache-misses                                       [Hardware event]
         branch-instructions OR branches                    [Hardware event]
         branch-misses                                      [Hardware event]
         bus-cycles                                         [Hardware event]
         ...                                                ...
      
         jbd2:jbd2_start_commit                             [Tracepoint event]
         jbd2:jbd2_commit_locking                           [Tracepoint event]
         jbd2:jbd2_run_stats                                [Tracepoint event]
         block:block_rq_issue                               [Tracepoint event]
         block:block_bio_complete                           [Tracepoint event]
         block:block_bio_backmerge                          [Tracepoint event]
         block:block_getrq                                  [Tracepoint event]
         ...                                                ...
      
      After this patch:
      
       $ perf list
      
       List of pre-defined events (to be used in -e):
         branch-instructions OR branches                    [Hardware event]
         branch-misses                                      [Hardware event]
         bus-cycles                                         [Hardware event]
         cache-misses                                       [Hardware event]
         cache-references                                   [Hardware event]
         cpu-cycles OR cycles                               [Hardware event]
         instructions                                       [Hardware event]
         ...                                                ...
      
         block:block_bio_backmerge                          [Tracepoint event]
         block:block_bio_complete                           [Tracepoint event]
         block:block_getrq                                  [Tracepoint event]
         block:block_rq_issue                               [Tracepoint event]
         jbd2:jbd2_commit_locking                           [Tracepoint event]
         jbd2:jbd2_run_stats                                [Tracepoint event]
         jbd2:jbd2_start_commit                             [Tracepoint event]
         ...                                                ...
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425032491-20224-2-git-send-email-yunlong.song@huawei.com
      [ Don't forget closedir({sys,evt}_dir) when handling errors ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ab0e4800
    • Yunlong Song's avatar
      perf data: Fix sentinel setting for data_cmds array · 1f924c29
      Yunlong Song authored
      The recent new patch "perf tools: Add new 'perf data' command" (commit
      2245bf14 in acme's git repo perf/core) has caused a building error when
      compiling the source code of perf:
      
       cc1: warnings being treated as errors
       builtin-data.c:89: error: missing initializer
       builtin-data.c:89: error: (near initialization for ‘data_cmds[1].summary’)
       make[2]: *** [builtin-data.o] Error 1
       make[2]: *** Waiting for unfinished jobs....
         LD       bench/perf-in.o
         LD       tests/perf-in.o
       make[1]: *** [perf-in.o] Error 2
       make: *** [all] Error 2
      
      This patch fixes the building error above.
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425038026-27604-1-git-send-email-yunlong.song@huawei.com
      [ .name == NULL ends the loop, use it instead of seting all fields to NULL ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1f924c29
    • He Kuang's avatar
      perf probe: Fix a precedence bug · f56847c2
      He Kuang authored
      The minus operator has higher precedence than ?: Add parentheses around
      ?: fix this.
      
      Before this patch:
      
        $ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
        $ perf probe -l -k ../vmlinux
          kprobes:myprobe      (on do_sys_open)
      
      After this patch:
      
        $ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
        $ perf probe -l -k ../vmlinux
          kprobes:myprobe      (on do_sys_open@linux.git/fs/open.c)
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Acked-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1425034373-14511-1-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f56847c2
    • Kan Liang's avatar
      perf diff: Support for different binaries · 94ba462d
      Kan Liang authored
      Currently, the perf diff only works with same binaries. That's because
      it compares the symbol start address. It doesn't work if the perf.data
      comes from different binaries. This patch matches the symbol names.
      
      Actually, perf diff once intended to compare the symbol names.  The
      commit as below can look for a pair by name.
      
      604c5c92 (perf diff: Change the default sort order to "dso,symbol")
      However, at that time, perf diff used a global list of dsos. That means
      the binaries which has same name can only be loaded once. That's a
      problem for comparing different binaries.
      
      For example, we have an old binary and an updated binary. They very
      likely have same name and most of the functions, so only dsos from old
      binary will be loaded. When processing the data from updated binary,
      perf still use the symbol information from old binary. That's wrong.
      
      Then the commit as below used IP to replace symbol name.
      9c443dfd ("perf diff: Fix support for all --sort combinations")
      >From that time, perf diff starts to compare the symbol address.
      
      The global dsos is discarded from a patch in 2010.
      a1645ce1 ("perf: 'perf kvm' tool for monitoring guest performance
      from host")
      However, at that time, perf diff already compared by address. So perf
      diff cannot work for different binaries as well.
      
      This patch actually rolls back the perf diff to original design. The
      document is also changed, so everybody knows the original design is to
      compare the symbol names.
      
      Here are some examples:
      
      The only difference between example_v1.c and example_v2.c is the
      location of f2 and f3. There is no change in behavior, but the previous
      perf diff display the wrong differential profile.
      
      example_v1.c
      noinline void f3(void)
      {
              volatile int i;
              for (i = 0; i < 10000;) {
      
                      if(i%2)
                              i++;
                      else
                              i++;
              }
      }
      
      noinline void f2(void)
      {
              volatile int a = 100, b, c;
              for (b = 0; b < 10000; b++)
                      c = a * b;
      
      }
      
      noinline void f1(void)
      {
                      f2();
                      f3();
      }
      
      int main()
      {
              int i;
              for (i = 0; i < 100000; i++)
                      f1();
      }
      
      example_v2.c
      noinline void f2(void)
      {
              volatile int a = 100, b, c;
              for (b = 0; b < 10000; b++)
                      c = a * b;
      }
      
      noinline void f3(void)
      {
              volatile int i;
              for (i = 0; i < 10000;) {
                      if(i%2)
                              i++;
                      else
                              i++;
              }
      }
      
      noinline void f1(void)
      {
                      f2();
                      f3();
      }
      
      int main()
      {
              int i;
              for (i = 0; i < 100000; i++)
                      f1();
      }
      
      [lk@localhost perf_diff]$ gcc example_v1.c -o example
      [lk@localhost perf_diff]$ perf record -o example_v1.data ./example
      [ perf record: Woken up 4 times to write data ]
      [ perf record: Captured and wrote 0.813 MB example_v1.data (~35522 samples) ]
      
      [lk@localhost perf_diff]$ gcc example_v2.c -o example
      [lk@localhost perf_diff]$ perf record -o example_v2.data ./example
      [ perf record: Woken up 4 times to write data ]
      [ perf record: Captured and wrote 0.824 MB example_v2.data (~36015 samples) ]
      
      Old perf diff result:
      
      [lk@localhost perf_diff]$ perf diff example_v1.data example_v2.data
       Event 'cycles'
       Baseline    Delta  Shared Object     Symbol
       ........  .......  ................  ...............................
      
                           [kernel.vmlinux]  [k] __perf_event_task_sched_out
           0.00%           [kernel.vmlinux]  [k] apic_timer_interrupt
                           [kernel.vmlinux]  [k] idle_cpu
                           [kernel.vmlinux]  [k] intel_pstate_timer_func
                           [kernel.vmlinux]  [k] native_read_msr_safe
           0.00%           [kernel.vmlinux]  [k] native_read_tsc
           0.00%           [kernel.vmlinux]  [k] native_write_msr_safe
                           [kernel.vmlinux]  [k] ntp_tick_length
           0.00%           [kernel.vmlinux]  [k] rb_erase
           0.00%           [kernel.vmlinux]  [k] tick_sched_timer
           0.00%           [kernel.vmlinux]  [k] unmap_single_vma
           0.00%           [kernel.vmlinux]  [k] update_wall_time
           0.00%           example           [.] f1
          46.24%           example           [.] f2
          53.71%   -7.55%  example           [.] f3
                  +53.81%  example           [.] f3
           0.02%           example           [.] main
      
      New perf diff result:
      
      [lk@localhost perf_diff]$ perf diff example_v1.data example_v2.data
                           [kernel.vmlinux]  [k] __perf_event_task_sched_out
           0.00%           [kernel.vmlinux]  [k] apic_timer_interrupt
                           [kernel.vmlinux]  [k] idle_cpu
                           [kernel.vmlinux]  [k] intel_pstate_timer_func
                           [kernel.vmlinux]  [k] native_read_msr_safe
           0.00%           [kernel.vmlinux]  [k] native_read_tsc
           0.00%           [kernel.vmlinux]  [k] native_write_msr_safe
                           [kernel.vmlinux]  [k] ntp_tick_length
           0.00%           [kernel.vmlinux]  [k] rb_erase
           0.00%           [kernel.vmlinux]  [k] tick_sched_timer
           0.00%           [kernel.vmlinux]  [k] unmap_single_vma
           0.00%           [kernel.vmlinux]  [k] update_wall_time
           0.00%           example           [.] f1
          46.24%   -0.08%  example           [.] f2
          53.71%   +0.11%  example           [.] f3
           0.02%           example           [.] main
      Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Link: http://lkml.kernel.org/r/1423460384-11645-1-git-send-email-kan.liang@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      94ba462d
    • Masami Hiramatsu's avatar
      perf buildid-cache: Add new buildid cache if update target is not cached · a50d11a1
      Masami Hiramatsu authored
      Add new buildid cache if the update target file is not cached.
      
      This can happen when an old binary is replaced by new one after caching
      the old one. In this case, user sees his operation just failed.
      
      But it does not look straight, since user just pass the binary "path",
      not "build-id".
      
        ----
        # ./perf buildid-cache --add ./perf
        (update ./perf to new binary)
        # ./perf buildid-cache --update ./perf
        ./perf wasn't in the cache
        #
        ----
      
      This patch adds given new binary to cache if the new binary is
      not cached. So we'll not see the above error.
      
        ----
        # ./perf buildid-cache --add ./perf
        (update ./perf to new binary)
        # ./perf buildid-cache --update ./perf
        #
        ----
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      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/20150226065440.23912.1494.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a50d11a1
    • Arnaldo Carvalho de Melo's avatar
      perf probe: Handle strdup() failure · 38ae502b
      Arnaldo Carvalho de Melo authored
      We could end up returning 0 (Ok) with a NULL raw_path. Fix it.
      Acked-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naohiro Aota <naota@elisp.net>
      Link: http://lkml.kernel.org/n/tip-l0kcbcg5f4nnzqt01cv42vec@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      38ae502b