• Adrian Hunter's avatar
    perf intel-pt: Add support for synthesizing callchains for regular events · 2855c05c
    Adrian Hunter authored
    Currently, callchains can be synthesized only for synthesized events.
    Support also synthesizing callchains for regular events.
    
    Example:
    
     # perf record --kcore --aux-sample -e '{intel_pt//,cycles}' -c 10000 uname
     Linux
     [ perf record: Woken up 3 times to write data ]
     [ perf record: Captured and wrote 0.532 MB perf.data ]
     # perf script --itrace=Ge | head -20
     uname  4864 2419025.358181:      10000     cycles:
            ffffffffbba56965 apparmor_bprm_committing_creds+0x35 ([kernel.kallsyms])
            ffffffffbc400cd5 __indirect_thunk_start+0x5 ([kernel.kallsyms])
            ffffffffbba07422 security_bprm_committing_creds+0x22 ([kernel.kallsyms])
            ffffffffbb89805d install_exec_creds+0xd ([kernel.kallsyms])
            ffffffffbb90d9ac load_elf_binary+0x3ac ([kernel.kallsyms])
    
     uname  4864 2419025.358185:      10000     cycles:
            ffffffffbba56db0 apparmor_bprm_committed_creds+0x20 ([kernel.kallsyms])
            ffffffffbc400cd5 __indirect_thunk_start+0x5 ([kernel.kallsyms])
            ffffffffbba07452 security_bprm_committed_creds+0x22 ([kernel.kallsyms])
            ffffffffbb89809a install_exec_creds+0x4a ([kernel.kallsyms])
            ffffffffbb90d9ac load_elf_binary+0x3ac ([kernel.kallsyms])
    
     uname  4864 2419025.358189:      10000     cycles:
            ffffffffbb86fdf6 vma_adjust_trans_huge+0x6 ([kernel.kallsyms])
            ffffffffbb821660 __vma_adjust+0x160 ([kernel.kallsyms])
            ffffffffbb897be7 shift_arg_pages+0x97 ([kernel.kallsyms])
            ffffffffbb897ed9 setup_arg_pages+0x1e9 ([kernel.kallsyms])
            ffffffffbb90d9f2 load_elf_binary+0x3f2 ([kernel.kallsyms])
    
    Committer testing:
    
      # perf record --kcore --aux-sample -e '{intel_pt//,cycles}' -c 10000 uname
      Linux
      [ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.233 MB perf.data ]
      #
    
    Then, before this patch:
    
      # perf script --itrace=Ge | head -20
         uname 28642 168664.856384: 10000 cycles: ffffffff9810aeaa commit_creds+0x2a ([kernel.kallsyms])
         uname 28642 168664.856388: 10000 cycles: ffffffff982a24f1 mprotect_fixup+0x151 ([kernel.kallsyms])
         uname 28642 168664.856392: 10000 cycles: ffffffff982a385b move_page_tables+0xbcb ([kernel.kallsyms])
         uname 28642 168664.856396: 10000 cycles: ffffffff982fd4ec __mod_memcg_state+0x1c ([kernel.kallsyms])
         uname 28642 168664.856400: 10000 cycles: ffffffff9829fddd do_mmap+0xfd ([kernel.kallsyms])
         uname 28642 168664.856404: 10000 cycles: ffffffff9829c879 __vma_adjust+0x479 ([kernel.kallsyms])
         uname 28642 168664.856408: 10000 cycles: ffffffff98238e94 __perf_addr_filters_adjust+0x34 ([kernel.kallsyms])
         uname 28642 168664.856412: 10000 cycles: ffffffff98a38e0b down_write+0x1b ([kernel.kallsyms])
         uname 28642 168664.856416: 10000 cycles: ffffffff983006a0 memcg_kmem_get_cache+0x0 ([kernel.kallsyms])
         uname 28642 168664.856421: 10000 cycles: ffffffff98396eaf load_elf_binary+0x92f ([kernel.kallsyms])
         uname 28642 168664.856425: 10000 cycles: ffffffff982e0222 kfree+0x62 ([kernel.kallsyms])
         uname 28642 168664.856428: 10000 cycles: ffffffff9846dfd4 file_has_perm+0x54 ([kernel.kallsyms])
         uname 28642 168664.856433: 10000 cycles: ffffffff98288911 vma_interval_tree_insert+0x51 ([kernel.kallsyms])
         uname 28642 168664.856437: 10000 cycles: ffffffff9823e577 perf_event_mmap_output+0x27 ([kernel.kallsyms])
         uname 28642 168664.856441: 10000 cycles: ffffffff98a26fa0 xas_load+0x40 ([kernel.kallsyms])
         uname 28642 168664.856445: 10000 cycles: ffffffff98004f30 arch_setup_additional_pages+0x0 ([kernel.kallsyms])
         uname 28642 168664.856448: 10000 cycles: ffffffff98a297c0 copy_user_generic_unrolled+0xa0 ([kernel.kallsyms])
         uname 28642 168664.856452: 10000 cycles: ffffffff9853a87a strnlen_user+0x10a ([kernel.kallsyms])
         uname 28642 168664.856456: 10000 cycles: ffffffff986638a7 randomize_page+0x27 ([kernel.kallsyms])
         uname 28642 168664.856460: 10000 cycles: ffffffff98a3b645 _raw_spin_lock+0x5 ([kernel.kallsyms])
    
      #
    
    And after:
    
      # perf script --itrace=Ge | head -20
      uname 28642 168664.856384:      10000     cycles:
      	ffffffff9810aeaa commit_creds+0x2a ([kernel.kallsyms])
      	ffffffff9831fe87 install_exec_creds+0x17 ([kernel.kallsyms])
      	ffffffff983968d9 load_elf_binary+0x359 ([kernel.kallsyms])
      	ffffffff98e00c45 __x86_indirect_thunk_rax+0x5 ([kernel.kallsyms])
      	ffffffff98e00c45 __x86_indirect_thunk_rax+0x5 ([kernel.kallsyms])
    
      uname 28642 168664.856388:      10000     cycles:
      	ffffffff982a24f1 mprotect_fixup+0x151 ([kernel.kallsyms])
      	ffffffff9831fa83 setup_arg_pages+0x123 ([kernel.kallsyms])
      	ffffffff9839691f load_elf_binary+0x39f ([kernel.kallsyms])
      	ffffffff98e00c45 __x86_indirect_thunk_rax+0x5 ([kernel.kallsyms])
      	ffffffff98e00c45 __x86_indirect_thunk_rax+0x5 ([kernel.kallsyms])
    
      uname 28642 168664.856392:      10000     cycles:
      	ffffffff982a385b move_page_tables+0xbcb ([kernel.kallsyms])
      	ffffffff9831f889 shift_arg_pages+0xa9 ([kernel.kallsyms])
      	ffffffff9831fb4f setup_arg_pages+0x1ef ([kernel.kallsyms])
      	ffffffff9839691f load_elf_binary+0x39f ([kernel.kallsyms])
      	ffffffff98e00c45 __x86_indirect_thunk_rax+0x5 ([kernel.kallsyms])
      #
    Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Link: http://lore.kernel.org/lkml/20200401101613.6201-12-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    2855c05c
intel-pt.c 84.6 KB