1. 20 11月, 2019 1 次提交
  2. 19 11月, 2019 1 次提交
    • A
      perf map_groups: Auto sort maps by name, if needed · a7c2b572
      Arnaldo Carvalho de Melo 提交于
      There are still lots of lookups by name, even if just when loading
      vmlinux, till that code is studied to figure out if its possible to do
      away with those map lookup by names, provide a way to sort it using
      libc's qsort/bsearch.
      
      Doing it at the first lookup defers the sorting a bit, and as the code
      stands now, is never done for user maps, just for the kernel ones.
      
        # perf probe -l
        # perf probe -x ~/bin/perf -L __map_groups__find_by_name
        <__map_groups__find_by_name@/home/acme/git/perf/tools/perf/util/symbol.c:0>
              0  static struct map *__map_groups__find_by_name(struct map_groups *mg, const char *name)
              1  {
                        struct map **mapp;
      
              4         if (mg->maps_by_name == NULL &&
              5             map__groups__sort_by_name_from_rbtree(mg))
              6                 return NULL;
      
              8         mapp = bsearch(name, mg->maps_by_name, mg->nr_maps, sizeof(*mapp), map__strcmp_name);
              9         if (mapp)
             10                 return *mapp;
             11         return NULL;
             12  }
      
                 struct map *map_groups__find_by_name(struct map_groups *mg, const char *name)
                 {
      
        # perf probe -x ~/bin/perf 'found=__map_groups__find_by_name:10 name:string'
        Added new event:
          probe_perf:found     (on __map_groups__find_by_name:10 in /home/acme/bin/perf with name:string)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe_perf:found -aR sleep 1
      
        #
        # perf probe -x ~/bin/perf -L map_groups__find_by_name
        <map_groups__find_by_name@/home/acme/git/perf/tools/perf/util/symbol.c:0>
              0  struct map *map_groups__find_by_name(struct map_groups *mg, const char *name)
              1  {
              2         struct maps *maps = &mg->maps;
                        struct map *map;
      
              5         down_read(&maps->lock);
      
              7         if (mg->last_search_by_name && strcmp(mg->last_search_by_name->dso->short_name, name) == 0) {
              8                 map = mg->last_search_by_name;
              9                 goto out_unlock;
                        }
                        /*
                         * If we have mg->maps_by_name, then the name isn't in the rbtree,
                         * as mg->maps_by_name mirrors the rbtree when lookups by name are
                         * made.
                         */
             16         map = __map_groups__find_by_name(mg, name);
             17         if (map || mg->maps_by_name != NULL)
             18                 goto out_unlock;
      
                        /* Fallback to traversing the rbtree... */
             21         maps__for_each_entry(maps, map)
             22                 if (strcmp(map->dso->short_name, name) == 0) {
             23                         mg->last_search_by_name = map;
             24                         goto out_unlock;
                                }
      
             27         map = NULL;
      
                 out_unlock:
             30         up_read(&maps->lock);
             31         return map;
             32  }
      
                 int dso__load_vmlinux(struct dso *dso, struct map *map,
                                      const char *vmlinux, bool vmlinux_allocated)
      
        # perf probe -x ~/bin/perf 'fallback=map_groups__find_by_name:21 name:string'
        Added new events:
          probe_perf:fallback  (on map_groups__find_by_name:21 in /home/acme/bin/perf with name:string)
          probe_perf:fallback_1 (on map_groups__find_by_name:21 in /home/acme/bin/perf with name:string)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe_perf:fallback_1 -aR sleep 1
      
        #
        # perf probe -l
          probe_perf:fallback  (on map_groups__find_by_name:21@util/symbol.c in /home/acme/bin/perf with name_string)
          probe_perf:fallback_1 (on map_groups__find_by_name:21@util/symbol.c in /home/acme/bin/perf with name_string)
          probe_perf:found     (on __map_groups__find_by_name:10@util/symbol.c in /home/acme/bin/perf with name_string)
        #
        # perf stat -e probe_perf:*
      
      Now run 'perf top' in another term and then, after a while, stop 'perf stat':
      
      Furthermore, if we ask for interval printing, we can see that that is done just
      at the start of the workload:
      
        # perf stat -I1000 -e probe_perf:*
        #           time             counts unit events
             1.000319513                  0      probe_perf:found
             1.000319513                  0      probe_perf:fallback_1
             1.000319513                  0      probe_perf:fallback
             2.001868092             23,251      probe_perf:found
             2.001868092                  0      probe_perf:fallback_1
             2.001868092                  0      probe_perf:fallback
             3.002901597                  0      probe_perf:found
             3.002901597                  0      probe_perf:fallback_1
             3.002901597                  0      probe_perf:fallback
             4.003358591                  0      probe_perf:found
             4.003358591                  0      probe_perf:fallback_1
             4.003358591                  0      probe_perf:fallback
        ^C
        #
      
      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-c5lmbyr14x448rcfii7y6t3k@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a7c2b572
  3. 18 11月, 2019 2 次提交
    • A
      perf map_groups: Add a front end cache for map lookups by name · 1ae14516
      Arnaldo Carvalho de Melo 提交于
      Lets see if it helps:
      
      First look at the probeable lines for the function that does lookups by
      name in a map_groups struct:
      
        # perf probe -x ~/bin/perf -L map_groups__find_by_name
        <map_groups__find_by_name@/home/acme/git/perf/tools/perf/util/symbol.c:0>
              0  struct map *map_groups__find_by_name(struct map_groups *mg, const char *name)
              1  {
              2         struct maps *maps = &mg->maps;
                        struct map *map;
      
              5         down_read(&maps->lock);
      
              7         if (mg->last_search_by_name && strcmp(mg->last_search_by_name->dso->short_name, name) == 0) {
              8                 map = mg->last_search_by_name;
              9                 goto out_unlock;
                        }
      
             12         maps__for_each_entry(maps, map)
             13                 if (strcmp(map->dso->short_name, name) == 0) {
             14                         mg->last_search_by_name = map;
             15                         goto out_unlock;
                                }
      
             18         map = NULL;
      
                 out_unlock:
             21         up_read(&maps->lock);
             22         return map;
             23  }
      
                 int dso__load_vmlinux(struct dso *dso, struct map *map,
                                      const char *vmlinux, bool vmlinux_allocated)
      
        #
      
      Now add a probe to the place where we reuse the last search:
      
        # perf probe -x ~/bin/perf map_groups__find_by_name:8
        Added new event:
          probe_perf:map_groups__find_by_name (on map_groups__find_by_name:8 in /home/acme/bin/perf)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe_perf:map_groups__find_by_name -aR sleep 1
      
        #
      
      Now lets do a system wide 'perf stat' counting those events:
      
        # perf stat -e probe_perf:*
      
      Leave it running and lets do a 'perf top', then, after a while, stop the
      'perf stat':
      
        # perf stat -e probe_perf:*
        ^C
         Performance counter stats for 'system wide':
      
                     3,603      probe_perf:map_groups__find_by_name
      
              44.565253139 seconds time elapsed
        #
      
      yeah, good to have.
      
      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-tcz37g3nxv3tvxw3q90vga3p@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1ae14516
    • A
      perf maps: Do not use an rbtree to sort by map name · c5c584d2
      Arnaldo Carvalho de Melo 提交于
      This is only used for the kernel maps, shave 24 bytes out 'struct map'
      and just traverse the existing per ip rbtree to look for maps by name,
      use a front end cache to reuse the last search if its the same name.
      
      After this 'struct map' is down to just two cachelines:
      
        $ 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;        /*    40     1 */
      
        	/* XXX 3 bytes hole, try to pack */
      
        	u32                        priv;                 /*    44     4 */
        	u32                        prot;                 /*    48     4 */
        	u32                        flags;                /*    52     4 */
        	u64                        pgoff;                /*    56     8 */
        	/* --- cacheline 1 boundary (64 bytes) --- */
        	u64                        reloc;                /*    64     8 */
        	u32                        maj;                  /*    72     4 */
        	u32                        min;                  /*    76     4 */
        	u64                        ino;                  /*    80     8 */
        	u64                        ino_generation;       /*    88     8 */
        	u64                        (*map_ip)(struct map *, u64); /*    96     8 */
        	u64                        (*unmap_ip)(struct map *, u64); /*   104     8 */
        	struct dso *               dso;                  /*   112     8 */
        	refcount_t                 refcnt;               /*   120     4 */
      
        	/* size: 128, cachelines: 2, members: 17 */
        	/* sum members: 121, holes: 1, sum holes: 3 */
        	/* padding: 4 */
        	/* forced alignments: 1 */
        } __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-bvr8fqfgzxtgnhnwt5sssx5g@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c5c584d2
  4. 14 11月, 2019 1 次提交
  5. 12 11月, 2019 5 次提交
  6. 07 11月, 2019 3 次提交
  7. 01 10月, 2019 1 次提交
    • S
      perf map: Fix overlapped map handling · ee212d6e
      Steve MacLean 提交于
      Whenever an mmap/mmap2 event occurs, the map tree must be updated to add a new
      entry. If a new map overlaps a previous map, the overlapped section of the
      previous map is effectively unmapped, but the non-overlapping sections are
      still valid.
      
      maps__fixup_overlappings() is responsible for creating any new map entries from
      the previously overlapped map. It optionally creates a before and an after map.
      
      When creating the after map the existing code failed to adjust the map.pgoff.
      This meant the new after map would incorrectly calculate the file offset
      for the ip. This results in incorrect symbol name resolution for any ip in the
      after region.
      
      Make maps__fixup_overlappings() correctly populate map.pgoff.
      
      Add an assert that new mapping matches old mapping at the beginning of
      the after map.
      
      Committer-testing:
      
      Validated correct parsing of libcoreclr.so symbols from .NET Core 3.0 preview9
      (which didn't strip symbols).
      
      Preparation:
      
        ~/dotnet3.0-preview9/dotnet new webapi -o perfSymbol
        cd perfSymbol
        ~/dotnet3.0-preview9/dotnet publish
        perf record ~/dotnet3.0-preview9/dotnet \
            bin/Debug/netcoreapp3.0/publish/perfSymbol.dll
        ^C
      
      Before:
      
        perf script --show-mmap-events 2>&1 | grep -e MMAP -e unknown |\
           grep libcoreclr.so | head -n 4
              dotnet  1907 373352.698780: PERF_RECORD_MMAP2 1907/1907: \
                  [0x7fe615726000(0x768000) @ 0 08:02 5510620 765057155]: \
                  r-xp .../3.0.0-preview9-19423-09/libcoreclr.so
              dotnet  1907 373352.701091: PERF_RECORD_MMAP2 1907/1907: \
                  [0x7fe615974000(0x1000) @ 0x24e000 08:02 5510620 765057155]: \
                  rwxp .../3.0.0-preview9-19423-09/libcoreclr.so
              dotnet  1907 373352.701241: PERF_RECORD_MMAP2 1907/1907: \
                  [0x7fe615c42000(0x1000) @ 0x51c000 08:02 5510620 765057155]: \
                  rwxp .../3.0.0-preview9-19423-09/libcoreclr.so
              dotnet  1907 373352.705249:     250000 cpu-clock: \
                   7fe6159a1f99 [unknown] \
                   (.../3.0.0-preview9-19423-09/libcoreclr.so)
      
      After:
      
        perf script --show-mmap-events 2>&1 | grep -e MMAP -e unknown |\
           grep libcoreclr.so | head -n 4
              dotnet  1907 373352.698780: PERF_RECORD_MMAP2 1907/1907: \
                  [0x7fe615726000(0x768000) @ 0 08:02 5510620 765057155]: \
                  r-xp .../3.0.0-preview9-19423-09/libcoreclr.so
              dotnet  1907 373352.701091: PERF_RECORD_MMAP2 1907/1907: \
                  [0x7fe615974000(0x1000) @ 0x24e000 08:02 5510620 765057155]: \
                  rwxp .../3.0.0-preview9-19423-09/libcoreclr.so
              dotnet  1907 373352.701241: PERF_RECORD_MMAP2 1907/1907: \
                  [0x7fe615c42000(0x1000) @ 0x51c000 08:02 5510620 765057155]: \
                  rwxp .../3.0.0-preview9-19423-09/libcoreclr.so
      
      All the [unknown] symbols were resolved.
      Signed-off-by: NSteve MacLean <Steve.MacLean@Microsoft.com>
      Tested-by: NBrian Robbins <brianrob@microsoft.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
      Cc: John Keeping <john@metanate.com>
      Cc: John Salem <josalem@microsoft.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tom McDonald <thomas.mcdonald@microsoft.com>
      Link: http://lore.kernel.org/lkml/BN8PR21MB136270949F22A6A02335C238F7800@BN8PR21MB1362.namprd21.prod.outlook.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ee212d6e
  8. 01 9月, 2019 3 次提交
  9. 16 8月, 2019 2 次提交
    • J
      perf unwind: Fix libunwind when tid != pid · e8ba2906
      John Keeping 提交于
      Commit e5adfc3e ("perf map: Synthesize maps only for thread group
      leader") changed the recording side so that we no longer get mmap events
      for threads other than the thread group leader (when synthesising these
      events for threads which exist before perf is started).
      
      When a file recorded after this change is loaded, the lack of mmap
      records mean that unwinding is not set up for any other threads.
      
      This can be seen in a simple record/report scenario:
      
      	perf record --call-graph=dwarf -t $TID
      	perf report
      
      If $TID is a process ID then the report will show call graphs, but if
      $TID is a secondary thread the output is as if --call-graph=none was
      specified.
      
      Following the rationale in that commit, move the libunwind fields into
      struct map_groups and update the libunwind functions to take this
      instead of the struct thread.  This is only required for
      unwind__finish_access which must now be called from map_groups__delete
      and the others are changed for symmetry.
      
      Note that unwind__get_entries keeps the thread argument since it is
      required for symbol lookup and the libdw unwind provider uses the thread
      ID.
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Fixes: e5adfc3e ("perf map: Synthesize maps only for thread group leader")
      Link: http://lkml.kernel.org/r/20190815100146.28842-2-john@metanate.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e8ba2906
    • J
      perf map: Use zalloc for map_groups · ab6cd0e5
      John Keeping 提交于
      In the next commit we will add new fields to map_groups and we need
      these to be null if no value is assigned.  The simplest way to achieve
      this is to request zeroed memory from the allocator.
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: john keeping <john@metanate.com>
      Link: http://lkml.kernel.org/r/20190815100146.28842-1-john@metanate.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ab6cd0e5
  10. 09 7月, 2019 2 次提交
    • A
      tools lib: Adopt zalloc()/zfree() from tools/perf · 7f7c536f
      Arnaldo Carvalho de Melo 提交于
      Eroding a bit more the tools/perf/util/util.h hodpodge header.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-natazosyn9rwjka25tvcnyi0@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7f7c536f
    • L
      perf map: Fix potential NULL pointer dereference found by smatch tool · 363bbaef
      Leo Yan 提交于
      Based on the following report from Smatch, fix the potential NULL
      pointer dereference check.
      
        tools/perf/util/map.c:479
        map__fprintf_srccode() error: we previously assumed 'state' could be
        null (see line 466)
      
        tools/perf/util/map.c
        465         /* Avoid redundant printing */
        466         if (state &&
        467             state->srcfile &&
        468             !strcmp(state->srcfile, srcfile) &&
        469             state->line == line) {
        470                 free(srcfile);
        471                 return 0;
        472         }
        473
        474         srccode = find_sourceline(srcfile, line, &len);
        475         if (!srccode)
        476                 goto out_free_line;
        477
        478         ret = fprintf(fp, "|%-8d %.*s", line, len, srccode);
        479         state->srcfile = srcfile;
                    ^^^^^^^
        480         state->line = line;
                    ^^^^^^^
      
      This patch validates 'state' pointer before access its elements.
      Signed-off-by: NLeo Yan <leo.yan@linaro.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Alexios Zavras <alexios.zavras@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Fixes: dd2e18e9 ("perf tools: Support 'srccode' output")
      Link: http://lkml.kernel.org/r/20190702103420.27540-8-leo.yan@linaro.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      363bbaef
  11. 29 5月, 2019 1 次提交
    • J
      perf script: Pad DSO name for --call-trace · 1c492422
      Jiri Olsa 提交于
      Pad the DSO name in --call-trace so we don't have the indent screwed by
      different DSO name lengths, as now for kernel there's also BPF code
      displayed.
      
        # perf-with-kcore record pt -e intel_pt//ku -- sleep 1
        # perf-core/perf-with-kcore script pt --call-trace
      
      Before:
      
         sleep 3660 [16] 57036.806464404: ([kernel.kallsyms])                      kretprobe_perf_func
         sleep 3660 [16] 57036.806464404: ([kernel.kallsyms])                          trace_call_bpf
         sleep 3660 [16] 57036.806464404: ([kernel.kallsyms])                              __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806464404: ([kernel.kallsyms])                                  __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return)                                         bpf_get_current_pid_tgid
         sleep 3660 [16] 57036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return)                                         bpf_ktime_get_ns
         sleep 3660 [16] 57036.806464725: ([kernel.kallsyms])                                          __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806464725: ([kernel.kallsyms])                                              __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806465045: (bpf_prog_da4fe6b3d2c29b25_trace_return)                                         __htab_map_lookup_elem
         sleep 3660 [16] 57036.806465366: ([kernel.kallsyms])                                          memcmp
         sleep 3660 [16] 57036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return)                                         bpf_probe_read
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms])                                          probe_kernel_read
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms])                                              __check_object_size
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms])                                                  check_stack_object
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms])                                              copy_user_enhanced_fast_string
         sleep 3660 [16] 57036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return)                                         bpf_probe_read
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms])                                          probe_kernel_read
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms])                                              __check_object_size
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms])                                                  check_stack_object
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms])                                              copy_user_enhanced_fast_string
         sleep 3660 [16] 57036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return)                                         bpf_get_current_uid_gid
         sleep 3660 [16] 57036.806466008: ([kernel.kallsyms])                                          from_kgid
         sleep 3660 [16] 57036.806466008: ([kernel.kallsyms])                                          from_kuid
         sleep 3660 [16] 57036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return)                                         bpf_perf_event_output
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms])                                          perf_event_output
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms])                                              perf_prepare_sample
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms])                                                  perf_misc_flags
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms])                                                      __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms])                                                          __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806466328: ([kvm])                                                      kvm_is_in_guest
         sleep 3660 [16] 57036.806466649: ([kernel.kallsyms])                                                  __perf_event_header__init_id.isra.0
         sleep 3660 [16] 57036.806466649: ([kernel.kallsyms])                                              perf_output_begin
      
      After:
      
         sleep 3660 [16] 57036.806464404: ([kernel.kallsyms]                      )     kretprobe_perf_func
         sleep 3660 [16] 57036.806464404: ([kernel.kallsyms]                      )         trace_call_bpf
         sleep 3660 [16] 57036.806464404: ([kernel.kallsyms]                      )             __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806464404: ([kernel.kallsyms]                      )                 __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return )                     bpf_get_current_pid_tgid
         sleep 3660 [16] 57036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return )                     bpf_ktime_get_ns
         sleep 3660 [16] 57036.806464725: ([kernel.kallsyms]                      )                         __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806464725: ([kernel.kallsyms]                      )                             __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806465045: (bpf_prog_da4fe6b3d2c29b25_trace_return )                     __htab_map_lookup_elem
         sleep 3660 [16] 57036.806465366: ([kernel.kallsyms]                      )                         memcmp
         sleep 3660 [16] 57036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return )                     bpf_probe_read
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]                      )                         probe_kernel_read
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]                      )                             __check_object_size
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]                      )                                 check_stack_object
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]                      )                             copy_user_enhanced_fast_string
         sleep 3660 [16] 57036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return )                     bpf_probe_read
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]                      )                         probe_kernel_read
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]                      )                             __check_object_size
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]                      )                                 check_stack_object
         sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]                      )                             copy_user_enhanced_fast_string
         sleep 3660 [16] 57036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return )                     bpf_get_current_uid_gid
         sleep 3660 [16] 57036.806466008: ([kernel.kallsyms]                      )                         from_kgid
         sleep 3660 [16] 57036.806466008: ([kernel.kallsyms]                      )                         from_kuid
         sleep 3660 [16] 57036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return )                     bpf_perf_event_output
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]                      )                         perf_event_output
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]                      )                             perf_prepare_sample
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]                      )                                 perf_misc_flags
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]                      )                                     __x86_indirect_thunk_rax
         sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]                      )                                         __x86_indirect_thunk_rax
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stanislav Fomichev <sdf@google.com>
      Link: http://lkml.kernel.org/r/20190508132010.14512-8-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1c492422
  12. 18 4月, 2019 2 次提交
    • J
      perf tools: Fix map reference counting · b9abbdfa
      Jiri Olsa 提交于
      By calling maps__insert() we assume to get 2 references on the map,
      which we relese within maps__remove call.
      
      However if there's already same map name, we currently don't bump the
      reference and can crash, like:
      
        Program received signal SIGABRT, Aborted.
        0x00007ffff75e60f5 in raise () from /lib64/libc.so.6
      
        (gdb) bt
        #0  0x00007ffff75e60f5 in raise () from /lib64/libc.so.6
        #1  0x00007ffff75d0895 in abort () from /lib64/libc.so.6
        #2  0x00007ffff75d0769 in __assert_fail_base.cold () from /lib64/libc.so.6
        #3  0x00007ffff75de596 in __assert_fail () from /lib64/libc.so.6
        #4  0x00000000004fc006 in refcount_sub_and_test (i=1, r=0x1224e88) at tools/include/linux/refcount.h:131
        #5  refcount_dec_and_test (r=0x1224e88) at tools/include/linux/refcount.h:148
        #6  map__put (map=0x1224df0) at util/map.c:299
        #7  0x00000000004fdb95 in __maps__remove (map=0x1224df0, maps=0xb17d80) at util/map.c:953
        #8  maps__remove (maps=0xb17d80, map=0x1224df0) at util/map.c:959
        #9  0x00000000004f7d8a in map_groups__remove (map=<optimized out>, mg=<optimized out>) at util/map_groups.h:65
        #10 machine__process_ksymbol_unregister (sample=<optimized out>, event=0x7ffff7279670, machine=<optimized out>) at util/machine.c:728
        #11 machine__process_ksymbol (machine=<optimized out>, event=0x7ffff7279670, sample=<optimized out>) at util/machine.c:741
        #12 0x00000000004fffbb in perf_session__deliver_event (session=0xb11390, event=0x7ffff7279670, tool=0x7fffffffc7b0, file_offset=13936) at util/session.c:1362
        #13 0x00000000005039bb in do_flush (show_progress=false, oe=0xb17e80) at util/ordered-events.c:243
        #14 __ordered_events__flush (oe=0xb17e80, how=OE_FLUSH__ROUND, timestamp=<optimized out>) at util/ordered-events.c:322
        #15 0x00000000005005e4 in perf_session__process_user_event (session=session@entry=0xb11390, event=event@entry=0x7ffff72a4af8,
        ...
      
      Add the map to the list and getting the reference event if we find the
      map with same name.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Fixes: 1e628569 ("perf symbols: Fix slowness due to -ffunction-section")
      Link: http://lkml.kernel.org/r/20190416160127.30203-10-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b9abbdfa
    • S
      perf tools: Check maps for bpf programs · a93e0b23
      Song Liu 提交于
      As reported by Jiri Olsa in:
      
        "[BUG] perf: intel_pt won't display kernel function"
        https://lore.kernel.org/lkml/20190403143738.GB32001@krava
      
      Recent changes to support PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT
      broke --kallsyms option. This is because it broke test __map__is_kmodule.
      
      This patch fixes this by adding check for bpf program, so that these maps
      are not mistaken as kernel modules.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reported-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Yonghong Song <yhs@fb.com>
      Link: http://lkml.kernel.org/r/20190416160127.30203-8-jolsa@kernel.org
      Fixes: 76193a94 ("perf, bpf: Introduce PERF_RECORD_KSYMBOL")
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a93e0b23
  13. 20 3月, 2019 2 次提交
  14. 06 2月, 2019 1 次提交
  15. 25 1月, 2019 1 次提交
  16. 18 12月, 2018 2 次提交
    • A
      perf tools: Support 'srccode' output · dd2e18e9
      Andi Kleen 提交于
      When looking at PT or brstackinsn traces with 'perf script' it can be
      very useful to see the source code. This adds a simple facility to print
      them with 'perf script', if the information is available through dwarf
      
        % perf record ...
        % perf script -F insn,ip,sym,srccode
        ...
      
                  4004c6 main
        5               for (i = 0; i < 10000000; i++)
                   4004cd main
        5               for (i = 0; i < 10000000; i++)
                   4004c6 main
        5               for (i = 0; i < 10000000; i++)
                   4004cd main
        5               for (i = 0; i < 10000000; i++)
                   4004cd main
        5               for (i = 0; i < 10000000; i++)
                   4004cd main
        5               for (i = 0; i < 10000000; i++)
                   4004cd main
        5               for (i = 0; i < 10000000; i++)
                   4004cd main
        5               for (i = 0; i < 10000000; i++)
                   4004b3 main
        6                       v++;
      
        % perf record -b ...
        % perf script -F insn,ip,sym,srccode,brstackinsn
      
        ...
               main+22:
                0000000000400543        insn: e8 ca ff ff ff            # PRED
        |18                     f1();
                f1:
                0000000000400512        insn: 55
        |10       {
                0000000000400513        insn: 48 89 e5
                0000000000400516        insn: b8 00 00 00 00
        |11             f2();
                000000000040051b        insn: e8 d6 ff ff ff            # PRED
                f2:
                00000000004004f6        insn: 55
        |5        {
                00000000004004f7        insn: 48 89 e5
                00000000004004fa        insn: 8b 05 2c 0b 20 00
        |6              c = a / b;
                0000000000400500        insn: 8b 0d 2a 0b 20 00
                0000000000400506        insn: 99
                0000000000400507        insn: f7 f9
                0000000000400509        insn: 89 05 29 0b 20 00
                000000000040050f        insn: 90
        |7        }
                0000000000400510        insn: 5d
                0000000000400511        insn: c3                        # PRED
                f1+14:
                0000000000400520        insn: b8 00 00 00 00
        |12             f2();
                0000000000400525        insn: e8 cc ff ff ff            # PRED
                f2:
                00000000004004f6        insn: 55
        |5        {
                00000000004004f7        insn: 48 89 e5
                00000000004004fa        insn: 8b 05 2c 0b 20 00
        |6              c = a / b;
      
      Not supported for callchains currently, would need some layout changes
      there.
      
      Committer notes:
      
      Fixed the build on Alpine Linux (3.4 .. 3.8) by addressing this
      warning:
      
        In file included from util/srccode.c:19:0:
        /usr/include/sys/fcntl.h:1:2: error: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Werror=cpp]
         #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
          ^~~~~~~
        cc1: all warnings being treated as errors
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Tested-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/20181204001848.24769-1-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dd2e18e9
    • E
      perf map: Remove extra indirection from map__find() · b18e0888
      Eric Saint-Etienne 提交于
      A double pointer is used in map__find() where a single pointer is enough
      because the function doesn't affect the rbtree and the rbtree is locked.
      Signed-off-by: NEric Saint-Etienne <eric.saint.etienne@oracle.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Eric Saint-Etienne <eric.saintetienne@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1542969759-24346-1-git-send-email-eric.saint.etienne@oracle.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b18e0888
  17. 22 11月, 2018 1 次提交
  18. 12 9月, 2018 1 次提交
  19. 05 9月, 2018 1 次提交
  20. 09 8月, 2018 1 次提交
  21. 06 6月, 2018 1 次提交
  22. 04 6月, 2018 1 次提交
  23. 22 5月, 2018 1 次提交
  24. 27 4月, 2018 3 次提交