1. 02 Mar, 2015 16 commits
  2. 01 Mar, 2015 1 commit
  3. 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
  4. 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
  5. 26 Feb, 2015 5 commits
    • Masami Hiramatsu's avatar
      perf probe: Fix get_real_path to free allocated memory in error path · eb47cb2e
      Masami Hiramatsu authored
      Fix get_real_path to free allocated memory when comp_dir is used for
      complementing path and getting an error.
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naohiro Aota <naota@elisp.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20150226082504.28125.74506.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eb47cb2e
    • Masami Hiramatsu's avatar
      perf probe: Check kprobes blacklist when adding new events · 9aaf5a5f
      Masami Hiramatsu authored
      Recent linux kernel provides a blacklist of the functions which can not
      be probed. perf probe can now check this blacklist before setting new
      events and indicate better error message for users.
      
      Without this patch,
        ----
        # perf probe --add vmalloc_fault
        Added new event:
        Failed to write event: Invalid argument
          Error: Failed to add events.
        ----
      With this patch
        ----
        # perf probe --add vmalloc_fault
        Added new event:
        Warning: Skipped probing on blacklisted function: vmalloc_fault
        ----
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20150219143113.14434.5387.stgit@localhost.localdomainSigned-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9aaf5a5f
    • David Ahern's avatar
      perf trace: Fix SIGBUS failures due to misaligned accesses · 55d43bca
      David Ahern authored
      On Sparc64 perf-trace is failing in many spots due to extended load
      instructions being used on misaligned accesses.
      
      (gdb) run trace ls
      Starting program: /tmp/perf/perf trace ls
      [Thread debugging using libthread_db enabled]
      Detaching after fork from child process 169460.
      
      <ls output removed>
      
      Program received signal SIGBUS, Bus error.
      0x000000000014f4dc in tp_field__u64 (field=0x4cc700, sample=0x7feffffa098) at builtin-trace.c:61
      warning: Source file is more recent than executable.
      61      TP_UINT_FIELD(64);
      
      (gdb) bt
       0  0x000000000014f4dc in tp_field__u64 (field=0x4cc700, sample=0x7feffffa098) at builtin-trace.c:61
       1  0x0000000000156ad4 in trace__sys_exit (trace=0x7feffffc268, evsel=0x4cc580, event=0xfffffc0104912000,
          sample=0x7feffffa098) at builtin-trace.c:1701
       2  0x0000000000158c14 in trace__run (trace=0x7feffffc268, argc=1, argv=0x7fefffff360) at builtin-trace.c:2160
       3  0x000000000015b78c in cmd_trace (argc=1, argv=0x7fefffff360, prefix=0x0) at builtin-trace.c:2609
       4  0x0000000000107d94 in run_builtin (p=0x4549c8, argc=2, argv=0x7fefffff360) at perf.c:341
       5  0x0000000000108140 in handle_internal_command (argc=2, argv=0x7fefffff360) at perf.c:400
       6  0x0000000000108308 in run_argv (argcp=0x7feffffef2c, argv=0x7feffffef20) at perf.c:444
       7  0x0000000000108728 in main (argc=2, argv=0x7fefffff360) at perf.c:559
      
      (gdb) p *sample
      $1 = {ip = 4391276, pid = 169472, tid = 169472, time = 6303014583281250, addr = 0, id = 72082,
        stream_id = 18446744073709551615, period = 1, weight = 0, transaction = 0, cpu = 73, raw_size = 36,
        data_src = 84410401, flags = 0, insn_len = 0, raw_data = 0xfffffc010491203c, callchain = 0x0,
        branch_stack = 0x0, user_regs = {abi = 0, mask = 0, regs = 0x0, cache_regs = 0x7feffffa098, cache_mask = 0},
        intr_regs = {abi = 0, mask = 0, regs = 0x0, cache_regs = 0x7feffffa098, cache_mask = 0}, user_stack = {
          offset = 0, size = 0, data = 0x0}, read = {time_enabled = 0, time_running = 0, {group = {nr = 0,
              values = 0x0}, one = {value = 0, id = 0}}}}
      (gdb) p *field
      $2 = {offset = 16, {integer = 0x14f4a8 <tp_field__u64>, pointer = 0x14f4a8 <tp_field__u64>}}
      
      sample->raw_data is guaranteed to not be 8-byte aligned because it is preceded
      by the size as a u3. So accessing raw data with an extended load instruction causes
      the SIGBUS. Resolve by using memcpy to a temporary variable of appropriate size.
      Signed-off-by: default avatarDavid Ahern <david.ahern@oracle.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1424376022-140608-1-git-send-email-david.ahern@oracle.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      55d43bca
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 0afb1704
      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:
      
      New user selectable features:
      
        - Support recording running/enabled time in 'perf record' (Andi Kleen)
      
        - New tool: 'perf data' for converting perf.data to other formats,
          initially for the CTF (Common Trace Format) from LTTng (Jiri Olsa, Sebastian Siewior)
      
      User visible changes:
      
        - Only insert blank duration bracket when tracing syscalls in 'perf trace' (Arnaldo Carvalho de Melo)
      
        - Filter out the trace pid when no threads are specified in 'perf trace' (Arnaldo Carvalho de Melo)
      
        - Add 'perf trace' man page entry for --event (Arnaldo Carvalho de Melo)
      
        - Dump stack on segfaults in 'perf trace' (Arnaldo Carvalho de Melo)
      
      Infrastructure changes:
      
        - Introduce set_filter_pid and set_filter_pids methods in the evlist class (Arnaldo Carvalho de Melo)
      
        - Some perf_session untanglement patches, removing the need to pass a
          perf_session instance for things that are related to evlists, so that
          tools that don't deal with perf.data files like trace in live mode can
          make use of the ordered_events class (Arnaldo Carvalho de Melo)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0afb1704
    • Ingo Molnar's avatar
      e9e4e443
  6. 25 Feb, 2015 1 commit