1. 10 7月, 2020 1 次提交
  2. 28 5月, 2020 1 次提交
  3. 06 5月, 2020 2 次提交
  4. 18 4月, 2020 7 次提交
    • K
      perf callchain: Stitch LBR call stack · ff165628
      Kan Liang 提交于
      In LBR call stack mode, the depth of reconstructed LBR call stack limits
      to the number of LBR registers.
      
        For example, on skylake, the depth of reconstructed LBR call stack is
        always <= 32.
      
        # To display the perf.data header info, please use
        # --header/--header-only options.
        #
        #
        # Total Lost Samples: 0
        #
        # Samples: 6K of event 'cycles'
        # Event count (approx.): 6487119731
        #
        # Children      Self  Command          Shared Object       Symbol
        # ........  ........  ...............  ..................
        # ................................
      
          99.97%    99.97%  tchain_edit      tchain_edit        [.] f43
                  |
                   --99.64%--f11
                             f12
                             f13
                             f14
                             f15
                             f16
                             f17
                             f18
                             f19
                             f20
                             f21
                             f22
                             f23
                             f24
                             f25
                             f26
                             f27
                             f28
                             f29
                             f30
                             f31
                             f32
                             f33
                             f34
                             f35
                             f36
                             f37
                             f38
                             f39
                             f40
                             f41
                             f42
                             f43
      
      For a call stack which is deeper than LBR limit, HW will overwrite the
      LBR register with oldest branch. Only partial call stacks can be
      reconstructed.
      
      However, the overwritten LBRs may still be retrieved from previous
      sample. At that moment, HW hasn't overwritten the LBR registers yet.
      Perf tools can stitch those overwritten LBRs on current call stacks to
      get a more complete call stack.
      
      To determine if LBRs can be stitched, perf tools need to compare current
      sample with previous sample.
      
      - They should have identical LBR records (Same from, to and flags
        values, and the same physical index of LBR registers).
      
      - The searching starts from the base-of-stack of current sample.
      
      Once perf determines to stitch the previous LBRs, the corresponding LBR
      cursor nodes will be copied to 'lists'.  The 'lists' is to track the LBR
      cursor nodes which are going to be stitched.
      
      When the stitching is over, the nodes will not be freed immediately.
      They will be moved to 'free_lists'. Next stitching may reuse the space.
      Both 'lists' and 'free_lists' will be freed when all samples are
      processed.
      
      Committer notes:
      
      Fix the intel-pt.c initialization of the union with 'struct
      branch_flags', that breaks the build with its unnamed union on older gcc
      versions.
      
      Uninline thread__free_stitch_list(), as it grew big and started dragging
      includes to thread.h, so move it to thread.c where what it needs in
      terms of headers are already there.
      
      This fixes the build in several systems such as debian:experimental when
      cross building to the MIPS32 architecture, i.e. in the other cases what
      was needed was being included by sheer luck.
      
        In file included from builtin-sched.c:11:
        util/thread.h: In function 'thread__free_stitch_list':
        util/thread.h:169:3: error: implicit declaration of function 'free' [-Werror=implicit-function-declaration]
          169 |   free(pos);
              |   ^~~~
        util/thread.h:169:3: error: incompatible implicit declaration of built-in function 'free' [-Werror]
        util/thread.h:19:1: note: include '<stdlib.h>' or provide a declaration of 'free'
           18 | #include "callchain.h"
          +++ |+#include <stdlib.h>
           19 |
        util/thread.h:174:3: error: incompatible implicit declaration of built-in function 'free' [-Werror]
          174 |   free(pos);
              |   ^~~~
        util/thread.h:174:3: note: include '<stdlib.h>' or provide a declaration of 'free'
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.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/20200319202517.23423-13-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ff165628
    • K
      perf callchain: Save previous cursor nodes for LBR stitching approach · 7f1d3931
      Kan Liang 提交于
      The cursor nodes which generates from sample are eventually added into
      callchain. To avoid generating cursor nodes from previous samples again,
      the previous cursor nodes are also saved for LBR stitching approach.
      
      Some option, e.g. hide-unresolved, may hide some LBRs.  Add a variable
      'valid' in struct callchain_cursor_node to indicate this case. The LBR
      stitching approach will only append the valid cursor nodes from previous
      samples later.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.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/20200319202517.23423-12-kan.liang@linux.intel.com
      [ Use zfree() instead of open coded equivalent, and use it when freeing members of structs ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7f1d3931
    • K
      perf thread: Save previous sample for LBR stitching approach · 9c6c3f47
      Kan Liang 提交于
      To retrieve the overwritten LBRs from previous sample for LBR stitching
      approach, perf has to save the previous sample.
      
      Only allocate the struct lbr_stitch once, when LBR stitching approach is
      enabled and kernel supports hw_idx.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.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/20200319202517.23423-11-kan.liang@linux.intel.com
      [ Use zalloc()/zfree() for thread->lbr_stitch ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9c6c3f47
    • K
      perf machine: Factor out lbr_callchain_add_lbr_ip() · e2b23483
      Kan Liang 提交于
      Both caller and callee needs to add ip from LBR to callchain.
      Factor out lbr_callchain_add_lbr_ip() to improve code readability.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.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/20200319202517.23423-9-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e2b23483
    • K
      perf machine: Factor out lbr_callchain_add_kernel_ip() · dd3e249a
      Kan Liang 提交于
      Both caller and callee needs to add kernel ip to callchain.  Factor out
      lbr_callchain_add_kernel_ip() to improve code readability.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.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/20200319202517.23423-8-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dd3e249a
    • K
      perf machine: Refine the function for LBR call stack reconstruction · e48b8311
      Kan Liang 提交于
      LBR only collect the user call stack. To reconstruct a call stack, both
      kernel call stack and user call stack are required. The function
      resolve_lbr_callchain_sample() mix the kernel call stack and user call
      stack.
      
      Now, with the help of HW idx, perf tool can reconstruct a more complete
      call stack by adding some user call stack from previous sample. However,
      current implementation is hard to be extended to support it.
      
      Current code path for resolve_lbr_callchain_sample()
      
        for (j = 0; j < mix_chain_nr; j++) {
             if (ORDER_CALLEE) {
                   if (kernel callchain)
                        Fill callchain info
                   else if (LBR callchain)
                        Fill callchain info
             } else {
                   if (LBR callchain)
                        Fill callchain info
                   else if (kernel callchain)
                        Fill callchain info
             }
             add_callchain_ip();
        }
      
      With the patch,
      
        if (ORDER_CALLEE) {
             for (j = 0; j < NUM of kernel callchain) {
                   Fill callchain info
                   add_callchain_ip();
             }
             for (; j < mix_chain_nr) {
                   Fill callchain info
                   add_callchain_ip();
             }
        } else {
             for (; j < NUM of LBR callchain) {
                   Fill callchain info
                   add_callchain_ip();
             }
             for (j = 0; j < mix_chain_nr) {
                   Fill callchain info
                   add_callchain_ip();
             }
        }
      
      No functional changes.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.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/20200319202517.23423-7-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e48b8311
    • K
      perf machine: Remove the indent in resolve_lbr_callchain_sample · f8603267
      Kan Liang 提交于
      The indent is unnecessary in resolve_lbr_callchain_sample.  Removing it
      will make the following patch simpler.
      
      Current code path for resolve_lbr_callchain_sample()
      
              /* LBR only affects the user callchain */
              if (i != chain_nr) {
                      body of the function
                      ....
                      return 1;
              }
      
              return 0;
      
      With the patch,
      
              /* LBR only affects the user callchain */
              if (i == chain_nr)
                      return 0;
      
              body of the function
              ...
              return 1;
      
      No functional changes.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.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/20200319202517.23423-6-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f8603267
  5. 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
  6. 03 4月, 2020 2 次提交
  7. 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
  8. 12 2月, 2020 3 次提交
  9. 30 11月, 2019 1 次提交
  10. 26 11月, 2019 5 次提交
  11. 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
  12. 19 11月, 2019 2 次提交
  13. 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
  14. 12 11月, 2019 4 次提交
  15. 07 11月, 2019 2 次提交
  16. 25 9月, 2019 1 次提交
  17. 20 9月, 2019 2 次提交
  18. 01 9月, 2019 1 次提交