1. 19 Apr, 2024 9 commits
  2. 17 Apr, 2024 4 commits
    • Chaitanya S Prakash's avatar
      perf tools: Enable configs required for test_uprobe_from_different_cu.sh · 6b718ac6
      Chaitanya S Prakash authored
      Test "perf probe of function from different CU" fails due to certain
      configs not being enabled. Building the kernel with
      CONFIG_KPROBE_EVENTS=y and CONFIG_UPROBE_EVENTS=y fixes the issue. As
      CONFIG_KPROBE_EVENTS is dependent on CONFIG_KPROBES, enable it as well.
      Some platforms enable these configs as a part of their defconfig, so
      this change is only required for the ones that don't do so.
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarChaitanya S Prakash <chaitanyas.prakash@arm.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Link: https://lore.kernel.org/r/20240408062230.1949882-1-ChaitanyaS.Prakash@arm.com
      Link: https://lore.kernel.org/r/20240408062230.1949882-7-ChaitanyaS.Prakash@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6b718ac6
    • Namhyung Kim's avatar
      perf report: Add weight[123] output fields · 7043dc52
      Namhyung Kim authored
      Add weight1, weight2 and weight3 fields to -F/--fields and their aliases
      like 'ins_lat', 'p_stage_cyc' and 'retire_lat'.  Note that they are in
      the sort keys too but the difference is that output fields will sum up
      the weight values and display the average.
      
      In the sort key, users can see the distribution of weight value and I
      think it's confusing we have local vs. global weight for the same weight.
      
      For example, I experiment with mem-loads events to get the weights.  On
      my laptop, it seems only weight1 field is supported.
      
        $ perf mem record -- perf test -w noploop
      
      Let's look at the noploop function only.  It has 7 samples.
      
        $ perf script -F event,ip,sym,weight | grep noploop
        # event                         weight     ip           sym
        cpu/mem-loads,ldlat=30/P:           43     55b3c122bffc noploop
        cpu/mem-loads,ldlat=30/P:           48     55b3c122bffc noploop
        cpu/mem-loads,ldlat=30/P:           38     55b3c122bffc noploop    <--- same weight
        cpu/mem-loads,ldlat=30/P:           38     55b3c122bffc noploop    <--- same weight
        cpu/mem-loads,ldlat=30/P:           59     55b3c122bffc noploop
        cpu/mem-loads,ldlat=30/P:           33     55b3c122bffc noploop
        cpu/mem-loads,ldlat=30/P:           38     55b3c122bffc noploop    <--- same weight
      
      When you use the 'weight' sort key, it'd show entries with a separate
      weight value separately.  Also note that the first entry has 3 samples
      with weight value 38, so they are displayed together and the weight
      value is the sum of 3 samples (114 = 38 * 3).
      
        $ perf report -n -s +weight | grep -e Weight -e noploop
        # Overhead  Samples  Command   Shared Object   Symbol         Weight
             0.53%        3     perf   perf            [.] noploop    114
             0.18%        1     perf   perf            [.] noploop    59
             0.18%        1     perf   perf            [.] noploop    48
             0.18%        1     perf   perf            [.] noploop    43
             0.18%        1     perf   perf            [.] noploop    33
      
      If you use 'local_weight' sort key, you can see the actual weight.
      
        $ perf report -n -s +local_weight | grep -e Weight -e noploop
        # Overhead  Samples  Command   Shared Object   Symbol         Local Weight
             0.53%        3     perf   perf            [.] noploop    38
             0.18%        1     perf   perf            [.] noploop    59
             0.18%        1     perf   perf            [.] noploop    48
             0.18%        1     perf   perf            [.] noploop    43
             0.18%        1     perf   perf            [.] noploop    33
      
      But when you use the -F/--field option instead, you can see the average
      weight for the while noploop function (as it won't group samples by
      weight value and use the default 'comm,dso,sym' sort keys).
      
        $ perf report -n -F +weight | grep -e Weight -e noploop
        Warning:
        --fields weight shows the average value unlike in the --sort key.
        # Overhead  Samples  Weight1  Command  Shared Object  Symbol
             1.23%        7     42.4  perf     perf           [.] noploop
      
      The weight1 field shows the average value:
        (38 * 3 + 59 + 48 + 43 + 33) / 7 = 42.4
      
      Also it'd show the warning that 'weight' field has the average value.
      Using 'weight1' can remove the warning.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20240411181718.2367948-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7043dc52
    • Namhyung Kim's avatar
      perf hist: Add weight fields to hist entry stats · 6fcf1e65
      Namhyung Kim authored
      Like period and sample numbers, it'd be better to track weight values
      and display them in the output rather than having them as sort keys.
      
      This patch just adds a few more fields to save the weights in a hist
      entry.  It'll be displayed as new output fields in the later patch.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20240411181718.2367948-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6fcf1e65
    • Namhyung Kim's avatar
      perf hist: Move histogram related code to hist.h · 0993d724
      Namhyung Kim authored
      It's strange that sort.h has the definition of struct hist_entry.  As
      sort.h already includes hist.h, let's move the data structure to hist.h.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20240411181718.2367948-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0993d724
  3. 16 Apr, 2024 4 commits
    • Namhyung Kim's avatar
      perf annotate-data: Handle RSP if it's not the FB register · a5a00497
      Namhyung Kim authored
      In some cases, the stack pointer on x86 (rsp = reg7) is used to point
      variables on stack but it's not the frame base register.  Then it
      should handle the register like normal registers (IOW not to access
      the other stack variables using offset calculation) but it should not
      assume it would have a pointer.
      
      Before:
        -----------------------------------------------------------
        find data type for 0x7c(reg7) at tcp_getsockopt+0xb62
        CU for net/ipv4/tcp.c (die:0x7b5f516)
        frame base: cfa=0 fbreg=6
        no pointer or no type
        check variable "zc" failed (die: 0x7b9580a)
         variable location: base=reg7, offset=0x40
         type='struct tcp_zerocopy_receive' size=0x40 (die:0x7b947f4)
      
      After:
        -----------------------------------------------------------
        find data type for 0x7c(reg7) at tcp_getsockopt+0xb62
        CU for net/ipv4/tcp.c (die:0x7b5f516)
        frame base: cfa=0 fbreg=6
        found "zc" in scope=3/3 (die: 0x7b957fc) type_offset=0x3c
         variable location: base=reg7, offset=0x40
         type='struct tcp_zerocopy_receive' size=0x40 (die:0x7b947f4)
      
      Note that the type-offset was properly calculated to 0x3c as the
      variable starts at 0x40.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240412183310.2518474-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a5a00497
    • Namhyung Kim's avatar
      perf dwarf-aux: Check variable address range properly · 0519fadb
      Namhyung Kim authored
      In match_var_offset(), it just checked the end address of the variable
      with the given offset because it assumed the register holds a pointer
      to the data type and the offset starts from the base.
      
      But I found some cases that the stack pointer (rsp = reg7) register is
      used to pointer a stack variable while the frame base is maintained by a
      different register (rbp = reg6).  In that case, it cannot simply use the
      stack pointer as it cannot guarantee that it points to the frame base.
      So it needs to check both boundaries of the variable location.
      
      Before:
        -----------------------------------------------------------
        find data type for 0x7c(reg7) at tcp_getsockopt+0xb62
        CU for net/ipv4/tcp.c (die:0x7b5f516)
        frame base: cfa=0 fbreg=6
        no pointer or no type
        check variable "tss" failed (die: 0x7b95801)
         variable location: base reg7, offset=0x110
         type='struct scm_timestamping_internal' size=0x30 (die:0x7b8c126)
      
      So the current code just checks register number for the non-PC and
      non-FB registers and assuming it has offset 0.  But this variable has
      offset 0x110 so it should not match to this.
      
      After:
        -----------------------------------------------------------
        find data type for 0x7c(reg7) at tcp_getsockopt+0xb62
        CU for net/ipv4/tcp.c (die:0x7b5f516)
        frame base: cfa=0 fbreg=6
        no pointer or no type
        check variable "zc" failed (die: 0x7b9580a)
         variable location: base=reg7, offset=0x40
         type='struct tcp_zerocopy_receive' size=0x40 (die:7b947f4)
      
      Now it find the correct variable "zc".  It was located at reg7 + 0x40
      and the size if 0x40 which means it should cover [0x40, 0x80).  And the
      access was for reg7 + 0x7c so it found the right one.  But it still
      failed to use the variable and it would be handled in the next patch.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240412183310.2518474-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0519fadb
    • Namhyung Kim's avatar
      perf dwarf-aux: Check pointer offset when checking variables · 645af3fb
      Namhyung Kim authored
      In match_var_offset(), it checks the offset range with the target type
      only for non-pointer types.  But it also needs to check the pointer
      types with the target type.
      
      This is because there can be more than one pointer variable located in
      the same register.  Let's look at the following example.  It's looking
      up a variable for reg3 at tcp_get_info+0x62.  It found "sk" variable but
      it wasn't the right one since it accesses beyond the target type (struct
      'sock' in this case) size.
      
        -----------------------------------------------------------
        find data type for 0x7bc(reg3) at tcp_get_info+0x62
        CU for net/ipv4/tcp.c (die:0x7b5f516)
        frame base: cfa=0 fbreg=6
        offset: 1980 is bigger than size: 760
        check variable "sk" failed (die: 0x7b92b2c)
         variable location: reg3
         type='struct sock' size=0x2f8 (die:0x7b63c3ab)
      
      Actually there was another variable "tp" in the function and it's
      located at the same (reg3) because it's just type-casted like below.
      
        void tcp_get_info(struct sock *sk, struct tcp_info *info)
        {
            const struct tcp_sock *tp = tcp_sk(sk);
            ...
      
      The 'struct tcp_sock' contains the 'struct sock' at offset 0 so it can
      just use the same address as a pointer to tcp_sock.  That means it
      should match variables correctly by checking the offset and size.
      Actually it cannot distinguish if the offset was smaller than the size
      of the original struct sock.  But I think it's fine as they are the same
      at that part.
      
      So let's check the target type size and retry if it doesn't match.
      Now it succeeded to find the correct variable.
      
        -----------------------------------------------------------
        find data type for 0x7bc(reg3) at tcp_get_info+0x62
        CU for net/ipv4/tcp.c (die:0x7b5f516)
        frame base: cfa=0 fbreg=6
        found "tp" in scope=1/1 (die: 0x7b92b16) type_offset=0x7bc
         variable location: reg3
         type='struct tcp_sock' size=0xa68 (die:0x7b81380)
      
      Fixes: bc10db8e ("perf annotate-data: Support stack variables")
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240412183310.2518474-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      645af3fb
    • Namhyung Kim's avatar
      perf annotate-data: Improve debug message with location info · 2bc3cf57
      Namhyung Kim authored
      To verify it found the correct variable, let's add the location
      expression to the debug message.
      
        $ perf --debug type-profile annotate --data-type
        ...
        -----------------------------------------------------------
        find data type for 0xaf0(reg15) at schedule+0xeb
        CU for kernel/sched/core.c (die:0x1180523)
        frame base: cfa=0 fbreg=6
        found "rq" in scope=3/4 (die: 0x11b6a00) type_offset=0xaf0
         variable location: reg15
         type='struct rq' size=0xfc0 (die:0x11892e2)
        -----------------------------------------------------------
        find data type for 0x7bc(reg3) at tcp_get_info+0x62
        CU for net/ipv4/tcp.c (die:0x7b5f516)
        frame base: cfa=0 fbreg=6
        offset: 1980 is bigger than size: 760
        check variable "sk" failed (die: 0x7b92b2c)
         variable location: reg3
         type='struct sock' size=0x2f8 (die:0x7b63c3ab)
        -----------------------------------------------------------
        ...
      
      The first case is fine.  It looked up a data type in r15 with offset of
      0xaf0 at schedule+0xeb.  It found the CU die and the frame base info and
      the variable "rq" was found in the scope 3/4.  Its location is the r15
      register and the type size is 0xfc0 which includes 0xaf0.
      
      But the second case is not good.  It looked up a data type in rbx (reg3)
      with offset 0x7bc.  It found a CU and the frame base which is good so
      far.  And it also found a variable "sk" but the access offset is bigger
      than the type size (1980 vs. 760 or 0x7bc vs. 0x2f8).  The variable has
      the right location (reg3) but I need to figure out why it accesses
      beyond what it's supposed to.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240412183310.2518474-2-namhyung@kernel.org
      [ Fix the build on 32-bit by casting Dwarf_Word to (long) in pr_debug_location() ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2bc3cf57
  4. 12 Apr, 2024 23 commits
    • Ian Rogers's avatar
      perf bench uprobe: Add uretprobe variant of uprobe benchmarks · 988052f4
      Ian Rogers authored
      Name benchmarks with _ret at the end to avoid creating a new set of
      benchmarks.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrei Vagin <avagin@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240406040911.1603801-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      988052f4
    • Ian Rogers's avatar
      perf bench uprobe: Remove lib64 from libc.so.6 binary path · 459fee7b
      Ian Rogers authored
      bpf_program__attach_uprobe_opts will search LD_LIBRARY_PATH and so
      specifying `/lib64` is unnecessary and causes failures for libc.so.6
      paths like `/lib/x86_64-linux-gnu/libc.so.6`.
      
      Fixes: 7b47623b ("perf bench uprobe trace_printk: Add entry attaching an BPF program that does a trace_printk")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrei Vagin <avagin@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kees Kook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240406040911.1603801-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      459fee7b
    • Ian Rogers's avatar
      perf trace beauty: Add shellcheck to scripts · 2b8c43e7
      Ian Rogers authored
      Add shell check to scripts generating perf trace lookup tables. Fix
      quoting issue in arch_errno_names.sh.
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Link: https://lore.kernel.org/r/20240409023216.2342032-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2b8c43e7
    • Ian Rogers's avatar
      perf util: Add shellcheck to generate-cmdlist.sh · 61ff60aa
      Ian Rogers authored
      Add shellcheck to generate-cmdlist.sh to avoid basic shell script
      mistakes.
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Link: https://lore.kernel.org/r/20240409023216.2342032-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      61ff60aa
    • Ian Rogers's avatar
      perf arch x86: Add shellcheck to build · ec440763
      Ian Rogers authored
      Add shellcheck for:
      
        tools/perf/arch/x86/tests/gen-insn-x86-dat.sh
        tools/perf/arch/x86/entry/syscalls/syscalltbl.sh
      
      Address a minor quoting issue.
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Link: https://lore.kernel.org/r/20240409023216.2342032-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ec440763
    • Ian Rogers's avatar
      perf build: Add shellcheck to tools/perf scripts · 646e22eb
      Ian Rogers authored
      Address shell check errors/warnings in perf-archive.sh and
      perf-completion.sh.
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oliver Upton <oliver.upton@linux.dev>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Link: https://lore.kernel.org/r/20240409023216.2342032-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      646e22eb
    • Ian Rogers's avatar
      perf list: Escape '\r' in JSON output · 20b0027c
      Ian Rogers authored
      Events like for sapphirerapids have '\r' in the uncore descriptions. The
      non-escaped versions of this fail JSON validation the the 'perf list'
      test.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240410222353.1722840-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      20b0027c
    • Ian Rogers's avatar
      perf dsos: Switch more loops to dsos__for_each_dso() · 0ffc8fca
      Ian Rogers authored
      Switch loops within dsos.c, add a version that isn't locked. Switch
      some unlocked loops to hold the read lock.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Anne Macedo <retpolanne@posteo.net>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ben Gainey <ben.gainey@arm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Chengen Du <chengen.du@canonical.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linux.dev>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Markus Elfring <Markus.Elfring@web.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paran Lee <p4ranlee@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Sun Haiyong <sunhaiyong@loongson.cn>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yanteng Si <siyanteng@loongson.cn>
      Cc: Yicong Yang <yangyicong@hisilicon.com>
      Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com>
      Link: https://lore.kernel.org/r/20240410064214.2755936-6-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0ffc8fca
    • Ian Rogers's avatar
      perf dso: Move dso functions out of dsos.c · 1d6eff93
      Ian Rogers authored
      Move dso and dso_id functions to dso.c to match the struct declarations.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Anne Macedo <retpolanne@posteo.net>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ben Gainey <ben.gainey@arm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Chengen Du <chengen.du@canonical.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linux.dev>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Markus Elfring <Markus.Elfring@web.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paran Lee <p4ranlee@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Sun Haiyong <sunhaiyong@loongson.cn>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yanteng Si <siyanteng@loongson.cn>
      Cc: Yicong Yang <yangyicong@hisilicon.com>
      Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com>
      Link: https://lore.kernel.org/r/20240410064214.2755936-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1d6eff93
    • Ian Rogers's avatar
      perf dsos: Introduce dsos__for_each_dso() · 73f3fea2
      Ian Rogers authored
      To better abstract the dsos internals, introduce dsos__for_each_dso that
      does a callback on each dso.
      
      This also means the read lock can be correctly held.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Anne Macedo <retpolanne@posteo.net>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ben Gainey <ben.gainey@arm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Chengen Du <chengen.du@canonical.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linux.dev>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Markus Elfring <Markus.Elfring@web.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paran Lee <p4ranlee@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Sun Haiyong <sunhaiyong@loongson.cn>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yanteng Si <siyanteng@loongson.cn>
      Cc: Yicong Yang <yangyicong@hisilicon.com>
      Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com>
      Link: https://lore.kernel.org/r/20240410064214.2755936-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      73f3fea2
    • Ian Rogers's avatar
      perf dsos: Tidy reference counting and locking · f649ed80
      Ian Rogers authored
      Move more functionality into dsos.c generally from machine.c, renaming
      functions to match their new usage.
      
      The find function is made to always "get" before returning a dso.
      
      Reduce the scope of locks in vdso to match the locking paradigm.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Anne Macedo <retpolanne@posteo.net>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ben Gainey <ben.gainey@arm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Chengen Du <chengen.du@canonical.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linux.dev>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Markus Elfring <Markus.Elfring@web.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paran Lee <p4ranlee@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Sun Haiyong <sunhaiyong@loongson.cn>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yanteng Si <siyanteng@loongson.cn>
      Cc: Yicong Yang <yangyicong@hisilicon.com>
      Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com>
      Link: https://lore.kernel.org/r/20240410064214.2755936-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f649ed80
    • Ian Rogers's avatar
      perf dsos: Attempt to better abstract DSOs internals · 83acca9f
      Ian Rogers authored
      Move functions from machine and build-id to dsos. Pass 'struct dsos'
      rather than internal state.
      
      Rename some functions to better represent which data structure they
      operate on.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Anne Macedo <retpolanne@posteo.net>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ben Gainey <ben.gainey@arm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Chengen Du <chengen.du@canonical.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linux.dev>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Markus Elfring <Markus.Elfring@web.de>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paran Lee <p4ranlee@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Sun Haiyong <sunhaiyong@loongson.cn>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yanteng Si <siyanteng@loongson.cn>
      Cc: Yicong Yang <yangyicong@hisilicon.com>
      Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com>
      Link: https://lore.kernel.org/r/20240410064214.2755936-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      83acca9f
    • Adrian Hunter's avatar
      perf record: Fix debug message placement for test consumption · 792bc998
      Adrian Hunter authored
      evlist__config() might mess up the debug output consumed by test
      "Test per-thread recording" in "Miscellaneous Intel PT testing".
      
      Move it out from between the debug prints:
      
        "perf record opening and mmapping events" and
        "perf record done opening and mmapping events"
      
      Fixes: da406202 ("perf tools: Add debug messages and comments for testing")
      Closes: https://lore.kernel.org/linux-perf-users/ZhVfc5jYLarnGzKa@x1/Reported-by: default avatarArnaldo Carvalho de Melo <acme@kernel.org>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20240411075447.17306-1-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      792bc998
    • Namhyung Kim's avatar
      perf annotate: Skip DSOs not found · 873a8373
      Namhyung Kim authored
      In some data file, I see the following messages repeated.  It seems it
      doesn't have DSOs in the system and the dso->binary_type is set to
      DSO_BINARY_TYPE__NOT_FOUND.  Let's skip them to avoid the followings.
      
        No output from objdump  --start-address=0x0000000000000000 --stop-address=0x00000000000000d4  -d --no-show-raw-insn       -C "$1"
        Error running objdump  --start-address=0x0000000000000000 --stop-address=0x0000000000000631  -d --no-show-raw-insn       -C "$1"
        ...
      
      Closes: https://lore.kernel.org/linux-perf-users/15e1a2847b8cebab4de57fc68e033086aa6980ce.camel@yandex.ru/Reported-by: default avatarKonstantin Kharlamov <Hi-Angel@yandex.ru>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarKonstantin Kharlamov <Hi-Angel@yandex.ru>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240410185117.1987239-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      873a8373
    • Namhyung Kim's avatar
      perf report: Do not collect sample histogram unnecessarily · 6cdd977e
      Namhyung Kim authored
      The data type profiling alone doesn't need the sample histogram for
      functions.  It only needs the histogram for the types.
      
      Let's remove the condition in the report_callback to check if data type
      profiling is selected and make sure the annotation has the 'struct
      annotated_source' instantiated before calling symbol__disassemble().
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240411033256.2099646-8-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6cdd977e
    • Namhyung Kim's avatar
      perf report: Add a menu item to annotate data type in TUI · 0bfbe661
      Namhyung Kim authored
      When the hist entry has the type info, it should be able to display the
      annotation browser for the type like in `perf annotate --data-type`.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240411033256.2099646-7-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0bfbe661
    • Namhyung Kim's avatar
      perf annotate-data: Support event group display in TUI · 2b08f219
      Namhyung Kim authored
      Like in stdio, it should print all events in a group together.
      
      Committer notes:
      
      Collect it:
      
        root@number:~# perf record -a -e '{cpu_core/mem-loads,ldlat=30/P,cpu_core/mem-stores/P}'
        ^C[ perf record: Woken up 8 times to write data ]
        [ perf record: Captured and wrote 4.980 MB perf.data (55825 samples) ]
        root@number:~#
      
      Then do it in stdio:
      
        root@number:~# perf annotate --stdio --data-type
      
        Annotate type: 'union ' in /usr/lib64/libc.so.6 (1131 samples):
         event[0] = cpu_core/mem-loads,ldlat=30/P
         event[1] = cpu_core/mem-stores/P
        ============================================================================
                 Percent     offset       size  field
          100.00  100.00          0         40  union    {
          100.00  100.00          0         40      struct __pthread_mutex_s    __data {
           48.61   23.46          0          4          int     __lock;
            0.00    0.48          4          4          unsigned int    __count;
            6.38   41.32          8          4          int     __owner;
            8.74   34.02         12          4          unsigned int    __nusers;
           35.66    0.26         16          4          int     __kind;
            0.61    0.45         20          2          short int       __spins;
            0.00    0.00         22          2          short int       __elision;
            0.00    0.00         24         16          __pthread_list_t        __list {
            0.00    0.00         24          8              struct __pthread_internal_list*     __prev;
            0.00    0.00         32          8              struct __pthread_internal_list*     __next;
                                                        };
                                                    };
            0.00    0.00          0          0      char*       __size;
           48.61   23.94          0          8      long int    __align;
                                                };
      
      Now with TUI before this patch:
      
        root@number:~# perf annotate --tui --data-type
        Annotate type: 'union ' (790 samples)
            Percent     Offset       Size  Field
             100.00          0         40  union  {
             100.00          0         40      struct __pthread_mutex_s __data {
              48.61          0          4          int  __lock;
               0.00          4          4          unsigned int __count;
               6.38          8          4          int  __owner;
               8.74         12          4          unsigned int __nusers;
              35.66         16          4          int  __kind;
               0.61         20          2          short int    __spins;
               0.00         22          2          short int    __elision;
               0.00         24         16          __pthread_list_t     __list {
               0.00         24          8              struct __pthread_internal_list*  __prev;
               0.00         32          8              struct __pthread_internal_list*  __next;
      
               0.00          0          0      char*    __size;
              48.61          0          8      long int __align;
                                           };
      
      And now after this patch:
      
      Annotate type: 'union ' (790 samples)
                     Percent     Offset       Size  Field
           100.00     100.00          0         40  union  {
           100.00     100.00          0         40      struct __pthread_mutex_s      __data {
            48.61      23.46          0          4          int       __lock;
             0.00       0.48          4          4          unsigned int      __count;
             6.38      41.32          8          4          int       __owner;
             8.74      34.02         12          4          unsigned int      __nusers;
            35.66       0.26         16          4          int       __kind;
             0.61       0.45         20          2          short int __spins;
             0.00       0.00         22          2          short int __elision;
             0.00       0.00         24         16          __pthread_list_t  __list {
             0.00       0.00         24          8              struct __pthread_internal_list*       __prev;
             0.00       0.00         32          8              struct __pthread_internal_list*       __next;
                                                            };
                                                        };
             0.00       0.00          0          0      char* __size;
            48.61      23.94          0          8      long int      __align;
                                                    };
      
      On a followup patch the --tui output should have this that is present in
      --stdio:
      
        And the --stdio has all the missing info in TUI:
      
          Annotate type: 'union ' in /usr/lib64/libc.so.6 (1131 samples):
           event[0] = cpu_core/mem-loads,ldlat=30/P
           event[1] = cpu_core/mem-stores/P
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240411033256.2099646-6-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2b08f219
    • Namhyung Kim's avatar
      perf annotate-data: Add hist_entry__annotate_data_tui() · d001c7a7
      Namhyung Kim authored
      Support data type profiling output on TUI.
      
      Testing from Arnaldo:
      
      First make sure that the debug information for your workload binaries
      in embedded in them by building it with '-g' or install the debuginfo
      packages, since our workload is 'find':
      
        root@number:~# type find
        find is hashed (/usr/bin/find)
        root@number:~# rpm -qf /usr/bin/find
        findutils-4.9.0-5.fc39.x86_64
        root@number:~# dnf debuginfo-install findutils
        <SNIP>
        root@number:~#
      
      Then collect some data:
      
        root@number:~# echo 1 > /proc/sys/vm/drop_caches
        root@number:~# perf mem record find / > /dev/null
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.331 MB perf.data (3982 samples) ]
        root@number:~#
      
      Finally do data-type annotation with the following command, that will
      default, as 'perf report' to the --tui mode, with lines colored to
      highlight the hotspots, etc.
      
        root@number:~# perf annotate --data-type
        Annotate type: 'struct predicate' (58 samples)
            Percent     Offset       Size  Field
             100.00          0        312  struct predicate {
               0.00          0          8      PRED_FUNC        pred_func;
               0.00          8          8      char*    p_name;
               0.00         16          4      enum predicate_type      p_type;
               0.00         20          4      enum predicate_precedence        p_prec;
               0.00         24          1      _Bool    side_effects;
               0.00         25          1      _Bool    no_default_print;
               0.00         26          1      _Bool    need_stat;
               0.00         27          1      _Bool    need_type;
               0.00         28          1      _Bool    need_inum;
               0.00         32          4      enum EvaluationCost      p_cost;
               0.00         36          4      float    est_success_rate;
               0.00         40          1      _Bool    literal_control_chars;
               0.00         41          1      _Bool    artificial;
               0.00         48          8      char*    arg_text;
        <SNIP>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240411033256.2099646-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d001c7a7
    • Namhyung Kim's avatar
      perf annotate-data: Add hist_entry__annotate_data_tty() · 9b561be1
      Namhyung Kim authored
      And move the related code into util/annotate-data.c file.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240411033256.2099646-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9b561be1
    • Namhyung Kim's avatar
      perf annotate: Show progress of sample processing · d9aedc12
      Namhyung Kim authored
      Like 'perf report', it can take a while to process samples.
      
      Show a progress window to inform users how that it is not stuck.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240411033256.2099646-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d9aedc12
    • Namhyung Kim's avatar
      perf annotate-data: Skip sample histogram for stack canary · eb833488
      Namhyung Kim authored
      It's a pseudo data type and has no field.
      
      Fixes: b3c95109 ("perf annotate-data: Add stack canary type")
      Closes: https://lore.kernel.org/lkml/Zhb6jJneP36Z-or0@x1Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20240411033256.2099646-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eb833488
    • James Clark's avatar
      perf tests: Remove dependency on lscpu · 7aa87499
      James Clark authored
      This check can be done with uname which is more portable. At the same
      time re-arrange it into a standard if statement so that it's more
      readable.
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linux.dev>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Spoorthy S <spoorts2@in.ibm.com>
      Link: https://lore.kernel.org/r/20240410103458.813656-5-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7aa87499
    • James Clark's avatar
      perf map: Remove kernel map before updating start and end addresses · df12e21d
      James Clark authored
      In a debug build there is validation that mmap lists are sorted when
      taking a lock. In machine__update_kernel_mmap() the start and end
      addresses are updated resulting in an unsorted list before the map is
      removed from the list. When the map is removed, the lock is taken which
      triggers the validation and the failure:
      
        $ perf test "object code reading"
        --- start ---
        perf: util/maps.c:88: check_invariants: Assertion `map__start(prev) <= map__start(map)' failed.
        Aborted
      
      Fix it by updating the addresses after removal, but before insertion.
      The bug depends on the ordering and type of debug info on the system and
      doesn't reproduce everywhere.
      
      Fixes: 659ad349 ("perf maps: Switch from rbtree to lazily sorted array for addresses")
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linux.dev>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Spoorthy S <spoorts2@in.ibm.com>
      Link: https://lore.kernel.org/r/20240410103458.813656-4-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      df12e21d