Skip to content
  1. Mar 21, 2015
    • Milos Vyletel's avatar
      perf tools: Fix race in build_id_cache__add_s() · 0635b0f7
      Milos Vyletel authored
      
      
      int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
                                const char *name, bool is_kallsyms, bool is_vdso)
      {
      ...
              if (access(filename, F_OK)) {
                     ^--------------------------------------------------------- [1]
                      if (is_kallsyms) {
                               if (copyfile("/proc/kallsyms", filename))
                                      goto out_free;
                      } else if (link(realname, filename) && copyfile(name, filename))
                                   ^-----------------------------^------------- [2]
                                                                  \------------ [3]
                              goto out_free;
              }
      ...
      
      When multiple instances of perf record get to [1] at more or less same time and
      run access() one or more may get failure because the file does not exist yet
      (since the first instance did not have chance to link it yet).
      
      At this point the race moves to link() at [2] where first thread to get
      there links file and goes on but second one gets -EEXIST so it runs
      copyfile [3] which truncates the file.
      
      reproducer:
      
      rm -rf /root/.debug
      for cpu in $(awk '/processor/ {print $3}' /proc/cpuinfo); do
      	perf record -a -v -T -F 1000 -C $cpu \
      		-o perf-${cpu}.data sleep 5 2> /dev/null &
      done
      wait
      
      and simply search for empty files by:
      
      find /lib/modules/`uname -r`/kernel/* -size 0
      
      Signed-off-by: default avatarMilos Vyletel <milos@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1426847846-11112-1-git-send-email-milos@redhat.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0635b0f7
  2. Mar 20, 2015
    • Wang Nan's avatar
      perf report: Don't allow empty argument for '-t'. · 0c8c2077
      Wang Nan authored
      
      
      Without this patch, perf report cause segfault if pass "" as '-t':
      
        $ perf report -t ""
      
         # To display the perf.data header info, please use --header/--header-only options.
         #
         # Samples: 37  of event 'syscalls:sys_enter_write'
         # Event count (approx.): 37
         #
         # Children    SelfCommand   Shared Object         Symbol
         Segmentation fault
      
      Since -t is used to add field-separator for generate table, -t "" is
      actually meanless. This patch defines a new OPT_STRING_NOEMPTY() option
      generator to ensure user never pass empty string to that option.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: pi3orama@163.com
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/1426251114-198991-1-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0c8c2077
    • Wang Nan's avatar
      perf callchain: Separate eh/debug frame offset cache. · 303cb89a
      Wang Nan authored
      Commit f1f13af9
      
       ("perf callchain: Cache eh/debug frame offset for
      dwarf unwind") introduces a cache for .debug_frame and .eh_frame_hdr.
      Unfortunately, it makes them share a same cache (dso->frame_offset).
      Which causes unwind failure on ARM:
      
         $ perf test unwind
        Test dwarf unwind: FAILED!
      
      The reason is that, if a dso has '.debug_frame' but doesn't have
      '.eh_frame_hdr' (like ARM), dso->frame_offset will be filled by offset
      of '.debug_frame' during the first time calling of find_proc_info() ->
      read_unwind_spec_debug_frame(), and be regarded to '.eh_frame_hdr' when
      the second time calling of find_proc_info() ->
      read_unwind_spec_eh_frame(), since '.eh_frame_hdr' is checked prior to
      '.debug_frame'.
      
      This patch solves the problem by creating two cache fields for
      '.eh_frame_hdr' and '.debug_frame'.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Li Zefan <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/55028BA0.1030701@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      303cb89a
    • Yunlong Song's avatar
      perf tools: Avoid confusion with preloaded bash function for perf bash completion · 1312c8a8
      Yunlong Song authored
      
      
      Since some functions (e.g. '_get_comp_words_by_ref()') in perf bash
      completion script are originally taken from git bash completion script,
      these functions may be preloaded before perf bash completion script
      runs.
      
      In order to avoid repeating loading the same function twice, some test
      constraints are used before these function definitions in the perf bash
      completion script (e.g. 'type _get_comp_words_by_ref &>/dev/null ||').
      
      The problem is that, if these functions in perf bash completion script
      are changed for some reason, perf will still use the preloaded bash
      functions rather than the customized functions of its own.
      
      As a result, the perf bash completion will behave incorrectly. To get
      rid of this problem, a flag can be defined to determine the proper
      situation.
      
      And to avoid overwriting the preloaded functions, the names of these
      functions in perf bash completion script should be renamed to the
      perf-customized ones.
      
      Example:
      
      Before this patch:
      
       $ type _get_comp_words_by_ref
       _get_comp_words_by_ref is a function
       _get_comp_words_by_ref ()
       {
           local exclude flag i OPTIND=1;
           local cur cword words=();
           local upargs=() upvars=() vcur vcword vprev vwords;
           while getopts "c:i:n:p:w:" flag "$@"; do
               case $flag in
                   c)
                       vcur=$OPTARG
                   ;;
                   i)
                       vcword=$OPTARG
                   ;;
                   n)
                       exclude=$OPTARG
                   ;;
                   p)
                       vprev=$OPTARG
                   ;;
                   w)
                       vwords=$OPTARG
                   ;;
               esac;
           done;
           while [[ $# -ge $OPTIND ]]; do
               case ${!OPTIND} in
                   cur)
                       vcur=cur
                   ;;
                   prev)
                       vprev=prev
                   ;;
                   cword)
                       vcword=cword
                   ;;
                   words)
                       vwords=words
                   ;;
                   *)
                       echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" 1>&2;
                       return 1
                   ;;
               esac;
               let "OPTIND += 1";
           done;
           __get_cword_at_cursor_by_ref "$exclude" words cword cur;
           [[ -n $vcur ]] && {
               upvars+=("$vcur");
               upargs+=(-v $vcur "$cur")
           };
           [[ -n $vcword ]] && {
               upvars+=("$vcword");
               upargs+=(-v $vcword "$cword")
           };
           [[ -n $vprev && $cword -ge 1 ]] && {
               upvars+=("$vprev");
               upargs+=(-v $vprev "${words[cword - 1]}")
           };
           [[ -n $vwords ]] && {
               upvars+=("$vwords");
               upargs+=(-a${#words[@]} $vwords "${words[@]}")
           };
           (( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}"
       }
      
      As shown above, the _get_comp_words_by_ref is the preloaded function in
      fact, rather than the function defined in perf-completion.sh. So if we
      happen to change the function for some reason, the result will behave in
      a wrong state.
      
      After this patch:
      
      We can set preload_get_comp_words_by_ref="false" to not use the preloaded
      function. Instead, it will use the function defined in perf-completion.sh,
      which is renamed as __perf_get_comp_words_by_ref to avoid overwriting
      the preloaded function _get_comp_words_by_ref.
      
       $ type __perf_get_comp_words_by_ref
       __perf_get_comp_words_by_ref is a function
       __perf_get_comp_words_by_ref ()
       {
           local exclude cur_ words_ cword_;
           if [ "$1" = "-n" ]; then
               exclude=$2;
               shift 2;
           fi;
           __my_reassemble_comp_words_by_ref "$exclude";
           cur_=${words_[cword_]};
           while [ $# -gt 0 ]; do
               case "$1" in
                   cur)
                       cur=$cur_
                   ;;
                   prev)
                       prev=${words_[$cword_-1]}
                   ;;
                   words)
                       words=("${words_[@]}")
                   ;;
                   cword)
                       cword=$cword_
                   ;;
               esac;
               shift;
           done
       }
      
      As shown above, the function __perf_get_comp_words_by_ref is loaded and
      can work this time.
      
      Note that we do not change the original behavior when those functions are
      not preloaded before perf bash completion script runs. In this case,
      although the flag is set to "true", the code will still change it to
      "false" to use the function defined in perf-completion.sh.
      
      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/1426685758-25488-14-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1312c8a8
    • Yunlong Song's avatar
      perf tools: Add the bash completion for listing subsubcommands of perf trace · 6fdd9cb7
      Yunlong Song authored
      
      
      The bash completion does not support listing subsubcommands for 'perf
      trace <TAB>', so fix it.
      
      Example:
      
      Before this patch:
      
       $ perf trace <TAB>
       $
      
      As shown above, the subsubcommands of perf trace does not come out.
      
      After this patch:
      
       $ perf trace <TAB>
       record
      
      As shown above, the subsubcommands of perf trace can come out now.
      
      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/1426685758-25488-13-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6fdd9cb7
    • Yunlong Song's avatar
      perf tools: Add the bash completion for listing subsubcommands of perf timechart · 33ec0caf
      Yunlong Song authored
      
      
      The bash completion does not support listing subsubcommands for 'perf
      timechart <TAB>', so fix it.
      
      Example:
      
      Before this patch:
      
       $ perf timechart <TAB>
       $
      
      As shown above, the subsubcommands of perf timechart does not come out.
      
      After this patch:
      
       $ perf timechart <TAB>
       record
      
      As shown above, the subsubcommands of perf timechart can come out now.
      
      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/1426685758-25488-12-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      33ec0caf
    • Yunlong Song's avatar
      perf tools: Add the bash completion for listing subsubcommands of perf test · 1f9975f1
      Yunlong Song authored
      
      
      The bash completion does not support listing subsubcommands for 'perf
      test <TAB>', so fix it.
      
      Example:
      
      Before this patch:
      
       $ perf test <TAB>
       $
      
      As shown above, the subsubcommands of perf test does not come out.
      
      After this patch:
      
       $ perf test <TAB>
       list
      
      As shown above, the subsubcommands of perf test can come out now.
      
      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/1426685758-25488-11-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1f9975f1
    • Yunlong Song's avatar
      perf tools: Add the bash completion for listing subsubcommands of perf script · 40cae2b7
      Yunlong Song authored
      
      
      The bash completion does not support listing subsubcommands for 'perf
      script <TAB>', so fix it.
      
      Example:
      
      Before this patch:
      
       $ perf script <TAB>
       $
      
      As shown above, the subsubcommands of perf script does not come out.
      
      After this patch:
      
       $ perf script <TAB>
       record  report
      
      As shown above, the subsubcommands of perf script can come out now.
      
      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/1426685758-25488-10-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      40cae2b7
    • Yunlong Song's avatar
      perf tools: Add the bash completion for listing subsubcommands of perf help · e24a1108
      Yunlong Song authored
      
      
      The bash completion does not support listing subsubcommands for 'perf
      help <TAB>', so fix it.
      
      Example:
      
      Before this patch:
      
       $ perf help <TAB>
       $
      
      As shown above, the subsubcommands of perf help does not come out.
      
      After this patch:
      
       $ perf help <TAB>
       annotate       buildid-cache  data           evlist         inject
       kvm            lock           probe          report         script
       test           top
       bench          buildid-list   diff           help           kmem
       list           mem            record         sched          stat
       timechart      trace
      
      As shown above, the subsubcommands of perf help can come out now.
      
      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/1426685758-25488-9-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e24a1108
    • Yunlong Song's avatar
      perf tools: Add the bash completion for listing subsubcommands of perf data · 01b7160b
      Yunlong Song authored
      
      
      The bash completion does not support listing subsubcommands for 'perf
      data <TAB>', so fix it.
      
      Example:
      
      Before this patch:
      
       $ perf data <TAB>
       $
      
      As shown above, the subsubcommands of perf data does not come out.
      
      After this patch:
      
       $ perf data <TAB>
       convert
      
      As shown above, the subsubcommands of perf data can come out now.
      
      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/1426685758-25488-8-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      01b7160b
    • Yunlong Song's avatar
      perf tools: Fix the bash completion for listing subcommands of perf · e003ce54
      Yunlong Song authored
      
      
      The bash completion does not support listing subcommands for 'perf
      --<long option> <TAB>'.
      
      Example:
      
      Before this patch:
      
       $ perf --debug <TAB>
       $
      
      As shown above, the subcommands of perf does not come out.
      
      After this patch:
      
       $ perf --debug <TAB>
       annotate       buildid-cache  data           evlist         inject
       kvm            lock           probe          report         script
       test           top            version
       bench          buildid-list   diff           help           kmem
       list           mem            record         sched          stat
       timechart      trace
      
      As shown above, the subcommands of perf can come out now.
      
      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/1426685758-25488-7-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e003ce54
    • Yunlong Song's avatar
      perf tools: Fix the bash completion to support listing events for --event · 3346b542
      Yunlong Song authored
      
      
      The bash completion only supports -e rather than --event, so fix it.
      
      Example:
      
      Before this patch:
      
       $ perf record --event <TAB>
       $
      
      As shown above, the events of record does not come out.
      
      After this patch:
      
       $ perf record --event <TAB>
       lignment-faults                   cpu/instructions/
       L1-dcache-prefetch-misses          node-prefetches
       uncore_rbox_0/qpi0_idle_filt/
       branch-instructions                cpu/mem-loads/
       L1-dcache-store-misses             node-prefetch-misses
       uncore_rbox_0/qpi1_date_response/
       branch-load-misses                 cpu-migrations
       L1-dcache-stores                   node-store-misses
       uncore_rbox_0/qpi1_filt_send/
       branch-loads                       dTLB-load-misses
       L1-icache-load-misses              node-stores
       uncore_rbox_0/qpi1_idle_filt/
       ...
      
      As shown above, the events of record can come out now.
      
      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/1426685758-25488-6-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3346b542
    • Yunlong Song's avatar
      perf tools: Fix the bash completion for listing events of perf subcommand record|stat|top -e · bc81fad1
      Yunlong Song authored
      
      
      The bash completion does not support listing events for 'perf kvm|kmem|
      mem|lock|sched record|stat|top -e <TAB>', where 'kvm|kmem|mem|lock|sched'
      are all subcommands of perf.
      
      Example:
      
      Before this patch:
      
       $ perf kvm record -e <TAB>
       $
      
      As shown above, the events of record does not come out.
      
      After this patch:
      
       $ perf kvm record -e <TAB>
       alignment-faults                   cpu/instructions/
       L1-dcache-prefetch-misses          node-prefetches
       uncore_rbox_0/qpi0_idle_filt/
       branch-instructions                cpu/mem-loads/
       L1-dcache-store-misses             node-prefetch-misses
       uncore_rbox_0/qpi1_date_response/
       branch-load-misses                 cpu-migrations
       L1-dcache-stores                   node-store-misses
       uncore_rbox_0/qpi1_filt_send/
       branch-loads                       dTLB-load-misses
       L1-icache-load-misses              node-stores
       uncore_rbox_0/qpi1_idle_filt/
       ...
      
      As shown above, the events of record can come out now.
      
      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/1426685758-25488-5-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bc81fad1
    • Yunlong Song's avatar
      perf tools: Provide the right bash completion for listing options of perf subcommand subsubcommand · eee200a6
      Yunlong Song authored
      
      
      The bash completion gives wrong options for 'perf kvm|kmem|mem|lock|
      sched subsubcommand --<TAB>', where 'kvm|kmem|mem|lock|sched' are all
      subcommands of perf and 'subsubcommand' is a subcommand of 'kvm|kmem|mem
      |lock|sched'. In fact, the result incorrectly lists the bash completion
      of 'perf subcommand' rather than 'perf subcommand subsubcommand'.
      
      Example:
      
      Before this patch:
      
       $ perf kvm record --<TAB>
       --guest          --guestkallsyms  --guestmodules   --guestmount
       --guestvmlinux   --host           --input          --output
       --verbose
      
      As shown above, the result is the options of kvm rather than record.
      
      After this patch:
      
       $ perf kvm record --<TAB>
       --all-cpus          --cgroup            --delay             --group
       --no-buildid        --output            --quiet             --stat
       --uid
       --branch-any        --count             --event             --intr-regs
       --no-buildid-cache  --period            --raw-samples       --tid
       --verbose
       --branch-filter     --cpu               --filter            --mmap-pages
       --no-inherit        --per-thread        --realtime          --timestamp
       --weight
       --call-graph        --data              --freq
       --no-buffering      --no-samples        --pid
       --running-time      --transaction
      
      As shown above, the result is exactly the options of record as we wished.
      
      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/1426685758-25488-4-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eee200a6
    • Yunlong Song's avatar
      perf tools: Fix the bash completion for listing subsubcommands of perf subcommand · 67afff48
      Yunlong Song authored
      
      
      The bash completion does not support listing subsubcommands for 'perf
      kvm|kmem|mem|lock|sched --<long option> <TAB>', where 'kvm|kmem|mem|
      lock|sched' are all subcommands of perf.
      
      Example:
      
      Before this patch:
      
       $ perf kvm --verbose <TAB>
       $
      
      As shown above, the subsubcommands of perf kvm does not come out.
      
      After this patch:
      
       $ perf kvm --verbose <TAB>
       buildid-list  diff          record        report        stat
       top
      
      As shown above, the subsubcommands of perf kvm can come out now.
      
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1426685758-25488-3-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      67afff48
    • Yunlong Song's avatar
      perf tools: Fix the bash completion for listing options of perf subcommand · 02fde323
      Yunlong Song authored
      
      
      The bash completion does not support listing options for 'perf
      kvm|kmem|mem|lock|sched --<TAB>', where 'kvm|kmem|mem|lock|sched' are
      all subcommands of perf.
      
      Example:
      
      Before this patch:
      
       $ perf kvm --<TAB>
       $
      
      As shown above, the options of perf kvm does not come out.
      
      After this patch:
      
       $ perf kvm --<TAB>
       --alloc    --caller   --input    --line     --raw-ip   --sort
       --verbose
      
      As shown above, the options of perf kvm can come out now.
      
      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/1426685758-25488-2-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      02fde323
    • H.J. Lu's avatar
      perf tools: Fix perf-read-vdsox32 not building and lib64 install dir · 76aea773
      H.J. Lu authored
      Commit:
      
        c6e5e9fb
      
       ("perf tools: Fix building error in x86_64 when dwarf unwind is on")
      
      removed the definition of IS_X86_64 but not all places using it, with
      the consequence that perf-read-vdsox32 would not be built anymore, and
      the default lib install directory was 'lib' instead of 'lib64'.
      
      Also needs to go to v3.19.
      
      Signed-off-by: default avatarH.J. Lu <hjl.tools@gmail.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: stable@vger.kernel.org # 3.19
      Link: http://lkml.kernel.org/r/CAMe9rOqpGVq3D88w+D15ef7sv6G6k57ZeTvxBm46=WFgzo9p1w@mail.gmail.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      76aea773
  3. Mar 19, 2015
  4. Mar 18, 2015
    • Wang Nan's avatar
      perf tools: Fix building error for arm64. · 235504de
      Wang Nan authored
      Commit b11db658
      
       ("perf tools: Fix build
      error on ARCH=i386/x86_64/sparc64") uses sed on ARCH, which triggers a
      bug in sequence of sed expression, where 's/arm.*/arm/' will replace
      'arm64' to 'arm', causes arm64 building failure.
      
      This patch prevent 'arm64' to be mached for 'arm.*' case.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/1426598987-75245-1-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      235504de
    • Arnaldo Carvalho de Melo's avatar
      perf hists browser: Allow annotating entries in callchains · d5dbc518
      Arnaldo Carvalho de Melo authored
      
      
      Instead of annotating just the top level hist_entry, allow instead
      annotating a map_symbol, i.e. the top level hist_entry or one of the
      callchains for which there were samples.
      
      Suggested-by: default avatarStephane Eranian <eranian@google.com>
      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>
      Link: http://lkml.kernel.org/n/tip-k1zxj5564je9jei4yd15ouwn@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d5dbc518
    • Arnaldo Carvalho de Melo's avatar
      perf hists: Remove hist_entry->used, not used anymore · 4c47f4fc
      Arnaldo Carvalho de Melo authored
      
      
      Since hist_entry__delete() nowadays doesn't actually frees anything that
      may be in use by the annotation code.
      
      Eventually we will solve this for good by reference counting struct
      symbol.
      
      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-uldtgljymtrkns0knpiso5op@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4c47f4fc
  5. Mar 17, 2015
    • Arnaldo Carvalho de Melo's avatar
      perf hists browser: Fix up some branch alignment · 446fb96c
      Arnaldo Carvalho de Melo authored
      
      
      Those asprintf return checks should be aligned with the other
      conditionals, fix it.
      
      Also add {} blocks to further clarify.
      
      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>
      echo Link: http://lkml.kernel.org/n/tip-`ranpwd -l 24`@git.kernel.org
      Link: http://lkml.kernel.org/n/tip-nqgs07jfphbkw67wja870d3r@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      446fb96c
    • Arnaldo Carvalho de Melo's avatar
      perf hists browser: Simplify symbol annotation menu setup · 0ba332f7
      Arnaldo Carvalho de Melo authored
      
      
      No need to repeat some tests, skip annotation instead.
      
      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-6h6igrb81u4e6rwfmx7dv47n@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0ba332f7
  6. Mar 13, 2015
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 107eb964
      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 UI bug after zoom into thread/dso/symbol and another, after fold/unfold,
          in the TUI hists browser (He Kuang)
      
        - Fixes for 'perf probe' to better handle aliased symbols, for instance in glibc (Masami Hiramatsu, Namhyung Kim)
      
        - 'perf kmem' improvements and fixes: (Namhyung Kim)
          - Fix segfault when invalid sort key is given
          - Allow -v option
          - Fix alignment of slab result table
      
        - 'perf stat' improvements and fixes: (Andi Kleen)
          - Output running time and run/enabled ratio in CSV mode
          - Fix IPC and other formulas with -A
          - Always correctly indent ratio column
      
        - Add tracepoint events fields CTF conversion support to 'perf data' (Sebastian Andrzej Siewior)
      
      Infrastructure changes:
      
        - Output feature detection's gcc output to a file, to help in debugging (Arnaldo Carvalho de Melo)
      
        - Fix 'perf probe' compiles due to declarations using perf_probe_point (David Ahern)
      
        - Fix possible double free on error in 'perf probe' (He Kuang)
      
        - Remove superfluous thread->comm_set setting (Jiri Olsa)
      
        - Fix libbabeltrace detection (Jiri Olsa)
      
        - More work on separating ordered_events code out of perf_session (Arnaldo Carvalho de Melo)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      107eb964
    • Sebastian Andrzej Siewior's avatar
      perf data: Add tracepoint events fields CTF conversion support · 69364727
      Sebastian Andrzej Siewior authored
      
      
      Adding support to convert tracepoint event fields into CTF
      event fields.
      
      We parse each tracepoint event for CTF conversion and add
      tracepoint fields as regular CTF event fields, so they
      appear in babeltrace output like:
      
        $ babeltrace ./ctf-data/
        ...
        [09:02:00.950703057] (+?.?????????) sched:sched_stat_runtime: { }, { perf_ip = ... SNIP ... common_type = 298, common_flags = 1, \
        common_preempt_count = 0, common_pid = 31813, comm = "perf", pid = 31813, runtime = 458800, vruntime = 52059858071 }
        ...
      
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jeremie Galarneau <jgalar@efficios.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1424470628-5969-6-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      69364727
    • Namhyung Kim's avatar
      perf kmem: Fix alignment of slab result table · 65f46e02
      Namhyung Kim authored
      
      
      Its table was a bit misaligned.  Fix it.
      
      Before:
      
        # perf kmem stat --caller -l 10
        ------------------------------------------------------------------------------------------------------
         Callsite                           | Total_alloc/Per | Total_req/Per   | Hit      | Ping-pong | Frag
        ------------------------------------------------------------------------------------------------------
         radeon_cs_parser_init.part.1+11a   |      2080/260   |      1504/188   |        8 |        0 | 27.692%
         radeon_cs_parser_init.part.1+e1    |       384/96    |       288/72    |        4 |        0 | 25.000%
         radeon_cs_parser_init.part.1+93    |       128/32    |        96/24    |        4 |        0 | 25.000%
         load_elf_binary+a39                |       512/512   |       392/392   |        1 |        0 | 23.438%
         __alloc_skb+89                     |      6144/877   |      4800/685   |        7 |        6 | 21.875%
         radeon_fence_emit+5c               |      1152/192   |       912/152   |        6 |        0 | 20.833%
         radeon_cs_parser_relocs+ad         |      8192/2048  |      6624/1656  |        4 |        0 | 19.141%
         radeon_sa_bo_new+78                |      1280/64    |      1120/56    |       20 |        0 | 12.500%
         load_elf_binary+2c4                |        32/32    |        28/28    |        1 |        0 | 12.500%
         anon_vma_prepare+101               |       576/72    |       512/64    |        8 |        0 | 11.111%
         ...                                | ...             | ...             | ...    | ...      | ...
        ------------------------------------------------------------------------------------------------------
      
      After:
      
        ---------------------------------------------------------------------------------------------------------
         Callsite                           | Total_alloc/Per | Total_req/Per   | Hit      | Ping-pong | Frag
        ---------------------------------------------------------------------------------------------------------
         radeon_cs_parser_init.part.1+11a   |      2080/260   |      1504/188   |        8 |         0 | 27.692%
         radeon_cs_parser_init.part.1+e1    |       384/96    |       288/72    |        4 |         0 | 25.000%
         radeon_cs_parser_init.part.1+93    |       128/32    |        96/24    |        4 |         0 | 25.000%
         load_elf_binary+a39                |       512/512   |       392/392   |        1 |         0 | 23.438%
         __alloc_skb+89                     |      6144/877   |      4800/685   |        7 |         6 | 21.875%
         radeon_fence_emit+5c               |      1152/192   |       912/152   |        6 |         0 | 20.833%
         radeon_cs_parser_relocs+ad         |      8192/2048  |      6624/1656  |        4 |         0 | 19.141%
         radeon_sa_bo_new+78                |      1280/64    |      1120/56    |       20 |         0 | 12.500%
         load_elf_binary+2c4                |        32/32    |        28/28    |        1 |         0 | 12.500%
         anon_vma_prepare+101               |       576/72    |       512/64    |        8 |         0 | 11.111%
         ...                                | ...             | ...             | ...      | ...       | ...
        ---------------------------------------------------------------------------------------------------------
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Joonsoo Kim <js1304@gmail.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1426145571-3065-4-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      65f46e02
    • Namhyung Kim's avatar
      perf kmem: Allow -v option · bd72a33e
      Namhyung Kim authored
      
      
      Current perf kmem fails when -v option is used.  As it's very useful for
      debugging, let's allow it.
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joonsoo Kim <js1304@gmail.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1426145571-3065-3-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bd72a33e
    • Namhyung Kim's avatar
      perf kmem: Fix segfault when invalid sort key is given · 405f8755
      Namhyung Kim authored
      
      
      When it tries to free 'str', it was already updated by strsep() - so it
      needs to save the original pointer.
      
        # perf kmem stat -s xxx,hit
          Error: Unknown --sort key: 'xxx'
        *** Error in `perf': free(): invalid pointer: 0x0000000000e9e7b6 ***
        ======= Backtrace: =========
        /usr/lib/libc.so.6(+0x7198e)[0x7fc7e6e0d98e]
        /usr/lib/libc.so.6(+0x76dee)[0x7fc7e6e12dee]
        /usr/lib/libc.so.6(+0x775cb)[0x7fc7e6e135cb]
        ./perf[0x44a1b5]
        ./perf[0x490b20]
        ./perf(parse_options_step+0x173)[0x491773]
        ./perf(parse_options_subcommand+0xa7)[0x491fb7]
        ./perf(cmd_kmem+0x2bc)[0x44ae4c]
        ./perf[0x47aa13]
        ./perf(main+0x60a)[0x427a9a]
        /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7fc7e6dbc800]
        ./perf(_start+0x29)[0x427bb9]
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joonsoo Kim <js1304@gmail.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1426145571-3065-2-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      405f8755
    • Andi Kleen's avatar
      perf stat: Always correctly indent ratio column · 79103528
      Andi Kleen authored
      
      
      When cycles or instructions do not print anything, as in being,
      --per-socket or --per-core modi, the ratio column was not correctly
      indented for them. This lead to some ratios not lining up with the
      others. Always indent correctly when nothing is printed.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Link: http://lkml.kernel.org/r/1426087682-22765-3-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      79103528
    • Andi Kleen's avatar
      perf stat: Fix IPC and other formulas with -A · 56f0fd45
      Andi Kleen authored
      
      
      perf stat didn't compute the IPC and other formulas for individual CPUs
      with -A. Fix this for the easy -A case. As before, --per-core and
      --per-socket do not handle it, they simply print nothing.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Link: http://lkml.kernel.org/r/1426087682-22765-2-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      56f0fd45
    • Andi Kleen's avatar
      perf stat: Output running time and run/enabled ratio in CSV mode · d73515c0
      Andi Kleen authored
      
      
      The information how much a counter ran in 'perf stat' can be quite
      interesting for other tools to judge how trustworthy a measurement is.
      
      Currently it is only output in non CSV mode.
      
      This patches make perf stat always output the running time and the
      enabled/running ratio in CSV mode.
      
      This adds two new fields at the end for each line. I assume that
      existing tools ignore new fields at the end, so it's on by default.
      
      Only CSV mode is affected, no difference otherwise.
      
      v2: Add extra print_running function
      v3: Avoid printing nan
      v4: Remove some elses and add brackets.
      v5: Move non CSV case into print_running
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1426083387-17006-1-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d73515c0