Skip to content
  1. Feb 02, 2023
    • Athira Rajeev's avatar
      perf tests shell: Add check for perf data file in record+probe_libc_inet_pton test · 84cce3d6
      Athira Rajeev authored
      
      
      The "probe libc's inet_pton & backtrace it with ping" test installs a
      uprobe and uses perf record/script to check the backtrace. Currently
      even if the "perf record" fails, the test reports success. Logs below:
      
        # ./perf test -v "probe libc's inet_pton & backtrace it with ping"
        81: probe libc's inet_pton & backtrace it with ping                 :
        --- start ---
        test child forked, pid 304211
        failed to open /tmp/perf.data.Btf: No such file or directory
        test child finished with 0
        ---- end ----
        probe libc's inet_pton & backtrace it with ping: Ok
      
      Fix this by adding check for presence of perf.data file
      before proceeding with "perf script".
      
      With the patch changes, test reports fail correctly.
      
       # ./perf test -v "probe libc's inet_pton & backtrace it with ping"
       81: probe libc's inet_pton & backtrace it with ping                 :
        --- start ---
        test child forked, pid 304358
        FAIL: perf record failed to create "/tmp/perf.data.Uoi"
        test child finished with -1
        ---- end ----
        probe libc's inet_pton & backtrace it with ping: FAILED!
      
      Signed-off-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Disha Goel <disgoel@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nageswara R Sastry <rnsastry@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: http://lore.kernel.org/r/20230201180421.59640-1-atrajeev@linux.vnet.ibm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      84cce3d6
    • Namhyung Kim's avatar
      perf test: Add pipe mode test to the Intel PT test suite · e072b097
      Namhyung Kim authored
      
      
      The test_pipe() function will check perf report and perf inject with
      pipe input.
      
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20230131023350.1903992-5-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e072b097
    • Namhyung Kim's avatar
      perf session: Avoid calling lseek(2) for pipe · 14bf4784
      Namhyung Kim authored
      
      
      We should not call lseek(2) for pipes as it won't work.  And we already
      in the proper place to read the data for AUXTRACE.  Add the comment like
      in the PERF_RECORD_HEADER_TRACING_DATA.
      
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20230131023350.1903992-4-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      14bf4784
    • Namhyung Kim's avatar
      perf intel-pt: Do not try to queue auxtrace data on pipe · aeb802f8
      Namhyung Kim authored
      When it processes AUXTRACE_INFO, it calls to auxtrace_queue_data() to
      collect AUXTRACE data first.  That won't work with pipe since it needs
      lseek() to read the scattered aux data.
      
        $ perf record -o- -e intel_pt// true | perf report -i- --itrace=i100
        # To display the perf.data header info, please use --header/--header-only options.
        #
        0x4118 [0xa0]: failed to process type: 70
        Error:
        failed to process sample
      
      For the pipe mode, it can handle the aux data as it gets.  But there's
      no guarantee it can get the aux data in time.  So the following warning
      will be shown at the beginning:
      
        WARNING: Intel PT with pipe mode is not recommended.
                 The output cannot relied upon.  In particular,
                 time stamps and the order of events may be incorrect.
      
      Fixes: dbd13432
      
       ("perf intel-pt: Add support for decoding AUX area samples")
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      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: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20230131023350.1903992-3-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      aeb802f8
    • Namhyung Kim's avatar
      perf inject: Use perf_data__read() for auxtrace · 1746212d
      Namhyung Kim authored
      In copy_bytes(), it reads the data from the (input) fd and writes it to
      the output file.  But it does with the read(2) unconditionally which
      caused a problem of mixing buffered vs unbuffered I/O together.
      
      You can see the problem when using pipes.
      
        $ perf record -e intel_pt// -o- true | perf inject -b > /dev/null
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.000 MB - ]
        0x45c0 [0x30]: failed to process type: 71
      
      It should use perf_data__read() to honor the 'use_stdio' setting.
      
      Fixes: 60136667
      
       ("perf data: Allow to use stdio functions for pipe mode")
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20230131023350.1903992-2-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1746212d
  2. Jan 31, 2023
    • Mike Leach's avatar
      perf cs-etm: Update decoder code for OpenCSD version 1.4 · c6535b6b
      Mike Leach authored
      
      
      OpenCSD version 1.4 is released with support for FEAT_ITE.
      
      This adds a new packet type, with associated output element ID in the
      packet type enum - OCSD_GEN_TRC_ELEM_INSTRUMENTATION.
      
      As we just ignore this packet in perf, add to the switch statement to
      avoid the "enum not handled in switch error", but conditionally so as
      not to break the perf build for older OpenCSD installations.
      
      Reviewed-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarMike Leach <mike.leach@linaro.org>
      Acked-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: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120153706.20388-1-mike.leach@linaro.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c6535b6b
    • Naveen N. Rao's avatar
      perf test: Fix DWARF unwind test by adding non-inline to expected function in a backtrace · dfadf8b3
      Naveen N. Rao authored
      'DWARF unwind' 'perf test' can sometimes fail:
      
        $ perf test -v 74
        Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc
         74: Test dwarf unwind                                               :
        --- start ---
        test child forked, pid 3785254
        Problems creating module maps, continuing anyway...
        Problems creating module maps, continuing anyway...
        unwind: test__arch_unwind_sample:ip = 0x102d0ad4c (0x36ad4c)
        unwind: access_mem addr 0x7fffc33128c8, val 1031c3228, offset 120
        unwind: access_mem addr 0x7fffc33128d0, val 12427cc70, offset 128
        <snip>
        unwind: test_dwarf_unwind__krava_3:ip = 0x102b8768b (0x1e768b)
        unwind: access_mem addr 0x7fffc3313048, val 7fffc3313050, offset 2040
        unwind: access_mem addr 0x7fffc3313060, val 102b8777c, offset 2064
        unwind: test_dwarf_unwind__krava_2:ip = 0x102b8770b (0x1e770b)
        unwind: access_mem addr 0x7fffc3313088, val 7fffc3313090, offset 2104
        unwind: access_mem addr 0x7fffc33130a0, val 102b87890, offset 2128
        unwind: test_dwarf_unwind__krava_1:ip = 0x102b8777b (0x1e777b)
        unwind: access_mem addr 0x7fffc3313108, val 10323a274, offset 2232
        unwind: access_mem addr 0x7fffc3313110, val ffffffffffffffff, offset 2240
        unwind: access_mem addr 0x7fffc3313118, val 102c08ed0, offset 2248
        unwind: access_mem addr 0x7fffc3313120, val 1031db000, offset 2256
        unwind: access_mem addr 0x7fffc3313128, val 7fffc3313130, offset 2264
        unwind: access_mem addr 0x7fffc3313140, val 102b45ee8, offset 2288
        unwind: '':ip = 0x102b8788f (0x1e788f)
        failed: got unresolved address 0x102b8788f
        unwind: failed with 'no error'
        got wrong number of stack entries 0 != 8
        test child finished with -1
        ---- end ----
        Test dwarf unwind: FAILED!
      
      We expect to resolve test__dwarf_unwind as the last symbol, but that
      function can be optimized away:
      
        $ objdump -tT /usr/bin/perf | grep dwarf_unwind
        000000000083b018 g    DO .data	0000000000000040  Base        tests__dwarf_unwind
        00000000001e7750 g    DF .text	0000000000000068  Base        0x60 test_dwarf_unwind__krava_1
        00000000001e76e0 g    DF .text	0000000000000068  Base        0x60 test_dwarf_unwind__krava_2
        00000000001e7620 g    DF .text	00000000000000b4  Base        0x60 test_dwarf_unwind__krava_3
        00000000001e74f0 g    DF .text	0000000000000128  Base        0x60 test_dwarf_unwind__compare
        00000000001e7350 g    DF .text	000000000000019c  Base        0x60 test_dwarf_unwind__thread
        000000000083b000 g    DO .data	0000000000000018  Base        suite__dwarf_unwind
      
      Fix this similar to commit fdf7c49c
      
       ("perf tests: Fix dwarf
      unwind for stripped binaries") by marking the function as a global and
      adding the 'noinline' attribute to it.
      
      With this patch:
      
        $ objdump -tT perf | grep dwarf_unwind
        000000000083b018 g    DO .data	0000000000000040  Base        tests__dwarf_unwind
        00000000001e80f0 g    DF .text	0000000000000068  Base        0x60 test_dwarf_unwind__krava_1
        00000000001e8080 g    DF .text	0000000000000068  Base        0x60 test_dwarf_unwind__krava_2
        00000000001e7fc0 g    DF .text	00000000000000b4  Base        0x60 test_dwarf_unwind__krava_3
        00000000001e7e90 g    DF .text	0000000000000128  Base        0x60 test_dwarf_unwind__compare
        00000000001e7cf0 g    DF .text	000000000000019c  Base        0x60 test_dwarf_unwind__thread
        00000000001e8160 g    DF .text	0000000000000248  Base        0x60 test__dwarf_unwind
        000000000083b000 g    DO .data	0000000000000018  Base        suite__dwarf_unwind
        $ ./perf test 74
         74: Test dwarf unwind                                               : Ok
      
      Reported-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Link: http://lore.kernel.org/lkml/20230125123442.107156-1-naveen.n.rao@linux.vnet.ibm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dfadf8b3
  3. Jan 28, 2023
    • Ian Rogers's avatar
      perf buildid: Avoid copy of uninitialized memory · 22e06e68
      Ian Rogers authored
      
      
      build_id__init() only copies the buildid data up to size leaving the
      rest of the data array uninitialized. Copying the full array during
      synthesis means the written event contains uninitialized memory.
      
      Ensure the size is less that the buffer size and only copy the bytes
      that were initialized. This was detected by the Clang/LLVM memory
      sanitizer.
      
      v2. Avoids the potential for copying too much as suggested by Arnaldo.
      
      Suggested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.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: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      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: Stephane Eranian <eranian@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230120185828.43231-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      22e06e68
    • James Clark's avatar
      perf mem/c2c: Document that SPE is used for mem and c2c on ARM · 86569c0a
      James Clark authored
      
      
      Setup is non-trivial so also link to the full SPE docs.
      
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-perf-users@vger.kernel.or
      Link: https://lore.kernel.org/r/20230124145929.557891-1-james.clark@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      86569c0a
    • James Clark's avatar
      perf cs-etm: Improve missing sink warning message · 6bc75b4c
      James Clark authored
      
      
      Make the sink error message more similar to the event error message that
      reminds about missing kernel support. The available sinks are also
      determined by the hardware so mention that too.
      
      Also, usually it's not necessary to specify the sink, so add that as a
      hint.
      
      Now the error for a made up sink looks like this:
      
        $ perf record -e cs_etm/@abc/
        Couldn't find sink "abc" on event cs_etm/@abc/.
        Missing kernel or device support?
      
        Hint: An appropriate sink will be picked automatically if one isn't is specified.
      
      For any error other than ENOENT, the same message as before is
      displayed.
      
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Suggested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/r/ec7502e6-b406-3997-c2a5-24f98e5c4854@arm.com
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230124110220.460551-1-james.clark@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6bc75b4c
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Add Ian Rogers to MAINTAINERS as a reviewer · 0b58d89b
      Arnaldo Carvalho de Melo authored
      
      
      Ian has been reviewing perf tooling patches consistently for a long
      time, so lets reflect that in the MAINTAINERS file so that contributors
      add him to the CC list in patch submissions.
      
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0b58d89b
  4. Jan 23, 2023
    • Athira Rajeev's avatar
      perf test buildid: Fix shell string substitutions · f1942108
      Athira Rajeev authored
      
      
      The perf test named “build id cache operations” skips with below error
      on some distros:
      
        <<>>
         78: build id cache operations                                       :
        test child forked, pid 111101
        WARNING: wine not found. PE binaries will not be run.
        test binaries: /tmp/perf.ex.SHA1.PKz /tmp/perf.ex.MD5.Gt3 ./tests/shell/../pe-file.exe
        DEBUGINFOD_URLS=
        Adding 4abd406f041feb4f10ecde3fc30fd0639e1a91cb /tmp/perf.ex.SHA1.PKz: Ok
        build id: 4abd406f041feb4f10ecde3fc30fd0639e1a91cb
        ./tests/shell/buildid.sh: 69: ./tests/shell/buildid.sh: Bad substitution
        test child finished with -2
        build id cache operations: Skip
        <<>>
      
      The test script "tests/shell/buildid.sh" uses some of the string
      substitution ways which are supported in bash, but not in "sh" or other
      shells. Above error on line number 69 that reports "Bad substitution"
      is:
      
        <<>>
        link=${build_id_dir}/.build-id/${id:0:2}/${id:2}
        <<>>
      
      Here the way of getting first two characters from id ie, ${id:0:2} and
      similarly expressions like ${id:2} is not recognised in "sh". So the
      line errors and instead of hitting failure, the test gets skipped as
      shown in logs.  So the syntax issue causes test not to be executed in
      such cases. Similarly usage : "${@: -1}" [ to pick last argument passed
      to a function] in “test_record” doesn’t work in all distros.
      
      Fix this by using alternative way with shell substitution to pick
      required characters from the string. Also fix the usage of “${@: -1}” to
      work in all cases.
      
      Another usage in “test_record” is:
      
        <<>>
        ${perf} record --buildid-all -o ${data} $@ &> ${log}
        <<>>
      
      This causes the 'perf record' to start in background and Results in the
      data file not being created by the time "check" function is invoked.
      Below log shows 'perf record' result getting displayed after the call to
      "check" function.
      
        <<>>
        running: perf record /tmp/perf.ex.SHA1.EAU
        build id: 4abd406f041feb4f10ecde3fc30fd0639e1a91cb
        link: /tmp/perf.debug.mLT/.build-id/4a/bd406f041feb4f10ecde3fc30fd0639e1a91cb
        failed: link /tmp/perf.debug.mLT/.build-id/4a/bd406f041feb4f10ecde3fc30fd0639e1a91cb does not exist
        test child finished with -1
        build id cache operations: FAILED!
        root@machine:~/athira/linux/tools/perf# Couldn't synthesize bpf events.
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.010 MB /tmp/perf.data.bFF ]
        <<>>
      
      Fix this by redirecting output instead of using “&” which starts the
      command in background.
      
      Reviewed-by: default avatarDavid Laight <David.Laight@ACULAB.COM>
      Signed-off-by: default avatarAthira Jajeev <atrajeev@linux.vnet.ibm.com>
      Tested-by: default avatarDisha Goel <disgoel@linux.ibm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nageswara R Sastry <rnsastry@linux.ibm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230119142719.32628-1-atrajeev@linux.vnet.ibm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f1942108
    • Diederik de Haas's avatar
      perf: Various spelling fixes · fc5d836c
      Diederik de Haas authored
      
      
      Fix various spelling errors as reported by Debian's lintian tool.
      
      "amount of times" -> "number of times"
      ocurrence -> occurrence
      upto -> up to
      
      Signed-off-by: default avatarDiederik de Haas <didi.debian@cknow.org>
      Acked-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/20230122122034.48020-1-didi.debian@cknow.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fc5d836c
    • Naveen N. Rao's avatar
      perf test: Switch basic bpf filtering test to use syscall tracepoint · 7158005b
      Naveen N. Rao authored
      BPF filtering tests can sometime fail. Running the test in verbose mode
      shows the following:
      
        $ sudo perf test 42
        42: BPF filter                                                      :
        42.1: Basic BPF filtering                                           : FAILED!
        42.2: BPF pinning                                                   : Skip
        42.3: BPF prologue generation                                       : Skip
        $ perf --version
        perf version 4.18.0-425.3.1.el8.ppc64le
        $ sudo perf test -v 42
        42: BPF filter                                                      :
        42.1: Basic BPF filtering                                           :
        --- start ---
        test child forked, pid 711060
        ...
        bpf: config 'func=do_epoll_wait' is ok
        Looking at the vmlinux_path (8 entries long)
        Using /usr/lib/debug/lib/modules/4.18.0-425.3.1.el8.ppc64le/vmlinux for symbols
        Open Debuginfo file: /usr/lib/debug/.build-id/81/56f5a07f92ccb62c5600ba0e4aacfb5f3a7534.debug
        Try to find probe point from debuginfo.
        Matched function: do_epoll_wait [4ef8cb0]
        found inline addr: 0xc00000000061dbe4
        Probe point found: __se_compat_sys_epoll_pwait+196
        found inline addr: 0xc00000000061d9f4
        Probe point found: __se_sys_epoll_pwait+196
        found inline addr: 0xc00000000061d824
        Probe point found: __se_sys_epoll_wait+36
        Found 3 probe_trace_events.
        Opening /sys/kernel/tracing//kprobe_events write=1
        ...
        BPF filter result incorrect, expected 56, got 56 samples
        test child finished with -1
        ---- end ----
        BPF filter subtest 1: FAILED!
      
      The statement above about the result being incorrect looks weird, and it
      is due to that particular perf build missing commit 3e11300c
      ("perf test: Fix bpf test sample mismatch reporting"). In reality, due
      to commit 4b04e0de
      
       ("perf test: Fix basic bpf filtering test"),
      perf expects there to be 56*3 samples.
      
      However, the number of samples we receive is going to be dependent on
      where the probes are installed, which is dependent on where
      do_epoll_wait gets inlined. On s390x, it looks like probes at all the
      inlined locations are hit. But, that is not the case on ppc64le.
      
      Fix this by switching the test to instead use the syscall tracepoint.
      This ensures that we will only ever install a single event enabling us
      to reliably determine the sample count.
      
      Reported-by: default avatarDisha Goel <disgoel@linux.vnet.ibm.com>
      Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: bpf@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20230123083224.276404-1-naveen.n.rao@linux.vnet.ibm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7158005b
    • Arnaldo Carvalho de Melo's avatar
      Merge remote-tracking branch 'torvalds/master' into perf/core · 91f67b9a
      Arnaldo Carvalho de Melo authored
      
      
      To pick fixes that went via perf/urgent.
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      91f67b9a
    • James Clark's avatar
      perf cs-etm: Ensure that Coresight timestamps don't go backwards · 5670ebf5
      James Clark authored
      
      
      There are some edge cases around estimated timestamps that can result
      in them going backwards.
      
      One is that after a discontinuity, the last used timestamp is set to 0.
      The duration of the next range is then subtracted which could result in
      an earlier timestamp than the last instruction. Fix this by not
      resetting the last timestamp used on a discontinuity, and make sure that
      new estimated timestamps are clamped to be later than that.
      
      Another case is that estimated timestamps could compound over time to
      end up being more than the next real timestamp in the trace. Fix this by
      clamping the estimates in cs_etm_decoder__do_soft_timestamp() to be no
      later than it.
      
      cs_etm_decoder__do_soft_timestamp() also updated next_cs_timestamp,
      which meant that the next real timestamp was lost and not stored
      anywhere. Fix that by only updating cs_timestamp for estimates and keep
      next_cs_timestamp untouched.
      
      Finally, use next_cs_timestamp to signify if a timestamp has been
      received previously. Because cs_timestamp has the first range
      subtracted, it could technically go to 0 which would break the logic.
      
      Testing
      =======
      
      It can be verified that timestamps don't go backwards when tracing on a
      single core with the following commands. Across multiple cores it's
      expected that timestamps are interleaved:
      
        $ perf record -e cs_etm/@tmc_etr0/k -C 4 taskset -c 4 sleep 1
        $ perf script --itrace=i1ns --ns -Fcomm,tid,pid,time,cpu,event,ip,sym,addr,symoff,flags,callindent > itrace
        $ sed 's/://g' itrace | awk -F ' ' ' { print $4 } ' | awk '{ if ($1 < prev) { print "line:" NR " " $0 } {prev=$1}}'
      
      Reported-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bharat Bhushan <bbhushan2@marvell.com>
      Cc: George Cherian <gcherian@marvell.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Linu Cherian <lcherian@marvell.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120143702.4035046-9-james.clark@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5670ebf5
    • German Gomez's avatar
      perf cs_etm: Set the time field in the synthetic samples · a7fe9a44
      German Gomez authored
      
      
      If virtual timestamps are detected, set sample time field accordingly,
      otherwise warn the user that the samples will not include accurate
      time data.
      
        | Test notes (FEAT_TRF platform)
        |
        | $ ./perf record -e cs_etm//u -a -- sleep 4
        | $ ./perf script --fields +time
        | 	    perf   422 [000]   163.375100:          1 branches:uH:                 0 [unknown] ([unknown])
        | 	    perf   422 [000]   163.375100:          1 branches:uH:      ffffb8009544 ioctl+0x14 (/lib/aarch64-linux-gnu/libc-2.27.so)
        | 	    perf   422 [000]   163.375100:          1 branches:uH:      aaaaab6bebf4 perf_evsel__run_ioctl+0x90 (/home/german/linux/tools/perf/perf)
        | [...]
        | 	    perf   422 [000]   167.393100:          1 branches:uH:      aaaaab6bda00 __xyarray__entry+0x74 (/home/german/linux/tools/perf/perf)
        | 	    perf   422 [000]   167.393099:          1 branches:uH:      aaaaab6bda0c __xyarray__entry+0x80 (/home/german/linux/tools/perf/perf)
        | 	    perf   422 [000]   167.393099:          1 branches:uH:      ffffb8009538 ioctl+0x8 (/lib/aarch64-linux-gnu/libc-2.27.so)
        |
        | The time from the first sample to the last sample is 4 seconds
      
      Now that times are converted to nanoseconds, also try to estimate the
      timestamps more accurately be dividing by some fixed value for
      instructions per ns. This prevents long ranges from being estimated
      too far in the past than would be realistic.
      
      Signed-off-by: default avatarGerman Gomez <german.gomez@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bharat Bhushan <bbhushan2@marvell.com>
      Cc: George Cherian <gcherian@marvell.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Linu Cherian <lcherian@marvell.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120143702.4035046-8-james.clark@arm.com
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a7fe9a44
    • German Gomez's avatar
      perf cs_etm: Record ts_source in AUXTRACE_INFO for ETMv4 and ETE · 2e2f7cee
      German Gomez authored
      
      
      Read the value of ts_source exposed by the driver and store it in the
      ETMv4 and ETE header. If the interface doesn't exist (such as in older
      Kernels), defaults to a safe value of -1.
      
      Signed-off-by: default avatarGerman Gomez <german.gomez@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bharat Bhushan <bbhushan2@marvell.com>
      Cc: George Cherian <gcherian@marvell.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Linu Cherian <lcherian@marvell.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120143702.4035046-7-james.clark@arm.com
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2e2f7cee
    • German Gomez's avatar
      perf cs_etm: Keep separate symbols for ETMv4 and ETE parameters · 326163c5
      German Gomez authored
      
      
      Previously, adding a new parameter at the end of ETMv4 meant adding it
      somewhere in the middle of ETE, which is not supported by the current
      header version.
      
      Reviewed-by: default avatarMike Leach <mike.leach@linaro.org>
      Signed-off-by: default avatarGerman Gomez <german.gomez@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bharat Bhushan <bbhushan2@marvell.com>
      Cc: George Cherian <gcherian@marvell.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Linu Cherian <lcherian@marvell.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120143702.4035046-6-james.clark@arm.com
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      326163c5
    • German Gomez's avatar
      perf pmu: Add function to check if a pmu file exists · c2b6a896
      German Gomez authored
      
      
      Add a utility function perf_pmu__file_exists() to check if a given pmu
      file exists in the sysfs filesystem.
      
      Signed-off-by: default avatarGerman Gomez <german.gomez@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bharat Bhushan <bbhushan2@marvell.com>
      Cc: George Cherian <gcherian@marvell.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Linu Cherian <lcherian@marvell.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120143702.4035046-5-james.clark@arm.com
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c2b6a896
    • James Clark's avatar
      perf pmu: Remove remaining duplication of bus/event_source/devices/... · 5f2c8efa
      James Clark authored
      
      
      Use the new perf_pmu__pathname_scnprintf() instead. No functional
      changes.
      
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bharat Bhushan <bbhushan2@marvell.com>
      Cc: George Cherian <gcherian@marvell.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Linu Cherian <lcherian@marvell.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120143702.4035046-4-james.clark@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5f2c8efa
    • James Clark's avatar
      perf pmu: Use perf_pmu__open_file() and perf_pmu__scan_file() · d50a79cd
      James Clark authored
      
      
      Remove some code that duplicates existing methods. Copy strings where
      const strings are required.
      
      No functional changes.
      
      Committer notes:
      
      Add a stub for erf_pmu__scan_file() in tools/perf/util/python.c not to
      drag tools/perf/util/pmu.c into the python binding.
      
      This fixes 'perf test python' at this point in this patchset.
      
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bharat Bhushan <bbhushan2@marvell.com>
      Cc: George Cherian <gcherian@marvell.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Linu Cherian <lcherian@marvell.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120143702.4035046-3-james.clark@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d50a79cd
    • James Clark's avatar
      perf pmu: Remove duplication around EVENT_SOURCE_DEVICE_PATH · f8ad6018
      James Clark authored
      
      
      The pattern for accessing EVENT_SOURCE_DEVICE_PATH is duplicated in a
      few places, so add two utility functions to cover it. Also just use
      perf_pmu__scan_file() instead of pmu_type() which already does the same
      thing.
      
      No functional changes.
      
      Reviewed-by: default avatarLeo Yan <leo.yan@linaro.org>
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarSuzuki Poulouse <suzuki.poulose@arm.com>
      Tested-by: default avatarTanmay Jagdale <tanmay@marvell.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bharat Bhushan <bbhushan2@marvell.com>
      Cc: George Cherian <gcherian@marvell.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Linu Cherian <lcherian@marvell.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sunil Kovvuri Goutham <sgoutham@marvell.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: coresight@lists.linaro.org
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://lore.kernel.org/r/20230120143702.4035046-2-james.clark@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f8ad6018
    • Ian Rogers's avatar
      perf tools: Fix foolproof typo · 4cbd5334
      Ian Rogers authored
      
      
      In the context of LBR stitching documentation.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ali Saidi <alisaidi@amazon.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: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Link: https://lore.kernel.org/r/20230119201036.156441-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4cbd5334
    • 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
    • Linus Torvalds's avatar
      Merge tag 'sched_urgent_for_v6.2_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 2475bf02
      Linus Torvalds authored
      Pull scheduler fixes from Borislav Petkov:
      
       - Make sure the scheduler doesn't use stale frequency scaling values
         when latter get disabled due to a value error
      
       - Fix a NULL pointer access on UP configs
      
       - Use the proper locking when updating CPU capacity
      
      * tag 'sched_urgent_for_v6.2_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/aperfmperf: Erase stale arch_freq_scale values when disabling frequency invariance readings
        sched/core: Fix NULL pointer access fault in sched_setaffinity() with non-SMP configs
        sched/fair: Fixes for capacity inversion detection
        sched/uclamp: Fix a uninitialized variable warnings
      2475bf02
    • Linus Torvalds's avatar
      Merge tag 'edac_urgent_for_v6.2_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras · ab2f4087
      Linus Torvalds authored
      Pull EDAC fixes from Borislav Petkov:
      
       - Respect user-supplied polling value in the EDAC device code
      
       - Fix a use-after-free issue in qcom_edac
      
      * tag 'edac_urgent_for_v6.2_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras:
        EDAC/qcom: Do not pass llcc_driv_data as edac_device_ctl_info's pvt_info
        EDAC/device: Respect any driver-supplied workqueue polling value
      ab2f4087
    • Linus Torvalds's avatar
      Merge tag 'perf_urgent_for_v6.2_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 2b299a1c
      Linus Torvalds authored
      Pull perf fix from Borislav Petkov:
      
       - Add Emerald Rapids model support to more perf machinery
      
      * tag 'perf_urgent_for_v6.2_rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        perf/x86/intel/cstate: Add Emerald Rapids
        perf/x86/intel: Add Emerald Rapids
      2b299a1c
    • Linus Torvalds's avatar
      Merge tag 'gfs2-v6.2-rc4-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2 · 3c006ad7
      Linus Torvalds authored
      Pull gfs2 writepage fix from Andreas Gruenbacher:
      
       - Fix a regression introduced by commit "gfs2: stop using
         generic_writepages in gfs2_ail1_start_one".
      
      * tag 'gfs2-v6.2-rc4-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2:
        Revert "gfs2: stop using generic_writepages in gfs2_ail1_start_one"
      3c006ad7
  5. Jan 22, 2023
    • Andreas Gruenbacher's avatar
      Revert "gfs2: stop using generic_writepages in gfs2_ail1_start_one" · 95ecbd0f
      Andreas Gruenbacher authored
      Commit b2b0a5e9 switched from generic_writepages() to
      filemap_fdatawrite_wbc() in gfs2_ail1_start_one() on the path to
      replacing ->writepage() with ->writepages() and eventually eliminating
      the former.  Function gfs2_ail1_start_one() is called from
      gfs2_log_flush(), our main function for flushing the filesystem log.
      
      Unfortunately, at least as implemented today, ->writepage() and
      ->writepages() are entirely different operations for journaled data
      inodes: while the former creates and submits transactions covering the
      data to be written, the latter flushes dirty buffers out to disk.
      
      With gfs2_ail1_start_one() now calling ->writepages(), we end up
      creating filesystem transactions while we are in the course of a log
      flush, which immediately deadlocks on the sdp->sd_log_flush_lock
      semaphore.
      
      Work around that by going back to how things used to work before commit
      b2b0a5e9 for now; figuring out a superior solution will take time we
      don't have available right now.  However ...
      
      Since the removal of generic_writepages() is imminent, open-code it
      here.  We're already inside a blk_start_plug() ...  blk_finish_plug()
      section here, so skip that part of the original generic_writepages().
      
      This reverts commit b2b0a5e9
      
      .
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Acked-by: default avatarChristoph Hellwig <hch@lst.de>
      95ecbd0f
    • Linus Torvalds's avatar
      Linux 6.2-rc5 · 2241ab53
      Linus Torvalds authored
      2241ab53