1. 18 4月, 2020 1 次提交
  2. 16 4月, 2020 2 次提交
    • J
      perf annotate: Add basic support for bpf_image · 3c29d448
      Jiri Olsa 提交于
      Add the DSO_BINARY_TYPE__BPF_IMAGE dso binary type to recognize BPF
      images that carry trampoline or dispatcher.
      
      Upcoming patches will add support to read the image data, store it
      within the BPF feature in perf.data and display it for annotation
      purposes.
      
      Currently we only display following message:
      
        # ./perf annotate bpf_trampoline_24456 --stdio
         Percent |      Source code & Disassembly of . for cycles (504  ...
        --------------------------------------------------------------- ...
                 :       to be implemented
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Björn Töpel <bjorn.topel@intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David S. Miller <davem@redhat.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Jesper Dangaard Brouer <hawk@kernel.org>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20200312195610.346362-16-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3c29d448
    • J
      perf machine: Set ksymbol dso as loaded on arrival · 7eddf7e7
      Jiri Olsa 提交于
      There's no special load action for ksymbol data on map__load/dso__load
      action, where the kernel is getting loaded. It only gets confused with
      kernel kallsyms/vmlinux load for bpf object, which fails and could mess
      up with the map.
      
      Disabling any further load of the map for ksymbol related dso/map.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Björn Töpel <bjorn.topel@intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David S. Miller <davem@redhat.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Jesper Dangaard Brouer <hawk@kernel.org>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20200312195610.346362-15-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7eddf7e7
  3. 03 4月, 2020 2 次提交
  4. 10 3月, 2020 1 次提交
    • K
      perf tools: Add hw_idx in struct branch_stack · 42bbabed
      Kan Liang 提交于
      The low level index of raw branch records for the most recent branch can
      be recorded in a sample with PERF_SAMPLE_BRANCH_HW_INDEX
      branch_sample_type. Extend struct branch_stack to support it.
      
      However, if the PERF_SAMPLE_BRANCH_HW_INDEX is not applied, only nr and
      entries[] will be output by kernel. The pointer of entries[] could be
      wrong, since the output format is different with new struct
      branch_stack.  Add a variable no_hw_idx in struct perf_sample to
      indicate whether the hw_idx is output.  Add get_branch_entry() to return
      corresponding pointer of entries[0].
      
      To make dummy branch sample consistent as new branch sample, add hw_idx
      in struct dummy_branch_stack for cs-etm and intel-pt.
      
      Apply the new struct branch_stack for synthetic events as well.
      
      Extend test case sample-parsing to support new struct branch_stack.
      
      Committer notes:
      
      Renamed get_branch_entries() to perf_sample__branch_entries() to have
      proper namespacing and pave the way for this to be moved to libperf,
      eventually.
      
      Add 'static' to that inline as it is in a header.
      
      Add 'hw_idx' to 'struct dummy_branch_stack' in cs-etm.c to fix the build
      on arm64.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pavel Gerasimov <pavel.gerasimov@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vitaly Slobodskoy <vitaly.slobodskoy@intel.com>
      Link: http://lore.kernel.org/lkml/20200228163011.19358-2-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      42bbabed
  5. 12 2月, 2020 3 次提交
  6. 30 11月, 2019 1 次提交
  7. 26 11月, 2019 5 次提交
  8. 20 11月, 2019 2 次提交
    • A
      perf dso: Move dso_id from 'struct map' to 'struct dso' · 0e3149f8
      Arnaldo Carvalho de Melo 提交于
      And take it into account when looking up DSOs when we have the dso_id
      fields obtained from somewhere, like from PERF_RECORD_MMAP2 records.
      
      Instances of struct map pointing to the same DSO pathname but with
      anything in dso_id different are in fact different DSOs, so better have
      different 'struct dso' instances to reflect that. At some point we may
      want to get copies of the contents of the different objects if we want
      to do correct annotation or other analysis.
      
      With this we get 'struct map' 24 bytes leaner:
      
        $ pahole -C map ~/bin/perf
        struct map {
        	union {
        		struct rb_node     rb_node __attribute__((__aligned__(8))); /*     0    24 */
        		struct list_head   node;                 /*     0    16 */
        	} __attribute__((__aligned__(8)));               /*     0    24 */
        	u64                        start;                /*    24     8 */
        	u64                        end;                  /*    32     8 */
        	_Bool                      erange_warned:1;      /*    40: 0  1 */
        	_Bool                      priv:1;               /*    40: 1  1 */
      
        	/* XXX 6 bits hole, try to pack */
        	/* XXX 3 bytes hole, try to pack */
      
        	u32                        prot;                 /*    44     4 */
        	u64                        pgoff;                /*    48     8 */
        	u64                        reloc;                /*    56     8 */
        	/* --- cacheline 1 boundary (64 bytes) --- */
        	u64                        (*map_ip)(struct map *, u64); /*    64     8 */
        	u64                        (*unmap_ip)(struct map *, u64); /*    72     8 */
        	struct dso *               dso;                  /*    80     8 */
        	refcount_t                 refcnt;               /*    88     4 */
        	u32                        flags;                /*    92     4 */
      
        	/* size: 96, cachelines: 2, members: 13 */
        	/* sum members: 92, holes: 1, sum holes: 3 */
        	/* sum bitfield members: 2 bits, bit holes: 1, sum bit holes: 6 bits */
        	/* forced alignments: 1 */
        	/* last cacheline: 32 bytes */
        } __attribute__((__aligned__(8)));
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-g4hxxmraplo7wfjmk384mfsb@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0e3149f8
    • A
      perf map: Pass a dso_id to map__new() · 4a7380a5
      Arnaldo Carvalho de Melo 提交于
      Instead of the 4 fields, a step in the direction of moving this to
      struct dso.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-gp5s1xgxacurmih5d1l94ymy@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4a7380a5
  9. 19 11月, 2019 2 次提交
  10. 18 11月, 2019 1 次提交
    • A
      perf map: No need to adjust the long name of modules · f068435d
      Arnaldo Carvalho de Melo 提交于
      At some point in the past we needed to make sure we would get the long
      name of modules and not just what we get from /proc/modules, but that
      need, as described in the cset that introduced the adjustment function:
      
      Fixes: c03d5184 ("perf machine: Adjust dso->long_name for offline module")
      
      Without using the buildid-cache:
      
        # lsmod | grep trusted
        # insmod trusted.ko
        # lsmod | grep trusted
        trusted                24576  0
        # strace -e open,openat perf probe -m ./trusted.ko key_seal |& grep trusted
        openat(AT_FDCWD, "/sys/module/trusted/notes/.note.gnu.build-id", O_RDONLY) = 4
        openat(AT_FDCWD, "/sys/module/trusted/notes/.note.gnu.build-id", O_RDONLY) = 7
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/.debug/root/trusted.ko/dd3d355d567394d540f527e093e0f64b95879584/probes", O_RDWR|O_CREAT, 0644) = 3
        openat(AT_FDCWD, "/usr/lib/debug/root/trusted.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/usr/lib/debug/root/trusted.ko", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/.debug/trusted.ko", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "trusted.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, ".debug/trusted.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "trusted.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 4
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
          probe:key_seal       (on key_seal in trusted)
        # perf probe -l
          probe:key_seal       (on key_seal in trusted)
        #
      
      No attempt at opening '[trusted]'.
      
      Now using the build-id cache:
      
        # rmmod trusted
        # perf buildid-cache --add ./trusted.ko
        # insmod trusted.ko
        # strace -e open,openat perf probe -m ./trusted.ko key_seal |& grep trusted
        openat(AT_FDCWD, "/sys/module/trusted/notes/.note.gnu.build-id", O_RDONLY) = 4
        openat(AT_FDCWD, "/sys/module/trusted/notes/.note.gnu.build-id", O_RDONLY) = 7
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/.debug/root/trusted.ko/dd3d355d567394d540f527e093e0f64b95879584/probes", O_RDWR|O_CREAT, 0644) = 3
        openat(AT_FDCWD, "/usr/lib/debug/root/trusted.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/usr/lib/debug/root/trusted.ko", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/.debug/trusted.ko", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "trusted.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, ".debug/trusted.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "trusted.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 4
        openat(AT_FDCWD, "/root/trusted.ko", O_RDONLY) = 3
        #
      
      Again, no attempt at reading '[trusted]'.
      
      Finally, adding a probe to that function and then using:
      
      [root@quaco ~]# perf trace -e probe_perf:*/max-stack=16/ --max-events=2
           0.000 perf/13456 probe_perf:dso__adjust_kmod_long_name(__probe_ip: 5492263)
                                             dso__adjust_kmod_long_name (/home/acme/bin/perf)
                                             machine__process_kernel_mmap_event (/home/acme/bin/perf)
                                             machine__process_mmap_event (/home/acme/bin/perf)
                                             perf_event__process_mmap (/home/acme/bin/perf)
                                             machines__deliver_event (/home/acme/bin/perf)
                                             perf_session__deliver_event (/home/acme/bin/perf)
                                             perf_session__process_event (/home/acme/bin/perf)
                                             process_simple (/home/acme/bin/perf)
                                             reader__process_events (/home/acme/bin/perf)
                                             __perf_session__process_events (/home/acme/bin/perf)
                                             perf_session__process_events (/home/acme/bin/perf)
                                             process_buildids (/home/acme/bin/perf)
                                             record__finish_output (/home/acme/bin/perf)
                                             __cmd_record (/home/acme/bin/perf)
                                             cmd_record (/home/acme/bin/perf)
                                             run_builtin (/home/acme/bin/perf)
           0.055 perf/13456 probe_perf:dso__adjust_kmod_long_name(__probe_ip: 5492263)
                                             dso__adjust_kmod_long_name (/home/acme/bin/perf)
                                             machine__process_kernel_mmap_event (/home/acme/bin/perf)
                                             machine__process_mmap_event (/home/acme/bin/perf)
                                             perf_event__process_mmap (/home/acme/bin/perf)
                                             machines__deliver_event (/home/acme/bin/perf)
                                             perf_session__deliver_event (/home/acme/bin/perf)
                                             perf_session__process_event (/home/acme/bin/perf)
                                             process_simple (/home/acme/bin/perf)
                                             reader__process_events (/home/acme/bin/perf)
                                             __perf_session__process_events (/home/acme/bin/perf)
                                             perf_session__process_events (/home/acme/bin/perf)
                                             process_buildids (/home/acme/bin/perf)
                                             record__finish_output (/home/acme/bin/perf)
                                             __cmd_record (/home/acme/bin/perf)
                                             cmd_record (/home/acme/bin/perf)
                                             run_builtin (/home/acme/bin/perf)
        #
      
      This was the only path I could find using the perf tools that reach at this
      function, then as of november/2019, if we put a probe in the line where the
      actuall setting of the dso->long_name is done:
      
        # perf trace -e probe_perf:*
        ^C[root@quaco ~]
        # perf stat -e probe_perf:*  -I 2000
             2.000404265                  0      probe_perf:dso__adjust_kmod_long_name
             4.001142200                  0      probe_perf:dso__adjust_kmod_long_name
             6.001704120                  0      probe_perf:dso__adjust_kmod_long_name
             8.002398316                  0      probe_perf:dso__adjust_kmod_long_name
            10.002984010                  0      probe_perf:dso__adjust_kmod_long_name
            12.003597851                  0      probe_perf:dso__adjust_kmod_long_name
            14.004113303                  0      probe_perf:dso__adjust_kmod_long_name
            16.004582773                  0      probe_perf:dso__adjust_kmod_long_name
            18.005176373                  0      probe_perf:dso__adjust_kmod_long_name
            20.005801605                  0      probe_perf:dso__adjust_kmod_long_name
            22.006467540                  0      probe_perf:dso__adjust_kmod_long_name
        ^C    23.683261941                  0      probe_perf:dso__adjust_kmod_long_name
      
        #
      
      Its not being used at all.
      
      To further test this I used kvm.ko as the offline module, i.e. removed
      if from the buildid-cache by nuking it completely (rm -rf ~/.debug) and
      moved it from the normal kernel distro path, removed the modules, stoped
      the kvm guest, and then installed it manually, etc.
      
        # rmmod kvm-intel
        # rmmod kvm
        # lsmod | grep kvm
        # modprobe kvm-intel
        modprobe: ERROR: ctx=0x55d3b1722260 path=/lib/modules/5.3.8-200.fc30.x86_64/kernel/arch/x86/kvm/kvm.ko.xz error=No such file or directory
        modprobe: ERROR: ctx=0x55d3b1722260 path=/lib/modules/5.3.8-200.fc30.x86_64/kernel/arch/x86/kvm/kvm.ko.xz error=No such file or directory
        modprobe: ERROR: could not insert 'kvm_intel': Unknown symbol in module, or unknown parameter (see dmesg)
        # insmod ./kvm.ko
        # modprobe kvm-intel
        modprobe: ERROR: ctx=0x562f34026260 path=/lib/modules/5.3.8-200.fc30.x86_64/kernel/arch/x86/kvm/kvm.ko.xz error=No such file or directory
        modprobe: ERROR: ctx=0x562f34026260 path=/lib/modules/5.3.8-200.fc30.x86_64/kernel/arch/x86/kvm/kvm.ko.xz error=No such file or directory
        # lsmod | grep kvm
        kvm_intel             299008  0
        kvm                   765952  1 kvm_intel
        irqbypass              16384  1 kvm
        #
        # perf probe -x ~/bin/perf machine__findnew_module_map:12 mname=m.name:string filename=filename:string 'dso_long_name=map->dso->long_name:string' 'dso_name=map->dso->name:string'
        # perf probe -l
          probe_perf:machine__findnew_module_map (on machine__findnew_module_map:12@util/machine.c in /home/acme/bin/perf with mname filename dso_long_name dso_name)
        # perf record
        ^C[ perf record: Woken up 2 times to write data ]
        [ perf record: Captured and wrote 3.416 MB perf.data (33956 samples) ]
        # perf trace -e probe_perf:machine*
        <SNIP>
             6.322 perf/23099 probe_perf:machine__findnew_module_map(__probe_ip: 5492493, mname: "[salsa20_generic]", filename: "/lib/modules/5.3.8-200.fc30.x86_64/kernel/crypto/salsa20_generic.ko.xz", dso_long_name: "/lib/modules/5.3.8-200.fc30.x86_64/kernel/crypto/salsa20_generic.ko.xz", dso_name: "[salsa20_generic]")
             6.375 perf/23099 probe_perf:machine__findnew_module_map(__probe_ip: 5492493, mname: "[kvm]", filename: "[kvm]", dso_long_name: "[kvm]", dso_name: "[kvm]")
        <SNIP>
      
      The filename doesn't come with the path, no point in trying to set the dso->long_name.
      
        [root@quaco ~]# strace -e open,openat perf probe -m ./kvm.ko kvm_apic_local_deliver |& egrep 'open.*kvm'
        openat(AT_FDCWD, "/sys/module/kvm_intel/notes/.note.gnu.build-id", O_RDONLY) = 4
        openat(AT_FDCWD, "/sys/module/kvm/notes/.note.gnu.build-id", O_RDONLY) = 4
        openat(AT_FDCWD, "/lib/modules/5.3.8-200.fc30.x86_64/kernel/arch/x86/kvm", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 7
        openat(AT_FDCWD, "/sys/module/kvm_intel/notes/.note.gnu.build-id", O_RDONLY) = 8
        openat(AT_FDCWD, "/root/kvm.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/.debug/root/kvm.ko/5955f426cb93f03f30f3e876814be2db80ab0b55/probes", O_RDWR|O_CREAT, 0644) = 3
        openat(AT_FDCWD, "/usr/lib/debug/root/kvm.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/usr/lib/debug/root/kvm.ko", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/.debug/kvm.ko", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/kvm.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "kvm.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, ".debug/kvm.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "kvm.ko.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
        openat(AT_FDCWD, "/root/kvm.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/kvm.ko", O_RDONLY) = 3
        openat(AT_FDCWD, "/root/kvm.ko", O_RDONLY) = 4
        openat(AT_FDCWD, "/root/kvm.ko", O_RDONLY) = 3
        [root@quaco ~]#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-jlfew3lyb24d58egrp0o72o2@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f068435d
  11. 12 11月, 2019 4 次提交
  12. 07 11月, 2019 2 次提交
  13. 25 9月, 2019 1 次提交
  14. 20 9月, 2019 2 次提交
  15. 01 9月, 2019 4 次提交
  16. 30 8月, 2019 1 次提交
  17. 27 8月, 2019 4 次提交
  18. 26 8月, 2019 2 次提交