Skip to content
  1. Nov 18, 2015
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo' of... · e15bf88a
      Ingo Molnar authored
      
      Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
        - Do not change the key of an object in a rbtree, this time it was
          the one for DSOs lookup by its long_name, and the noticed symptom was
          with 'perf buildid-list --with-hits' (Adrian Hunter)
      
        - 'perf inject' is a pipe, events it doesn't touch should be passed
          on, PERF_RECORD_LOST wasn't, fix it (Adrian Hunter)
      
        - Make 'perf buildid-list' request event ordering, as it needs to
          first get the mmap events to be able to mark wich DSOs had hits
          (Adrian Hunter)
      
        - Fix memory leaks on failure in 'perf probe' (Masami Hiramatsu, Wang Nan)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      e15bf88a
  2. Nov 13, 2015
    • Wang Nan's avatar
      perf probe: Clear probe_trace_event when add_probe_trace_event() fails · 092b1f0b
      Wang Nan authored
      
      
      When probing with a glob, errors in add_probe_trace_event() won't be
      passed to debuginfo__find_trace_events() because it would be modified by
      probe_point_search_cb(). It causes a segfault if perf fails to find an
      argument for a probe point matched by the glob. For example:
      
        # ./perf probe -v -n 'SyS_dup? oldfd'
        probe-definition(0): SyS_dup? oldfd
        symbol:SyS_dup? file:(null) line:0 offset:0 return:0 lazy:(null)
        parsing arg: oldfd into oldfd
        1 arguments
        Looking at the vmlinux_path (7 entries long)
        Using /lib/modules/4.3.0-rc4+/build/vmlinux for symbols
        Open Debuginfo file: /lib/modules/4.3.0-rc4+/build/vmlinux
        Try to find probe point from debuginfo.
        Matched function: SyS_dup3
        found inline addr: 0xffffffff812095c0
        Probe point found: SyS_dup3+0
        Searching 'oldfd' variable in context.
        Converting variable oldfd into trace event.
        oldfd type is long int.
        found inline addr: 0xffffffff812096d4
        Probe point found: SyS_dup2+36
        Searching 'oldfd' variable in context.
        Failed to find 'oldfd' in this function.
        Matched function: SyS_dup3
        Probe point found: SyS_dup3+0
        Searching 'oldfd' variable in context.
        Converting variable oldfd into trace event.
        oldfd type is long int.
        Matched function: SyS_dup2
        Probe point found: SyS_dup2+0
        Searching 'oldfd' variable in context.
        Converting variable oldfd into trace event.
        oldfd type is long int.
        Found 4 probe_trace_events.
        Opening /sys/kernel/debug/tracing//kprobe_events write=1
        Writing event: p:probe/SyS_dup3 _text+2135488 oldfd=%di:s64
        Segmentation fault (core dumped)
        #
      
      This patch ensures that add_probe_trace_event() doesn't touches
      tf->ntevs and tf->tevs if those functions fail.
      
      After the patch:
      
        # perf probe  'SyS_dup? oldfd'
        Failed to find 'oldfd' in this function.
        Added new events:
          probe:SyS_dup3       (on SyS_dup? with oldfd)
          probe:SyS_dup3_1     (on SyS_dup? with oldfd)
          probe:SyS_dup2       (on SyS_dup? with oldfd)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e probe:SyS_dup2 -aR sleep 1
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1447417761-156094-3-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      092b1f0b
    • Masami Hiramatsu's avatar
      perf probe: Fix memory leaking on failure by clearing all probe_trace_events · 0196e787
      Masami Hiramatsu authored
      
      
      Fix memory leaking on the debuginfo__find_trace_events() failure path
      which frees an array of probe_trace_events but doesn't clears all the
      allocated sub-structures and strings.
      
      So, before doing zfree(tevs), clear all the array elements which may
      have allocated resources.
      
      Reported-by: default avatarWang Nan <wangnan0@huawei.com>
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1447417761-156094-2-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0196e787
    • Adrian Hunter's avatar
      perf inject: Also re-pipe lost_samples event · d8145b3e
      Adrian Hunter authored
      
      
      perf inject must re-pipe all events otherwise they get dropped from the
      output file.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1447408112-1920-4-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d8145b3e
    • Adrian Hunter's avatar
      perf buildid-list: Requires ordered events · 1216b65c
      Adrian Hunter authored
      
      
      'perf buildid-list' processes events to determine hits (i.e. with-hits
      option).  That may not work if events are not sorted in order. i.e. MMAP
      events must be processed before the samples that depend on them so that
      sample processing can 'hit' the DSO to which the MMAP refers.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1447408112-1920-3-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1216b65c
    • Adrian Hunter's avatar
      perf symbols: Fix dso lookup by long name and missing buildids · e266a753
      Adrian Hunter authored
      Commit 4598a0a6
      
       ("perf symbols: Improve DSO long names lookup speed
      with rbtree") Added a tree to lookup dsos by long name.  That tree gets
      corrupted whenever a dso long name is changed because the tree is not
      updated.
      
      One effect of that is buildid-list does not work with the 'with-hits'
      option because dso lookup fails and results in two structs for the same
      dso.  The first has the buildid but no hits, the second has hits but no
      buildid. e.g.
      
      Before:
      
        $ tools/perf/perf record ls
        arch     certs    CREDITS  Documentation  firmware  include
        ipc      Kconfig  lib      Makefile       net       REPORTING-BUGS
        scripts  sound    usr      block          COPYING   crypto
        drivers  fs       init     Kbuild         kernel    MAINTAINERS
        mm       README   samples  security       tools     virt
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.012 MB perf.data (11 samples) ]
        $ tools/perf/perf buildid-list
        574da826c66538a8d9060d393a8866289bd06005 [kernel.kallsyms]
        30c94dc66a1fe95180c3d68d2b89e576d5ae213c /lib/x86_64-linux-gnu/libc-2.19.so
        $ tools/perf/perf buildid-list -H
        574da826c66538a8d9060d393a8866289bd06005 [kernel.kallsyms]
        0000000000000000000000000000000000000000 /lib/x86_64-linux-gnu/libc-2.19.so
      
      After:
      
        $ tools/perf/perf buildid-list -H
        574da826c66538a8d9060d393a8866289bd06005 [kernel.kallsyms]
        30c94dc66a1fe95180c3d68d2b89e576d5ae213c /lib/x86_64-linux-gnu/libc-2.19.so
      
      The fix is to record the root of the tree on the dso so that
      dso__set_long_name() can update the tree when the long name changes.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Douglas Hatch <doug.hatch@hp.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Scott J Norton <scott.norton@hp.com>
      Cc: Waiman Long <Waiman.Long@hp.com>
      Fixes: 4598a0a6
      
       ("perf symbols: Improve DSO long names lookup speed with rbtree")
      Link: http://lkml.kernel.org/r/1447408112-1920-2-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e266a753
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo' of... · 2a49f02a
      Ingo Molnar authored
      
      Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
        - Fix 'd' hotkey for filtering by DSO in the top/report
          TUI browser (Arnaldo Carvalho de Melo)
      
        - Allow forcing reading of non-root owned /tmp/perf-PID JIT
          symbol maps (Arnaldo Carvalho de Melo)
      
        - Rebuild rbtree when adjusting symbols for kcore (Adrian Hunter)
      
        - Actually install tmon in the tools/ install rule (Kamal Mostafa)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      2a49f02a
    • Arnaldo Carvalho de Melo's avatar
      perf symbols: Allow forcing reading of non-root owned files by root · 2059fc7a
      Arnaldo Carvalho de Melo authored
      
      
      When the root user tries to read a file owned by some other user we get:
      
        # ls -la perf.data
        -rw-------. 1 acme acme 20032 Nov 12 15:50 perf.data
        # perf report
        File perf.data not owned by current user or root (use -f to override)
        # perf report -f | grep -v ^# | head -2
          30.96%  ls       [kernel.vmlinux]  [k] do_set_pte
          28.24%  ls       libc-2.20.so      [.] intel_check_word
        #
      
      That wasn't happening when the symbol code tried to read a JIT map,
      where the same check was done but no forcing was possible, fix it.
      
      Reported-by: default avatarBrendan Gregg <brendan.d.gregg@gmail.com>
      Tested-by: default avatarBrendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://permalink.gmane.org/gmane.linux.kernel.perf.user/2380
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2059fc7a
    • Arnaldo Carvalho de Melo's avatar
      perf hists browser: The dso can be obtained from popup_action->ms.map->dso · b7f294b5
      Arnaldo Carvalho de Melo authored
      
      
      So no need to have a 'dso' member in 'popup_action', remove it as no
      code is using it, already.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-76a6s0007slug0op0wkl6o8b@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b7f294b5
    • Arnaldo Carvalho de Melo's avatar
      perf hists browser: Fix 'd' hotkey action to filter by DSO · fae00650
      Arnaldo Carvalho de Melo authored
      When pressing 'd' the expected action is to filter all entries by the
      DSO in the current entry, but for that the action->map needs to be set,
      and only action->dso was being set, fix it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 045b80dd
      
       ("perf hists browser: Use the map to determine if a DSO is being used as a kernel")
      Link: http://lkml.kernel.org/n/tip-xqhfzgoblq49lk5h5u82atro@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fae00650
    • Adrian Hunter's avatar
      perf symbols: Rebuild rbtree when adjusting symbols for kcore · 866548dd
      Adrian Hunter authored
      
      
      Normally symbols are read from the DSO and adjusted, if need be, so that
      the symbol start matches the file offset in the DSO file (we want the
      file offset because that is what we know from MMAP events). That is done
      by dso__load_sym() which inserts the symbols *after* adjusting them.
      
      In the case of kcore, the symbols have been read from kallsyms and the
      symbol start is the memory address. The symbols have to be adjusted to
      match the kcore file offsets. dso__split_kallsyms_for_kcore() does that,
      but now the adjustment is being done *after* the symbols have been
      inserted. It appears dso__split_kallsyms_for_kcore() was assuming that
      changing the symbol start would not change the order in the rbtree -
      which is, of course, not guaranteed.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/563CB241.2090701@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      866548dd
    • Kamal Mostafa's avatar
      tools: Add a "make all" rule · f6ba98c5
      Kamal Mostafa authored
      
      
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      Acked-by: default avatarPavel Machek <pavel@ucw.cz>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jonathan Cameron <jic23@kernel.org>
      Cc: Pali Rohar <pali.rohar@gmail.com>
      Cc: Roberta Dobrescu <roberta.dobrescu@gmail.com>
      Link: http://lkml.kernel.org/r/1447280736-2161-2-git-send-email-kamal@canonical.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f6ba98c5
  3. Nov 12, 2015
    • Kamal Mostafa's avatar
      tools: Actually install tmon in the install rule · 836d525b
      Kamal Mostafa authored
      
      
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Pali Rohar <pali.rohar@gmail.com>
      Cc: Roberta Dobrescu <roberta.dobrescu@gmail.com>
      Link: http://lkml.kernel.org/r/1447280736-2161-1-git-send-email-kamal@canonical.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      836d525b
    • Huang Rui's avatar
      perf/x86/intel/rapl: Remove the unused RAPL_EVENT_DESC() macro · 41ac18eb
      Huang Rui authored
      
      
      Signed-off-by: default avatarHuang Rui <ray.huang@amd.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>
      Cc: Fengguang Wu <fengguang.wu@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tony Li <tony.li@amd.com>
      Link: http://lkml.kernel.org/r/1446630233-3166-1-git-send-email-ray.huang@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      41ac18eb
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo' of... · 492cf7a0
      Ingo Molnar authored
      
      Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
        - Add missing newlines to some pr_err() calls (Arnaldo Carvalho de Melo)
      
        - Print full source file paths when using
          'perf annotate --print-line --full-paths' (Michael Petlan)
      
        - Fix 'perf probe -d' when just one out of uprobes and kprobes is
          enabled (Wang Nan)
      
        - Add compiler.h to list.h to fix 'make perf-tar-src-pkg' generated
          tarballs, i.e. out of tree building (Arnaldo Carvalho de Melo)
      
        - Add the llvm-src-base.c and llvm-src-kbuild.c files, generated by the
          'perf test' LLVM entries, when running it in-tree, to .gitignore (Yunlong Song)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      492cf7a0
    • Arnaldo Carvalho de Melo's avatar
      tools include: Add compiler.h to list.h · 5602ea09
      Arnaldo Carvalho de Melo authored
      list.h needs WRITE_ONCE() since 7f5f873c
      
       ("rculist: Use WRITE_ONCE()
      when deleting from reader-visible list") add it before including the
      kernel's list.h file.
      
      This fixes builds of 'make perf-tar-src-pkg' perf tool tarball builds,
      i.e. out of tree builds.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-e0rb8f7jwz0jn24ttyick9u6@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5602ea09
    • Wang Nan's avatar
      perf probe: Verify parameters in two functions · 421fd084
      Wang Nan authored
      
      
      On kernel with only one out of CONFIG_KPROBE_EVENTS and
      CONFIG_UPROBE_EVENTS enabled, 'perf probe -d' causes a segfault because
      perf_del_probe_events() calls probe_file__get_events() with a negative
      fd.
      
      This patch fixes it by adding parameter validation at the entry of
      probe_file__get_events() and probe_file__get_rawlist(). Since they are
      both non-static public functions (in .h file), parameter verifying is
      required.
      
      v1 -> v2: Verify fd at the head of probe_file__get_rawlist() instead of
                checking at call site (suggested by Masami and Arnaldo at [1,2]).
      
      [1] http://lkml.kernel.org/r/50399556C9727B4D88A595C8584AAB37526048E3@GSjpTKYDCembx32.service.hitachi.net
      [2] http://lkml.kernel.org/r/20151105155830.GV13236@kernel.org
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446803415-83382-1-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      421fd084
    • Arnaldo Carvalho de Melo's avatar
      perf session: Add missing newlines to some pr_err() calls · e87b4911
      Arnaldo Carvalho de Melo authored
      
      
      Before:
      
        [acme@zoo linux]$ perf evlist
        WARNING: The perf.data file's data size field is 0 which is unexpected.
        Was the 'perf record' command properly terminated?
        non matching sample_type[acme@zoo linux]$
      
      After:
      
        [acme@zoo linux]$ perf evlist
        WARNING: The perf.data file's data size field is 0 which is unexpected.
        Was the 'perf record' command properly terminated?
        non matching sample_type
        [acme@zoo linux]$
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-wscok3a2s7yrj8156oc2r6qe@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e87b4911
    • Michael Petlan's avatar
      perf annotate: Support full source file paths for srcline fix · 4a4c03c1
      Michael Petlan authored
      
      
      The --full-paths option did not show the full source file paths in the 'perf
      annotate' tool, because the value of the option was not propagated into the
      related functions.
      
      With this patch the value of the --full-paths option is known to the function
      that composes the srcline string, so it prints the full path when necessary.
      
      Committer Note:
      
      This affects annotate when the --print-line option is used:
      
        # perf annotate -h 2>&1 | grep print-line
            -l, --print-line      print matching source lines (may be slow)
      
      Looking just at the lines that should be affected by this change:
      
      Before:
      
        # perf annotate --print-line --full-paths --stdio fput | grep '\.[ch]:[0-9]\+'
           94.44 atomic64_64.h:114
            5.56 file_table.c:265
         file_table.c:265    5.56 :	  ffffffff81219a00:       callq  ffffffff81769360 <__fentry__>
         atomic64_64.h:114   94.44 :	  ffffffff81219a05:       lock decq 0x38(%rdi)
      
      After:
      
        # perf annotate --print-line --full-paths --stdio fput | grep '\.[ch]:[0-9]\+'
           94.44 /home/git/linux/arch/x86/include/asm/atomic64_64.h:114
            5.56 /home/git/linux/fs/file_table.c:265
         /home/git/linux/fs/file_table.c:265    5.56 :	  ffffffff81219a00:       callq  ffffffff81769360 <__fentry__>
         /home/git/linux/arch/x86/include/asm/atomic64_64.h:114   94.44 :	  ffffffff81219a05:       lock decq 0x38(%rdi)
        #
      
      Signed-off-by: default avatarMichael Petlan <mpetlan@redhat.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Link: http://permalink.gmane.org/gmane.linux.kernel.perf.user/2365
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4a4c03c1
    • Yunlong Song's avatar
      perf test: Add llvm-src-base.c and llvm-src-kbuild.c to .gitignore · 3d07b3be
      Yunlong Song authored
      Commit b31de018 ("perf test: Enhance the
      LLVM test: update basic BPF test program") dynamically creates file
      llvm-src-base.c during the perf building.
      
      Similarly, the commit 7af3f3d5
      
       ("perf
      test: Enhance the LLVM tests: add kbuild test") dynamically creates file
      llvm-src-kbuild.c during the perf building. Add them to .gitignore.
      
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.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: Wang Nan <wangnan0@huawei.com>
      Fixes: b31de018 ("perf test: Enhance the LLVM test: update basic BPF test program")
      Fixes: 7af3f3d5
      
       ("perf test: Enhance the LLVM tests: add kbuild test")
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3d07b3be
  4. Nov 09, 2015
    • Peter Zijlstra's avatar
      perf: Fix inherited events vs. tracepoint filters · b71b437e
      Peter Zijlstra authored
      
      
      Arnaldo reported that tracepoint filters seem to misbehave (ie. not
      apply) on inherited events.
      
      The fix is obvious; filters are only set on the actual (parent)
      event, use the normal pattern of using this parent event for filters.
      This is safe because each child event has a reference to it.
      
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frédéric Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/r/20151102095051.GN17308@twins.programming.kicks-ass.net
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b71b437e
    • Paul E. McKenney's avatar
      perf: Disable IRQs across RCU RS CS that acquires scheduler lock · 2fd59077
      Paul E. McKenney authored
      
      
      The perf_lock_task_context() function disables preemption across its
      RCU read-side critical section because that critical section acquires
      a scheduler lock.  If there was a preemption during that RCU read-side
      critical section, the rcu_read_unlock() could attempt to acquire scheduler
      locks, resulting in deadlock.
      
      However, recent optimizations to expedited grace periods mean that IPI
      handlers that execute during preemptible RCU read-side critical sections
      can now cause the subsequent rcu_read_unlock() to acquire scheduler locks.
      Disabling preemption does nothiing to prevent these IPI handlers from
      executing, so these optimizations introduced a deadlock.  In theory,
      this deadlock could be avoided by pulling all wakeups and printk()s out
      from rnp->lock critical sections, but in practice this would re-introduce
      some RCU CPU stall warning bugs.
      
      Given that acquiring scheduler locks entails disabling interrupts, these
      deadlocks can be avoided by disabling interrupts (instead of disabling
      preemption) across any RCU read-side critical that acquires scheduler
      locks and holds them across the rcu_read_unlock().  This commit therefore
      makes this change for perf_lock_task_context().
      
      Reported-by: default avatarDave Jones <davej@codemonkey.org.uk>
      Reported-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Stephane Eranian <eranian@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20151104134838.GR29027@linux.vnet.ibm.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      2fd59077
  5. Nov 08, 2015
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-2' of... · bad9bc2d
      Ingo Molnar authored
      
      Merge tag 'perf-core-for-mingo-2' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      Fixes:
      
        - libbpf error reporting improvements, using a strerror interface to
          more precisely tell the user about problems with the provided
          scriptlet, be it in C or as a ready made object file (Wang Nan)
      
        - Do not be case sensitive when searching for matching 'perf test'
          entries (Arnaldo Carvalho de Melo)
      
        - Inform the user about objdump failures in 'perf annotate' (Andi Kleen)
      
      Infrastructure changes:
      
        - Improve the LLVM 'perf test' entry, introduce a new ones for
          BPF and kbuild tests to check the environment used by clang to
          compile .c scriptlets (Wang Nan)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      bad9bc2d
  6. Nov 07, 2015
    • Arnaldo Carvalho de Melo's avatar
      perf test: Do not be case sensitive when searching for matching tests · 345c99a3
      Arnaldo Carvalho de Melo authored
      
      
      Before:
      
        # perf test llvm
        # perf test LLVM
        35: Test LLVM searching and compiling                        : Ok
        #
      
      After
      
        # perf test llvm
        35: Test LLVM searching and compiling                        : Ok
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-c1u05npqbf6epse17ovfejoj@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      345c99a3
    • Wang Nan's avatar
      perf test: Add 'perf test BPF' · ba1fae43
      Wang Nan authored
      
      
      This patch adds BPF testcase for testing BPF event filtering.
      
      By utilizing the result of 'perf test LLVM', this patch compiles the
      eBPF sample program then test its ability. The BPF script in 'perf test
      LLVM' lets only 50% samples generated by epoll_pwait() to be captured.
      This patch runs that system call for 111 times, so the result should
      contain 56 samples.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446817783-86722-8-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ba1fae43
    • Wang Nan's avatar
      perf test: Enhance the LLVM tests: add kbuild test · 7af3f3d5
      Wang Nan authored
      
      
      This patch adds a kbuild testcase to check whether kernel headers can be
      correctly found.
      
      For example:
        # mv /lib/modules/4.3.0-rc5{,.bak}
        # perf test LLVM
      
          38: Test LLVM searching and compiling                        : Skip
      
        # perf test -v LLVM
        ...
        <stdin>:11:10: fatal error: 'uapi/linux/fs.h' file not found
        #include <uapi/linux/fs.h>
                ^
        1 error generated.
        ERROR:	unable to compile -
        Hint:	Check error message shown above.
        Hint:	You can also pre-compile it into .o using:
           		 clang -target bpf -O2 -c -
      	 with proper -I and -D options.
        Failed to compile test case: 'Test kbuild searching'
        test child finished with -2
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446817783-86722-7-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7af3f3d5
    • Wang Nan's avatar
      perf test: Enhance the LLVM test: update basic BPF test program · b31de018
      Wang Nan authored
      
      
      This patch replaces the original toy BPF program with the previously
      introduced bpf-script-example.c. Dynamically embeddeding it into
      'llvm-src-base.c'.
      
      The newly introduced BPF program attaches a BPF program to
      'sys_epoll_pwait()'. perf itself never use that syscall, so further test
      can verify their result with it. The program would generate 1 sample in
      every 2 calls of epoll_pwait() system call.
      
      Since the resulting BPF object is useful per se for further tests,
      test_llvm__fetch_bpf_obj() is introduced for creating BPF objects from
      source. The LLVM test was rewritten to use it.
      
      Committer note:
      
      Running it:
      
        [root@zoo wb]# perf test -v LLVM
        35: Test LLVM searching and compiling                        :
        --- start ---
        test child forked, pid 17740
        Kernel build dir is set to /lib/modules/4.3.0-rc1+/build
        set env: KBUILD_DIR=/lib/modules/4.3.0-rc1+/build
        unset env: KBUILD_OPTS
        include option is set to  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include -I/home/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -I/home/git/linux/include -Iinclude -I/home/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/git/linux/include/uapi -Iinclude/generated/uapi -include /home/git/linux/include/linux/kconfig.h
        set env: NR_CPUS=4
        set env: LINUX_VERSION_CODE=0x40300
        set env: CLANG_EXEC=/usr/libexec/icecc/bin/clang
        set env: CLANG_OPTIONS=-xc
        set env: KERNEL_INC_OPTIONS= -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.9.2/include -I/home/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated  -I/home/git/linux/include -Iinclude -I/home/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/git/linux/include/uapi -Iinclude/generated/uapi -include /home/git/linux/include/linux/kconfig.h
        set env: WORKING_DIR=/lib/modules/4.3.0-rc1+/build
        set env: CLANG_SOURCE=-
        llvm compiling command template: echo '/*
         * bpf-script-example.c
         * Test basic LLVM building
         */
        #ifndef LINUX_VERSION_CODE
        # error Need LINUX_VERSION_CODE
        # error Example: for 4.2 kernel, put 'clang-opt="-DLINUX_VERSION_CODE=0x40200" into llvm section of ~/.perfconfig'
        #endif
        #define BPF_ANY 0
        #define BPF_MAP_TYPE_ARRAY 2
        #define BPF_FUNC_map_lookup_elem 1
        #define BPF_FUNC_map_update_elem 2
      
        static void *(*bpf_map_lookup_elem)(void *map, void *key) =
      	  (void *) BPF_FUNC_map_lookup_elem;
        static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =
      	  (void *) BPF_FUNC_map_update_elem;
      
        struct bpf_map_def {
      	  unsigned int type;
      	  unsigned int key_size;
      	  unsigned int value_size;
      	  unsigned int max_entries;
        };
      
        #define SEC(NAME) __attribute__((section(NAME), used))
        struct bpf_map_def SEC("maps") flip_table = {
      	  .type = BPF_MAP_TYPE_ARRAY,
      	  .key_size = sizeof(int),
      	  .value_size = sizeof(int),
      	  .max_entries = 1,
        };
      
        SEC("func=sys_epoll_pwait")
        int bpf_func__sys_epoll_pwait(void *ctx)
        {
      	  int ind =0;
      	  int *flag = bpf_map_lookup_elem(&flip_table, &ind);
      	  int new_flag;
      	  if (!flag)
      		  return 0;
      	  /* flip flag and store back */
      	  new_flag = !*flag;
      	  bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY);
      	  return new_flag;
        }
        char _license[] SEC("license") = "GPL";
        int _version SEC("version") = LINUX_VERSION_CODE;
        ' | $CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS -DLINUX_VERSION_CODE=$LINUX_VERSION_CODE $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o -
        test child finished with 0
        ---- end ----
        Test LLVM searching and compiling: Ok
        [root@zoo wb]#
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446817783-86722-6-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b31de018
    • Wang Nan's avatar
      perf bpf: Improve BPF related error messages · d3e0ce39
      Wang Nan authored
      
      
      A series of bpf loader related error codes were introduced to help error
      reporting. Functions were improved to return these new error codes.
      
      Functions which return pointers were adjusted to encode error codes into
      return value using the ERR_PTR() interface.
      
      bpf_loader_strerror() was improved to convert these error messages to
      strings. It checks the error codes and calls libbpf_strerror() and
      strerror_r() accordingly, so caller don't need to consider checking the
      range of the error code.
      
      In bpf__strerror_load(), print kernel version of running kernel and the
      object's 'version' section to notify user how to fix his/her program.
      
      v1 -> v2:
       Use macro for error code.
      
       Fetch error message based on array index, eliminate for-loop.
      
       Print version strings.
      
      Before:
      
        # perf record -e ./test_kversion_nomatch_program.o sleep 1
        event syntax error: './test_kversion_nomatch_program.o'
                             \___ Failed to load program: Validate your program and check 'license'/'version' sections in your object
        SKIP
      
        After:
      
        # perf record -e ./test_kversion_nomatch_program.o ls
        event syntax error: './test_kversion_nomatch_program.o'
                             \___ 'version' (4.4.0) doesn't match running kernel (4.3.0)
        SKIP
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446818289-87444-1-git-send-email-wangnan0@huawei.com
      [ Add 'static inline' to bpf__strerror_prepare_load() when LIBBPF is disabled ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d3e0ce39
    • Wang Nan's avatar
      perf tools: Make fetch_kernel_version() publicly available · 07bc5c69
      Wang Nan authored
      
      
      There are 2 places in llvm-utils.c which find kernel version information
      through uname. This patch extracts the uname related code into a
      fetch_kernel_version() function and puts it into util.h so it can be
      reused.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446818135-87310-1-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      07bc5c69
    • Wang Nan's avatar
      bpf tools: Add new API bpf_object__get_kversion() · 45825d8a
      Wang Nan authored
      
      
      bpf_object__get_kversion() can be used to fetch value of object's
      'version' section. Following patch will use it for error reporting.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446817783-86722-3-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      45825d8a
    • Wang Nan's avatar
      bpf tools: Improve libbpf error reporting · 6371ca3b
      Wang Nan authored
      
      
      In this patch, a series of libbpf specific error numbers and
      libbpf_strerror() are introduced to help reporting errors.
      
      Functions are updated to pass correct the error number through the
      CHECK_ERR() macro.
      
      All users of bpf_object__open{_buffer}() and bpf_program__title() in
      perf are modified accordingly. In addition, due to the error codes
      changing, bpf__strerror_load() is also modified to use them.
      
      bpf__strerror_head() is also changed accordingly so it can parse libbpf
      errors. bpf_loader_strerror() is introduced for that purpose, and will
      be improved by the following patch.
      
      load_program() is improved not to dump log buffer if it is empty. log
      buffer is also used to deduce whether the error was caused by an invalid
      program or other problem.
      
      v1 -> v2:
      
       - Using macro for error code.
      
       - Fetch error message based on array index, eliminate for-loop.
      
       - Use log buffer to detect the reason of failure. 3 new error code
         are introduced to replace LIBBPF_ERRNO__LOAD.
      
      In v1:
      
        # perf record -e ./test_ill_program.o ls
        event syntax error: './test_ill_program.o'
                             \___ Failed to load program: Validate your program and check 'license'/'version' sections in your object
        SKIP
      
        # perf record -e ./test_kversion_nomatch_program.o ls
        event syntax error: './test_kversion_nomatch_program.o'
                             \___ Failed to load program: Validate your program and check 'license'/'version' sections in your object
        SKIP
      
        # perf record -e ./test_big_program.o ls
        event syntax error: './test_big_program.o'
                             \___ Failed to load program: Validate your program and check 'license'/'version' sections in your object
        SKIP
      
        In v2:
      
        # perf record -e ./test_ill_program.o ls
        event syntax error: './test_ill_program.o'
                             \___ Kernel verifier blocks program loading
        SKIP
      
        # perf record -e ./test_kversion_nomatch_program.o
        event syntax error: './test_kversion_nomatch_program.o'
                             \___ Incorrect kernel version
        SKIP
        (Will be further improved by following patches)
      
        # perf record -e ./test_big_program.o
        event syntax error: './test_big_program.o'
                             \___ Program too big
        SKIP
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446817783-86722-2-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6371ca3b
  7. Nov 06, 2015
    • Masami Hiramatsu's avatar
      perf probe: Cleanup find_perf_probe_point_from_map to reduce redundancy · 0a62f686
      Masami Hiramatsu authored
      
      
      In find_perf_probe_point_from_map(), the 'ret' variable is initialized
      with -ENOENT but overwritten by the return code of
      kernel_get_symbol_address_by_name(), and after that it is re-initialized
      with -ENOENT again.
      
      Setting ret=-ENOENT twice looks a bit redundant. This avoids the
      overwriting and just returns -ENOENT if some error happens to simplify
      the code.
      
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/n/tip-ufp1zgbktzmttcputozneomd@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0a62f686
    • Andi Kleen's avatar
      perf annotate: Inform the user about objdump failures in --stdio · 62ec9b3f
      Andi Kleen authored
      
      
      When the browser fails to annotate it is difficult for users to find out
      what went wrong.
      
      Add some errors for objdump failures that are displayed in the UI.
      
      Note it would be even better to handle these errors smarter, like
      falling back to the binary when the debug info is somehow corrupted. But
      for now just giving a better error is an improvement.
      
      Committer note:
      
      This works for --stdio, where errors just scroll by the screen:
      
        # perf annotate --stdio intel_idle
        Failure running objdump  --start-address=0xffffffff81418290 --stop-address=0xffffffff814183ae -l -d --no-show-raw -S -C /root/.debug/.build-id/28/2777c262e6b3c0451375163c9a81c893218ab1 2>/dev/null|grep -v /root/.debug/.build-id/28/2777c262e6b3c0451375163c9a81c893218ab1|expand
         Percent |      Source code & Disassembly of vmlinux for cycles:pp
        ------------------------------------------------------------------
      
      And with that one can use that command line to try to find out more about what
      happened instead of getting a blank screen, an improvement.
      
      We need tho to improve this further to get it to work with other UIs, like
      --tui and --gtk, where it continues showing a blank screen, no messages, as
      the pr_err() used is enough just for --stdio.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1446779167-18949-1-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      62ec9b3f
    • Jiri Olsa's avatar
      perf stat: Make stat options global · e0547311
      Jiri Olsa authored
      
      
      So they can be used in perf stat record command in following patch.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarKan Liang <kan.liang@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1446734469-11352-2-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e0547311
  8. Nov 05, 2015
    • Jiri Olsa's avatar
      perf sched latency: Fix thread pid reuse issue · 0014de17
      Jiri Olsa authored
      
      
      The latency subcommand holds a tree of working atoms sorted by thread's
      pid/tid. If there's new thread with same pid and tid, the old working atom is
      found and assert bug condition is hit in search function:
      
        thread_atoms_search: Assertion `!(thread != atoms->thread)' failed
      
      Changing the sort function to use thread object pointers together with pid and
      tid check. This way new thread will never find old one with same pid/tid.
      
      Link: http://lkml.kernel.org/n/tip-o4doazhhv0zax5zshkg8hnys@git.kernel.org
      Reported-by: default avatarMohit Agrawal <moagrawa@redhat.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1446462625-15807-1-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0014de17
    • Wang Nan's avatar
      perf tools: Fix find_perf_probe_point_from_map() which incorrectly returns success · 98d3b258
      Wang Nan authored
      
      
      It is possible that find_perf_probe_point_from_map() fails to find a
      symbol but still returns 0 because of an small error when coding:
      find_perf_probe_point_from_map() set 'ret' to error code at first, but
      also use it to hold return value of kernel_get_symbol_address_by_name().
      
      This patch resets 'ret' to error even kernel_get_symbol_address_by_name()
      success, so if !sym, the whole function returns error correctly.
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446729565-27592-3-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      98d3b258
    • Peter Feiner's avatar
      perf trace: Fix documentation for -i · 956959f6
      Peter Feiner authored
      The -i flag was incorrectly listed as a short flag for --no-inherit.  It
      should have only been listed as a short flag for --input.
      
      This documentation error has existed since the --input flag was
      introduced in 6810fc91
      
       (perf trace: Add
      option to analyze events in a file versus live).
      
      Signed-off-by: default avatarPeter Feiner <pfeiner@google.com>
      Cc: David Ahern <dsahern@gmail.com>
      Link: http://lkml.kernel.org/r/1446657706-14518-1-git-send-email-pfeiner@google.com
      Fixes: 6810fc91
      
       ("perf trace: Add option to analyze events in a file versus live")
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      956959f6
    • Yunlong Song's avatar
      tools lib bpf: Change FEATURE-DUMP to FEATURE-DUMP.libbpf · 0c77c04a
      Yunlong Song authored
      Commit ed63f34c
      
       ("perf tools: Make perf
      depend on libbpf") triggers the build of libbpf when building the perf
      tools, dynamically creating FEATURE-DUMP.libbpf.
      
      It failed to update the tools/lib/bpf/.gitignore file to have that
      prefix, fix it.
      
      Signed-off-by: default avatarYunlong Song <yunlong.song@huawei.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.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: Wang Nan <wangnan0@huawei.com>
      Fixes: 65f041be
      
       ("tools lib bpf: Use FEATURE_USER to allow building in the same dir as perf")
      Link: http://lkml.kernel.org/r/1446706594-4142-1-git-send-email-yunlong.song@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0c77c04a
    • Wang Nan's avatar
      perf llvm: Pass LINUX_VERSION_CODE to BPF program when compiling · 4a4f66a1
      Wang Nan authored
      
      
      Arnaldo suggests to make LINUX_VERSION_CODE works like __func__ and
      __FILE__ so user don't need to care setting right linux version too
      much. In this patch, perf llvm transfers LINUX_VERSION_CODE macro
      through clang cmdline.
      
      [1] http://lkml.kernel.org/r/20151029223744.GK2923@kernel.org
      
      Committer notes:
      
      Before, forgetting to update the version:
      
        # uname -r
        4.3.0-rc1+
        # cat bpf.c
        __attribute__((section("fork=_do_fork"), used))
        int fork(void *ctx)
        {
                return 1;
        }
      
        char _license[] __attribute__((section("license"), used)) = "GPL";
        int _version __attribute__((section("version"), used)) = 0x40200;
        #
        # perf record -e bpf.c sleep 1
        event syntax error: 'bpf.c'
                             \___ Invalid argument: Are you root and runing a CONFIG_BPF_SYSCALL kernel?
      
        (add -v to see detail)
        Run 'perf list' for a list of valid events
      
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
       #
      
      After:
      
        # grep version bpf.c
        int _version __attribute__((section("version"), used)) = LINUX_VERSION_CODE;
        # perf record -e bpf.c sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.017 MB perf.data ]
        # perf evlist -v
        perf_bpf_probe:fork: type: 2, size: 112, config: 0x5ee, { sample_period,
        sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1,
        inherit: 1, mmap: 1, comm: 1, enable_on_exec: 1, task: 1, sample_id_all:
        1, exclude_guest: 1, mmap2: 1, comm_exec: 1
        #
      
      Suggested-and-Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446636007-239722-3-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4a4f66a1
    • Wang Nan's avatar
      perf llvm: Pass number of configured CPUs to clang compiler · 59f41af9
      Wang Nan authored
      
      
      This patch introduces a new macro "__NR_CPUS__" to perf's embedded clang
      compiler, which represent the number of configured CPUs in this system.
      BPF programs can use this macro to create a map with the same number of
      system CPUs. For example:
      
       struct bpf_map_def SEC("maps") pmu_map = {
           .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
           .key_size = sizeof(int),
           .value_size = sizeof(u32),
           .max_entries = __NR_CPUS__,
       };
      
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1446636007-239722-2-git-send-email-wangnan0@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      59f41af9