1. 23 9月, 2015 2 次提交
    • N
      perf record: Synthesize COMM event for a command line workload · e803cf97
      Namhyung Kim 提交于
      When perf creates a new child to profile, the events are enabled on
      exec().  And in this case, it doesn't synthesize any event for the
      child since they'll be generated during exec().  But there's an window
      between the enabling and the event generation.
      
      It used to be overcome since samples are only in kernel (so we always
      have the map) and the comm is overridden by a later COMM event.
      However it won't work if events are processed and displayed before the
      COMM event overrides like in 'perf script'.  This leads to those early
      samples (like native_write_msr_safe) not having a comm but pid (like
      ':15328').
      
      So it needs to synthesize COMM event for the child explicitly before
      enabling so that it can have a correct comm.  But at this time, the
      comm will be "perf" since it's not exec-ed yet.
      
      Committer note:
      
      Before this patch:
      
        # perf record usleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.017 MB perf.data (7 samples) ]
        # perf script --show-task-events
          :4429  4429 27909.079372:          1 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
          :4429  4429 27909.079375:          1 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
          :4429  4429 27909.079376:         10 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
          :4429  4429 27909.079377:        223 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
          :4429  4429 27909.079378:       6571 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
         usleep  4429 27909.079380: PERF_RECORD_COMM exec: usleep:4429/4429
         usleep  4429 27909.079381:     185403 cycles:  ffffffff810a72d3 flush_signal_handlers (/lib/modules/4.
         usleep  4429 27909.079444:    2241110 cycles:      7fc575355be3 _dl_start (/usr/lib64/ld-2.20.so)
         usleep  4429 27909.079875: PERF_RECORD_EXIT(4429:4429):(4429:4429)
      
      After:
      
        # perf record usleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.017 MB perf.data (7 samples) ]
        # perf script --show-task
           perf     0     0.000000: PERF_RECORD_COMM: perf:8446/8446
           perf  8446 30154.038944:          1 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
           perf  8446 30154.038948:          1 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
           perf  8446 30154.038949:          9 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
           perf  8446 30154.038950:        230 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
           perf  8446 30154.038951:       6772 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
         usleep  8446 30154.038952: PERF_RECORD_COMM exec: usleep:8446/8446
         usleep  8446 30154.038954:     196923 cycles:  ffffffff81766440 _raw_spin_lock (/lib/modules/4.3.0-rc1
         usleep  8446 30154.039021:    2292130 cycles:      7f609a173dc4 memcpy (/usr/lib64/ld-2.20.so)
         usleep  8446 30154.039349: PERF_RECORD_EXIT(8446:8446):(8446:8446)
        #
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1442881495-2928-1-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e803cf97
    • A
      tools vm: Fix build due to removal of tools/lib/api/fs/debugfs.h · f6489bc2
      Arnaldo Carvalho de Melo 提交于
      There were some changes in how this debugfs mounting helper is
      implemented/exported and we forgot to check if there were other users
      besides perf, fix it.
      
      Need to do a make -C tools/ everytime we do changes to
      tools/{lib,include} and other places where we're moving things from
      tools/perf/ to be used by other tools/ living code.
      
      Fixed:
      
        $ make -C tools/vm
        make: Entering directory '/home/git/linux/tools/vm'
        make -C ../lib/api
        make[1]: Entering directory '/home/git/linux/tools/lib/api'
          CC       fd/array.o
          LD       fd/libapi-in.o
          CC       fs/fs.o
          CC       fs/tracing_path.o
          LD       fs/libapi-in.o
          CC       cpu.o
          LD       libapi-in.o
          AR       libapi.a
        make[1]: Leaving directory '/home/git/linux/tools/lib/api'
        gcc -Wall -Wextra -I../lib/ -o page-types page-types.c ../lib/api/libapi.a
        make: Leaving directory '/home/git/linux/tools/vm'
        $
      Reported-by: NVinson Lee <vlee@twopensource.com>
      Tested-by: NVinson Lee <vlee@twopensource.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Fixes: 60a1133a ("tools lib api fs: Remove debugfs, tracefs and findfs objects")
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f6489bc2
  2. 22 9月, 2015 7 次提交
    • J
      perf tools: Add include/err.h into MANIFEST · 96d8bf75
      Jiri Olsa 提交于
      Otherwise the tarpkg is incomplete (tarpkg tests fails).
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 01ca9fd4 ("tools: Add err.h with ERR_PTR PTR_ERR interface")
      Link: http://lkml.kernel.org/r/1442846143-8556-1-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      96d8bf75
    • A
      tools lib bpf: Use FEATURE_USER to allow building in the same dir as perf · 65f041be
      Arnaldo Carvalho de Melo 提交于
      When building tools/lib/bpf as part of the tools/perf/ build process,
      which will happend when we introduce a patch wiring that up, we end up
      stomping on the feature detection caching mechanism, that uses a file in
      the output directory (O=) that is shared by libbpf and perf to check if
      something changed from one build to another that requires redoing the
      feature detection process.
      
      By using the recently introduced FEATURE_USER tools/build/ knob, we can
      avoid that:
      
      Before, every make invokation would run the feature detection:
      
        $ make O=/tmp/build/perf -C tools/perf
        make: Entering directory '/home/git/linux/tools/perf'
        Auto-detecting system features:
        ...                         dwarf: [ on  ]
        ...                         glibc: [ on  ]
        <SNIP>
        ...                     get_cpuid: [ on  ]
        ...                           bpf: [ on  ]
      
          GEN      perf-archive
          GEN      perf-with-kcore
      
        Auto-detecting system features:
        ...                        libelf: [ on  ]
        ...                           bpf: [ on  ]
        <SNIP>
      
      After:
      
        $ make O=/tmp/build/perf -C tools/perf
        make: Entering directory '/home/git/linux/tools/perf'
          BUILD:   Doing 'make -j4' parallel build
        make: Leaving directory '/home/git/linux/tools/perf'
        $
      
      Because we now have two different feature detection state files:
      
        $ ls -la /tmp/build/perf/FEATURE-DUMP*
        -rw-rw-r--. 1 acme acme 338 Sep 21 17:25 /tmp/build/perf/FEATURE-DUMP
        -rw-rw-r--. 1 acme acme  33 Sep 21 17:25 /tmp/build/perf/FEATURE-DUMP.libbpf
        $
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: pi3orama@163.com
      Fixes: 1b76c13e ("bpf tools: Introduce 'bpf' library and add bpf feature check")
      Link: http://lkml.kernel.org/n/tip-s6ev9wfqy7pvvs58emys2g90@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      65f041be
    • A
      tools build: Allow setting the feature detection user · 13e96db6
      Arnaldo Carvalho de Melo 提交于
      We will use the tools/build/ autodetection in the eBPF patchkit
      and it is currently sharing the output directory with perf, that
      also uses the feature detection logic.
      
      As we keep state in the output directory, so that we can avoid running
      all the tests again, we need to have different filenames for the files
      used in this state, allow doing that via the FEATURE_USER variable, to
      be set alongside the existing FEATURE_{TEST,DISPLAY} variables.
      
      v2: Fix comment describing the FEATURE_DUMP filename to make sure where
          it is created, precisely at $(OUTPUT)FEATURE-DUMP$(FEATURE_USER).
          Pointed out by Jiri.
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/n/tip-fdbev0vrn3x6idqc3ajbnvcb@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      13e96db6
    • A
      tools lib bpf: Fix up FEATURE_{TESTS,DISPLAY} usage · 20517cd9
      Arnaldo Carvalho de Melo 提交于
      When libbpf was introduced it wrongly asked for the "libelf" and "bpf"
      feature tests to be performed (via FEATURE_TESTS), while asking that
      "libbpf", "libelf-mmap", "libelf-getphdrnum" and "bpf" to have the
      result of its respective tests to be displayed (via FEATURE_DISPLAY).
      
      Due to another recently bug fixed in the tools/build/ infrastructure
      ("tools build: Fixup feature detection display function name") the
      results for the entries in the FEATURE_DISPLAY, for this case, were
      appearing as all succeeding, when two of them (the ones only on the
      DISPLAY) were not even being performed.
      
      Before:
      
        $ make -C tools/lib/bpf/
        make: Entering directory '/home/git/linux/tools/lib/bpf'
        Auto-detecting system features:
        ...                        libelf: [ on  ]
        ...             libelf-getphdrnum: [ OFF ]
        ...                   libelf-mmap: [ OFF ]
        ...                           bpf: [ on  ]
        <SNIP>
      
      After, with FEATURE_TESTS == FEATURE_DISPLAY:
      
        Auto-detecting system features:
        ...                        libelf: [ on  ]
        ...             libelf-getphdrnum: [ on  ]
        ...                   libelf-mmap: [ on  ]
        ...                           bpf: [ on  ]
        <SNIP>
      
      I just inverted, so that it tests the four features but displays just
      the libelf and mmap ones, to make it more compact. So it becomes:
      
        $ make -C tools/lib/bpf/
        make: Entering directory '/home/git/linux/tools/lib/bpf'
      
        Auto-detecting system features:
        ...                        libelf: [ on  ]
        ...                           bpf: [ on  ]
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: pi3orama@163.com
      Fixes: 1b76c13e ("bpf tools: Introduce 'bpf' library and add bpf feature check")
      Link: http://lkml.kernel.org/n/tip-y4bd59e6j9rzzojiyeqrg2jq@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      20517cd9
    • A
      tools build: Fixup feature detection display function name · 6076e2a4
      Arnaldo Carvalho de Melo 提交于
      Cut'n'paste mistake, it should eval the name of the function
      defined right next to it, in the next line, fix it.
      
      Before:
      
        $ make -C tools/lib/bpf/
        make: Entering directory '/home/git/linux/tools/lib/bpf'
      
        Auto-detecting system features:
        ...                        libelf: [ on  ]
        ...             libelf-getphdrnum: [ on  ]
        ...                   libelf-mmap: [ on  ]
        ...                           bpf: [ on  ]
        <SNIP>
      
      After:
      
        $ make -C tools/lib/bpf/
        make: Entering directory '/home/git/linux/tools/lib/bpf'
      
        Auto-detecting system features:
        ...                        libelf: [ on  ]
        ...             libelf-getphdrnum: [ OFF ]
        ...                   libelf-mmap: [ OFF ]
        ...                           bpf: [ on  ]
        <SNIP>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: pi3orama@163.com
      Fixes: 58d4f00f ("perf build: Fix feature_check name clash")
      Link: http://lkml.kernel.org/n/tip-dzu1c4sruukgfq5d5b1c4r30@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6076e2a4
    • W
      perf tools: Don't assume that the parser returns non empty evsel list · 854f7363
      Wang Nan 提交于
      Don't blindly retrieve and use a last element in the lists returned by
      parse_events__scanner(), as it may have collected no entries, i.e.
      return an empty list.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kaixu Xia <xiakaixu@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1441523623-152703-2-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      854f7363
    • M
      perf probe: Fix a segfault when removing uprobe events · 0fb18553
      Masami Hiramatsu 提交于
      Fix a segfault bug and a small mistake in perf probe -d.
      
      Since the "ulist" in perf_del_probe_events is never initialized,
      strlist__add(ulist, *) always causes a segfault when removing
      uprobe events by perf probe -d.
      
      Also, the "str" local variable is never released if fail to
      allocate the "klist". This fixes it too.
      
      This has been introduced by the commit e607f142 ("perf probe:
      Print deleted events in cmd_probe()").
      Reported-by: NMilian Wolff <milian.wolff@kdab.com>
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/20150916125241.4446.44805.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0fb18553
  3. 18 9月, 2015 31 次提交