Skip to content
  1. Jan 23, 2023
    • Adrian Hunter's avatar
      perf symbols: Check SHT_RELA and SHT_REL type earlier · df8aeaef
      Adrian Hunter authored
      
      
      Make the code more readable by checking for SHT_RELA and SHT_REL type
      earlier.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-11-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      df8aeaef
    • Adrian Hunter's avatar
      perf symbols: Combine handling for SHT_RELA and SHT_REL · 375a4481
      Adrian Hunter authored
      
      
      SHT_REL and SHT_RELA are handled the same way. Simplify by combining the
      handling.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-10-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      375a4481
    • Adrian Hunter's avatar
      perf symbols: Allow for .plt entries with no symbol · 45204677
      Adrian Hunter authored
      
      
      Create a sensible name for .plt entries with no symbol.
      
      Example:
      
       Before:
      
         $ perf test --dso /usr/lib/x86_64-linux-gnu/libc.so.6 -vv Symbols 2>/tmp/cmp1.txt
      
       After:
      
         $ perf test --dso /usr/lib/x86_64-linux-gnu/libc.so.6 -vv Symbols 2>/tmp/cmp2.txt
         $ diff /tmp/cmp1.txt /tmp/cmp2.txt
          4c4
          < test child forked, pid 53043
          ---
          > test child forked, pid 54372
          23,62c23,62
          <  280f0-28100 g @plt
          <  28100-28110 g @plt
          <  28110-28120 g @plt
          <  28120-28130 g @plt
          <  28130-28140 g @plt
          <  28140-28150 g @plt
          <  28150-28160 g @plt
          <  28160-28170 g @plt
          <  28170-28180 g @plt
          <  28180-28190 g @plt
          <  28190-281a0 g @plt
          <  281a0-281b0 g @plt
          <  281b0-281c0 g @plt
          <  281c0-281d0 g @plt
          <  281d0-281e0 g @plt
          <  281e0-281f0 g @plt
          <  281f0-28200 g @plt
          <  28200-28210 g @plt
          <  28210-28220 g @plt
          <  28220-28230 g @plt
          <  28230-28240 g @plt
          <  28240-28250 g @plt
          <  28250-28260 g @plt
          <  28260-28270 g @plt
          <  28270-28280 g @plt
          <  28280-28290 g @plt
          <  28290-282a0 g @plt
          <  282a0-282b0 g @plt
          <  282b0-282c0 g @plt
          <  282c0-282d0 g @plt
          <  282d0-282e0 g @plt
          <  282e0-282f0 g @plt
          <  282f0-28300 g @plt
          <  28300-28310 g @plt
          <  28310-28320 g @plt
          <  28320-28330 g @plt
          <  28330-28340 g @plt
          <  28340-28350 g @plt
          <  28350-28360 g @plt
          <  28360-28370 g @plt
          ---
          >  280f0-28100 g offset_0x280f0@plt
          >  28100-28110 g offset_0x28100@plt
          >  28110-28120 g offset_0x28110@plt
          >  28120-28130 g offset_0x28120@plt
          >  28130-28140 g offset_0x28130@plt
          >  28140-28150 g offset_0x28140@plt
          >  28150-28160 g offset_0x28150@plt
          >  28160-28170 g offset_0x28160@plt
          >  28170-28180 g offset_0x28170@plt
          >  28180-28190 g offset_0x28180@plt
          >  28190-281a0 g offset_0x28190@plt
          >  281a0-281b0 g offset_0x281a0@plt
          >  281b0-281c0 g offset_0x281b0@plt
          >  281c0-281d0 g offset_0x281c0@plt
          >  281d0-281e0 g offset_0x281d0@plt
          >  281e0-281f0 g offset_0x281e0@plt
          >  281f0-28200 g offset_0x281f0@plt
          >  28200-28210 g offset_0x28200@plt
          >  28210-28220 g offset_0x28210@plt
          >  28220-28230 g offset_0x28220@plt
          >  28230-28240 g offset_0x28230@plt
          >  28240-28250 g offset_0x28240@plt
          >  28250-28260 g offset_0x28250@plt
          >  28260-28270 g offset_0x28260@plt
          >  28270-28280 g offset_0x28270@plt
          >  28280-28290 g offset_0x28280@plt
          >  28290-282a0 g offset_0x28290@plt
          >  282a0-282b0 g offset_0x282a0@plt
          >  282b0-282c0 g offset_0x282b0@plt
          >  282c0-282d0 g offset_0x282c0@plt
          >  282d0-282e0 g offset_0x282d0@plt
          >  282e0-282f0 g offset_0x282e0@plt
          >  282f0-28300 g offset_0x282f0@plt
          >  28300-28310 g offset_0x28300@plt
          >  28310-28320 g offset_0x28310@plt
          >  28320-28330 g offset_0x28320@plt
          >  28330-28340 g offset_0x28330@plt
          >  28340-28350 g offset_0x28340@plt
          >  28350-28360 g offset_0x28350@plt
          >  28360-28370 g offset_0x28360@plt
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-9-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      45204677
    • Adrian Hunter's avatar
      perf symbols: Add symbol for .plt header · 698a0d1a
      Adrian Hunter authored
      
      
      perf expands the _init symbol over .plt because there are no PLT symbols
      at that point, but then dso__synthesize_plt_symbols() creates them.
      
      Fix by truncating the previous symbol and inserting a symbol for .plt
      header.
      
      Example:
      
       Before:
      
         $ perf test --dso `which uname` -v Symbols
          74: Symbols                                                         :
         --- start ---
         test child forked, pid 191028
         Problems creating module maps, continuing anyway...
         Testing /usr/bin/uname
         Overlapping symbols:
          2000-25f0 g _init
          2040-2050 g free@plt
         test child finished with -1
         ---- end ----
         Symbols: FAILED!
         $ perf test --dso `which uname` -vv Symbols 2>/tmp/cmp1.txt
      
       After:
      
         $ perf test --dso `which uname` -v Symbols
          74: Symbols                                                         :
         --- start ---
         test child forked, pid 194291
         Testing /usr/bin/uname
         test child finished with 0
         ---- end ----
         Symbols: Ok
         $ perf test --dso `which uname` -vv Symbols 2>/tmp/cmp2.txt
         $ diff /tmp/cmp1.txt /tmp/cmp2.txt
         4,5c4
         < test child forked, pid 191031
         < Problems creating module maps, continuing anyway...
         ---
         > test child forked, pid 194296
         9c8,9
         <  2000-25f0 g _init
         ---
         >  2000-2030 g _init
         >  2030-2040 g .plt
         100,103c100
         < Overlapping symbols:
         <  2000-25f0 g _init
         <  2040-2050 g free@plt
         < test child finished with -1
         ---
         > test child finished with 0
         105c102
         < Symbols: FAILED!
         ---
         > Symbols: Ok
         $
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-8-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      698a0d1a
    • Adrian Hunter's avatar
      perf symbols: Do not check ss->dynsym twice · 5fec9b17
      Adrian Hunter authored
      
      
      ss->dynsym is checked to be not NULL twice. Remove the first check
      because, in fact, there can be a plt with no dynsym, which is something
      that will be dealt with later.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-7-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5fec9b17
    • Adrian Hunter's avatar
      perf symbols: Slightly simplify 'err' usage in dso__synthesize_plt_symbols() · 477d5e35
      Adrian Hunter authored
      
      
      Return zero directly instead of needless 'goto out_elf_end' that does
      the same thing. That allows 'err' to be initialized to -1 instead of
      having to change its value later.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-6-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      477d5e35
    • Adrian Hunter's avatar
      perf symbols: Add dso__find_symbol_nocache() · a2db72c5
      Adrian Hunter authored
      
      
      Symbols should not be cached when there are more symbols still to add.
      
      Add dso__find_symbol_nocache() to facilitate that.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-5-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a2db72c5
    • Adrian Hunter's avatar
      perf symbols: Check plt_entry_size is not zero · b08b20c3
      Adrian Hunter authored
      
      
      The code expects non-zero plt_entry_size. Check it and add a debug
      message to print if it is zero.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-4-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b08b20c3
    • Adrian Hunter's avatar
      perf symbols: Factor out get_plt_sizes() · c2d066c0
      Adrian Hunter authored
      
      
      Factor out get_plt_sizes() to make the code more readable and further
      changes to dso__synthesize_plt_symbols() easier to follow.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-3-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c2d066c0
    • Adrian Hunter's avatar
      perf test: Add Symbols test · 1b69346e
      Adrian Hunter authored
      
      
      Add a test to check function symbols do not overlap and are not zero
      length.
      
      The main motivation for the test is to make it easier to review changes
      to PLT symbol synthesis i.e. changes to dso__synthesize_plt_symbols().
      
      By default the test uses the perf executable as a test DSO, but a
      specific DSO can be specified via a new perf test option "--dso".
      
      The test is useful in the following ways:
      
       - Any DSO can be tested, even ones that do not run on the current
       architecture. For example, using cross-compiled DSOs to see how
       well perf handles different architectures.
      
       - With verbose > 1 (e.g. -vv), all the symbols are printed, which
       makes it easier to see issues.
      
       - perf removes duplicate symbols and expands zero-length symbols
       to reach the next symbol, however that is done before adding
       synthesized symbols, so the test is checking those also.
      
      Example:
      
        $ perf test -v Symbols
         74: Symbols                                                         :
        --- start ---
        test child forked, pid 154918
        Testing /home/user/bin/perf
        Overlapping symbols:
         7d000-7f3a0 g _init
         7d030-7d040 g __printf_chk@plt
        test child finished with -1
        ---- end ----
        Symbols: FAILED!
      
      Note the test fails because perf expands the _init symbol over the PLT
      because there are no PLT symbols at that point, but then
      dso__synthesize_plt_symbols() creates them.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230120123456.12449-2-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1b69346e
  2. Jan 20, 2023
    • Ian Rogers's avatar
      perf test workload thloop: Make count increments atomic · 1962ab6f
      Ian Rogers authored
      
      
      The count variable is incremented by multiple threads, doing so
      without an atomic operation causes thread sanitizer warnings. Switch
      to using relaxed atomics.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.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/20230114215251.271678-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1962ab6f
    • Ian Rogers's avatar
      perf debug: Increase libtraceevent logging when verbose · 316769f7
      Ian Rogers authored
      
      
      libtraceevent has added more levels of debug printout and with changes
      like:
      
        https://lore.kernel.org/linux-trace-devel/20210507095022.1079364-3-tz.stoyanov@gmail.com
      
      previously generated output like "registering plugin" is no longer
      displayed. This change makes it so that if perf's verbose debug output
      is enabled then the debug and info libtraceevent messages can be
      displayed.
      
      This change was previously posted:
      
        https://lore.kernel.org/linux-perf-users/20210923001024.550263-4-irogers@google.com/
      
      and reverted:
      
        https://lore.kernel.org/linux-perf-users/20220109153446.160593-1-acme@kernel.org/
      
      The previous failure was due to -Itools/lib being on the include path
      and libtraceevent in tools/lib being version 1.1.0. This meant that when
      LIBTRACEEVENT_VERSION was 1.3.0 the #if succeeded, but the header file
      for libtraceevent (taken from tools/lib rather than the intended
      /usr/include) was for version 1.1.0 and function definitions were
      missing.
      
      Since the previous issue the -Itools/lib include path has been
      removed:
      
        https://lore.kernel.org/lkml/20221109184914.1357295-1-irogers@google.com/
      
      As well as libtraceevent 1.1.0 has been removed from tools/lib:
      
        https://lore.kernel.org/lkml/20221130062935.2219247-1-irogers@google.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 Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Eelco Chaudron <echaudro@redhat.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20230111070641.1728726-3-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      316769f7
    • Ian Rogers's avatar
      perf trace: Reduce #ifdefs for TEP_FIELD_IS_RELATIVE · 1634bad3
      Ian Rogers authored
      
      
      Add a helper function that applies the mask to test, or returns false
      if libtraceevent is too old or not present.
      
      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 Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Eelco Chaudron <echaudro@redhat.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20230111070641.1728726-2-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1634bad3
    • Ian Rogers's avatar
      perf tools: Remove HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE · 1784eeae
      Ian Rogers authored
      Switch HAVE_LIBTRACEEVENT_TEP_FIELD_IS_RELATIVE to be a version number
      test on libtraceevent being >= to version 1.5.0. This also corrects a
      greater-than test to be greater-than-or-equal.
      
      Fixes: b9a49f8c
      
       ("perf tools: Check if libtracevent has TEP_FIELD_IS_RELATIVE")
      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 Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Eelco Chaudron <echaudro@redhat.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com/
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1784eeae
    • Ian Rogers's avatar
      perf llvm: Fix inadvertent file creation · 9f19aab4
      Ian Rogers authored
      The LLVM template is first echo-ed into command_out and then
      command_out executed. The echo surrounds the template with double
      quotes, however, the template itself may contain quotes. This is
      generally innocuous but in tools/perf/tests/bpf-script-test-prologue.c
      we see:
      ...
      SEC("func=null_lseek file->f_mode offset orig")
      ...
      where the first double quote ends the double quote of the echo, then
      the > redirects output into a file called f_mode.
      
      To avoid this inadvertent behavior substitute redirects and similar
      characters to be ASCII control codes, then substitute the output in
      the echo back again.
      
      Fixes: 5eab5a7e
      
       ("perf llvm: Display eBPF compiling command in debug output")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: bpf@vger.kernel.org
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: llvm@lists.linux.dev
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tom Rix <trix@redhat.com>
      Link: https://lore.kernel.org/r/20230105082609.344538-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9f19aab4
  3. Jan 19, 2023
    • Kan Liang's avatar
      perf vendor events intel: Add Emerald Rapids · 03953a69
      Kan Liang authored
      
      
      The event list of the Emerald Rapids is the same as the Sapphire
      Rapids. Add the CPU model ID of Emerald Rapids into the mapfile.csv and
      point it to the event list of Sapphire Rapids.
      
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Andi Kleen <andi.kleen@intel.com>
      Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20230118175632.3165217-1-kan.liang@linux.intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      03953a69
    • qinyu's avatar
      perf docs: Fix a typo in 'perf probe' man page: l20th -> 120th · 3524f89e
      qinyu authored
      Fix a minor typo in 'perf probe' doc.
      
      Fixes: 631c9def
      
       ("perf probe: Support --line option to show probable source-code lines")
      Signed-off-by: default avatarqinyu <qinyu32@huawei.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Feilong Lin <linfeilong@huawei.com>
      Cc: Hewenliang <hewenliang4@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230116012143.432435-1-qinyu32@huawei.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3524f89e
    • Jing Zhang's avatar
      perf vendor events arm64: Add instruction mix metrics for neoverse-n2-v2 · 485c5bc5
      Jing Zhang authored
      
      
      Add instruction mix related metrics.
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-10-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      485c5bc5
    • Jing Zhang's avatar
      perf vendor events arm64: Add PE utilization metrics for neoverse-n2-v2 · 4befa5cf
      Jing Zhang authored
      
      
      Add PE utilization related metrics. In cpu_utilization metric, if it is
      neoverse-n2 which slots are 5, the real stall_slot need to subtract the
      cpu_cycles according to the neoverse-n2 errata [0].
      
      [0] https://documentation-service.arm.com/static/636a66a64e6cf12278ad89cb?token=
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-9-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4befa5cf
    • Jing Zhang's avatar
      perf vendor events arm64: Add branch metrics for neoverse-n2-v2 · a1adade7
      Jing Zhang authored
      
      
      Add branch related metrics.
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-8-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a1adade7
    • Jing Zhang's avatar
      perf vendor events arm64: Add cache metrics for neoverse-n2-v2 · 8556d367
      Jing Zhang authored
      
      
      Add cache related metrics.
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-7-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8556d367
    • Jing Zhang's avatar
      perf vendor events arm64: Add TLB metrics for neoverse-n2-v2 · 6a60dd2e
      Jing Zhang authored
      
      
      Add TLB related metrics.
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-6-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6a60dd2e
    • Jing Zhang's avatar
      perf vendor events arm64: Add topdown L1 metrics for neoverse-n2-v2 · c1c685ce
      Jing Zhang authored
      
      
      Add general topdown L1 metrics for neoverse-n2-v2. Due to the wrong
      count of stall_slot and stall_slot_frontend on neoverse-n2, the real
      stall_slot and real stall_slot_frontend need to subtract cpu_cycles,
      so overwrite the "MetricExpr" for neoverse-n2 which slots are 5.
      Reference from ARM neoverse-n2 errata notice [0], D117.
      
      Since neoverse-n2/neoverse-v2 does not yet support topdown L2, metric
      groups such as Cache, TLB, Branch, InstructionsMix and PEutilization
      will be added to further analysis of performance bottlenecks in the
      following patches. Reference from ARM PMU guide [1][2].
      
      [0] https://documentation-service.arm.com/static/636a66a64e6cf12278ad89cb?token=
      [1] https://documentation-service.arm.com/static/628f8fa3dfaf015c2b76eae8?token=
      [2] https://documentation-service.arm.com/static/62cfe21e31ea212bb6627393?token=
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-5-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c1c685ce
    • Jing Zhang's avatar
      perf vendor events arm64: Add common topdown L1 metrics · a9ff64e5
      Jing Zhang authored
      
      
      The metrics of topdown L1 are from ARM sbsa7.0 platform design doc[0],
      D37-38, which are standard. So put them in the common file sbsa.json of
      arm64, so that other cores besides n2/v2 can also be reused.
      
      [0] https://documentation-service.arm.com/static/60250c7395978b529036da86?token=
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-4-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a9ff64e5
    • Jing Zhang's avatar
      perf jevent: Add general metrics support · 5b51e47a
      Jing Zhang authored
      
      
      Add general metrics support, so that some general metrics applicable to
      multiple architectures can be defined in the public JSON file like
      general events, and then add general metrics through "arch_std_event" in
      JSON file of different architecture.
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-3-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5b51e47a
    • Jing Zhang's avatar
      perf pmu: Add #slots literal support for arm64 · acef233b
      Jing Zhang authored
      
      
      The slots in each architecture may be different, so add #slots literal
      to obtain the slots of different architectures, and the #slots can be
      applied in the metric. Currently, The #slots just support for arm64,
      and other architectures will return NAN.
      
      On arm64, the value of slots is from the register PMMIR_EL1.SLOT, which
      I can read in /sys/bus/event_source/device/armv8_pmuv3_*/caps/slots.
      PMMIR_EL1.SLOT might read as zero if the PMU version is lower than
      ID_AA64DFR0_EL1_PMUVer_V3P4 or the STALL_SLOT event is not implemented.
      
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarJing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuai Xue <xueshuai@linux.alibaba.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Zhuo Song <zhuo.song@linux.alibaba.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/1673940573-90503-2-git-send-email-renyu.zj@linux.alibaba.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      acef233b
    • Ian Rogers's avatar
      perf script flamegraph: Avoid d3-flame-graph package dependency · b430d243
      Ian Rogers authored
      
      
      Currently flame graph generation requires a d3-flame-graph template to
      be installed. Unfortunately this is hard to come by for things like
      Debian [1].
      
      If the template isn't installed then ask if it should be downloaded from
      jsdelivr CDN. The downloaded HTML file is validated against an md5sum.
      If the download fails, generate a minimal flame graph with the
      javascript coming from links to jsdelivr CDN.
      
      v3. Adds a warning message and quits before download in live mode.
      v2. Change the warning to a prompt about downloading and add the
          --allow-download command line flag. Add an md5sum check for the
          downloaded HTML.
      
      [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=996839
      
      Reviewed-by: default avatarAndreas Gerstmayr <agerstmayr@redhat.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: 996839@bugs.debian.org
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Brendan Gregg <brendan@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Spier <spiermar@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230118072409.147786-1-irogers@google.com # v3 discussion
      Link: https://lore.kernel.org/r/20230112220024.32709-1-irogers@google.com # v2 discussion
      Link: https://lore.kernel.org/r/CAP-5=fXi_9zdhTAoYApiFQoLURAvpEatFzU3uL23o3zs=z25ZQ@mail.gmail.com # v1 discussion
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b430d243
    • Linus Torvalds's avatar
      Merge tag 'for-linus-2023011801' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid · 7287904c
      Linus Torvalds authored
      Pull HID fixes from Jiri Kosina:
      
       - fixes for potential empty list handling in HID core (Pietro Borrello)
      
       - fix for NULL pointer dereference in betop driver that could be
         triggered by malicious device (Pietro Borrello)
      
       - fixes for handling calibration data preventing division by zero in
         Playstation driver (Roderick Colenbrander)
      
       - fix for memory leak on error path in amd-sfh driver (Basavaraj
         Natikar)
      
       - other few assorted small fixes and device ID-specific handling
      
      * tag 'for-linus-2023011801' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
        HID: betop: check shape of output reports
        HID: playstation: sanity check DualSense calibration data.
        HID: playstation: sanity check DualShock4 calibration data.
        HID: uclogic: Add support for XP-PEN Deco 01 V2
        HID: revert CHERRY_MOUSE_000C quirk
        HID: check empty report_list in bigben_probe()
        HID: check empty report_list in hid_validate_values()
        HID: amd_sfh: Fix warning unwind goto
        HID: intel_ish-hid: Add check for ishtp_dma_tx_map
      7287904c
    • Linus Torvalds's avatar
      Merge tag 'affs-for-6.2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 7026172b
      Linus Torvalds authored
      Pull affs fix from David Sterba:
       "One minor fix for a KCSAN report"
      
      * tag 'affs-for-6.2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        affs: initialize fsdata in affs_truncate()
      7026172b
    • Linus Torvalds's avatar
      Merge tag 'erofs-for-6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs · 5fbad44d
      Linus Torvalds authored
      Pull erofs fixes from Gao Xiang:
       "Two patches fixes issues reported by syzbot, one fixes a missing
        `domain_id` mount option in documentation and a minor cleanup:
      
         - Fix wrong iomap->length calculation post EOF, which could cause a
           WARN_ON in iomap_iter_done() (Siddh)
      
         - Fix improper kvcalloc() use with __GFP_NOFAIL (me)
      
         - Add missing `domain_id` mount option in documentation (Jingbo)
      
         - Clean up fscache option parsing (Jingbo)"
      
      * tag 'erofs-for-6.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
        erofs: clean up parsing of fscache related options
        erofs: add documentation for 'domain_id' mount option
        erofs: fix kvcalloc() misuse with __GFP_NOFAIL
        erofs/zmap.c: Fix incorrect offset calculation
      5fbad44d
    • Linus Torvalds's avatar
      Merge tag 'loongarch-fixes-6.2-1' of... · 84bd7e08
      Linus Torvalds authored
      Merge tag 'loongarch-fixes-6.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
      
      Pull LoongArch fixes from Huacai Chen:
       "Fix a missing elf_hwcap, fix some stack unwinder bugs and two trivial
        cleanups"
      
      * tag 'loongarch-fixes-6.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
        LoongArch: Add generic ex-handler unwind in prologue unwinder
        LoongArch: Strip guess unwinder out from prologue unwinder
        LoongArch: Use correct sp value to get graph addr in stack unwinders
        LoongArch: Get frame info in unwind_start() when regs is not available
        LoongArch: Adjust PC value when unwind next frame in unwinder
        LoongArch: Simplify larch_insn_gen_xxx implementation
        LoongArch: Use common function sign_extend64()
        LoongArch: Add HWCAP_LOONGARCH_CPUCFG to elf_hwcap
      84bd7e08
  4. Jan 18, 2023
  5. Jan 17, 2023