1. 01 Aug, 2024 20 commits
    • Namhyung Kim's avatar
      perf mem: Rework command option handling · 35b38a71
      Namhyung Kim authored
      Split the common option and ones for record or report.  Otherwise -U in
      the record option cannot be used because it clashes with in the common
      (or report) option.  Also rename report_events() to __cmd_report() to
      follow the convention and to be sync with the record part.
      
      Also set the flag PARSE_OPT_STOP_AT_NON_OPTION for the common option so
      that it can show the help message in the subcommand like below:
      
        $ perf mem record -h
      
         Usage: perf mem record [<options>] [<command>]
            or: perf mem record [<options>] -- <command> [<options>]
      
            -C, --cpu <cpu>       list of cpus to profile
            -e, --event <event>   event selector. use 'perf mem record -e list' to list available events
            -f, --force           don't complain, do it
            -K, --all-kernel      collect only kernel level data
            -p, --phys-data       Record/Report sample physical addresses
            -t, --type <type>     memory operations(load,store) Default load,store
            -U, --all-user        collect only user level data
            -v, --verbose         be more verbose (show counter open errors, etc)
                --data-page-size  Record/Report sample data address page size
                --ldlat <n>       mem-loads latency
      
      Cc: Aditya Gupta <adityag@linux.ibm.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20240731235505.710436-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      35b38a71
    • Namhyung Kim's avatar
      perf mem: Free the allocated sort string, fixing a leak · 3da209bb
      Namhyung Kim authored
      The get_sort_order() returns either a new string (from strdup) or NULL
      but it never gets freed.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Fixes: 2e7f5450 ("perf mem: Factor out a function to generate sort order")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20240731235505.710436-3-namhyung@kernel.org
      [ Added Fixes tag ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3da209bb
    • Namhyung Kim's avatar
      perf hist: Correct hist_entry->mem_info refcounts · 96465e01
      Namhyung Kim authored
      The 'struct mem_info' is created by iter_prepare_mem_entry() at the
      beginning and destroyed by iter_finish_mem_entry() at the end.
      
      So if it's used in a new hist_entry, it should be cloned.
      
      Simplify (hopefully) the logic by adding some helper functions and by
      not holding the refcount in the temporary entry.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20240731235505.710436-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      96465e01
    • Ian Rogers's avatar
      perf python: Remove PYTHON_PERF ifdefs · 7c5dd51b
      Ian Rogers authored
      When perf code was compiled one way for the binary and another for the
      python module, the PYTHON_PERF ifdef was used to remove some code from
      the python module.
      
      Since switching to building the perf code as a series of libraries, with
      the same libraries being used for the python module, the ifdefs became
      unused as PYTHON_PERF is never defined. As such remove the ifdefs.
      
      Fixes: 9dabf400 ("perf python: Switch module to linking libraries from building source")
      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: James Clark <james.clark@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      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/20240731230005.12295-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7c5dd51b
    • Ian Rogers's avatar
      perf jevents: Autogenerate empty-pmu-events.c · 0fe881f1
      Ian Rogers authored
      empty-pmu-events.c exists so that builds may occur without python
      being installed on a system. Manually updating empty-pmu-events.c to
      be in sync with jevents.py is a pain, let's use jevents.py to generate
      empty-pmu-events.c.
      
      1) change jevents.py so that an arch and model of none cause
         generation of a pmu-events.c without any json. Add a SPDX and
         autogenerated warning to the start of the file.
      
      2) change Build so that if a generated pmu-events.c for arch none and
         model none doesn't match empty-pmu-events.c the build fails with a
         cat of the differences. Update Makefile.perf to clean up the files
         used for this.
      
      3) update empty-pmu-events.c to match the output of jevents.py with
         arch and mode of none.
      
      Committer notes:
      
      The firtst paragraph is confusing, so I asked and Ian further clarified:
      
       ---
      The requirement for python hasn't changed.
      
      Case 1: no python or NO_JEVENTS=1
      Build happens using empty-pmu-events.c that is checked in, no python
      is required.
      
      Case 2: python
      pmu-events.c is created by jevents.py (requiring python) and then built.
      This change adds a step where the empty-pmu-events.c is created using
      jevents.py and that file is diffed against the checked in version.
      
      This stops the checked in empty-pmu-events.c diverging if changes are
      made to jevents.py. If the diff causes the build to fail then you just
      copy the diff empty-pmu-events.c over the checked in one.
       ---
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.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: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oliver Sang <oliver.sang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Philip Li <philip.li@intel.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Weilin Wang <weilin.wang@intel.com>
      Cc: Xu Yang <xu.yang_2@nxp.com>
      Link: https://lore.kernel.org/r/20240730191744.3097329-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0fe881f1
    • Arnaldo Carvalho de Melo's avatar
      perf bpf: Move BPF disassembly routines to separate file to avoid clash with capstone bpf headers · ea59b70a
      Arnaldo Carvalho de Melo authored
      There is a clash of the libbpf and capstone libraries, that ends up
      with:
      
        In file included from /usr/include/capstone/capstone.h:325,
                         from util/disasm.c:1513:
        /usr/include/capstone/bpf.h:94:14: error: ‘bpf_insn’ defined as wrong kind of tag
           94 | typedef enum bpf_insn {
      
      So far we're just trying to avoid this by not having both headers
      included in the same .c or .h file, do it one more time by moving the
      BPF diassembly routines from util/disasm.c to util/disasm_bpf.c.
      
      This is only being hit when building with BUILD_NONDISTRO=1, i.e.
      building with binutils-devel, that isn't the in the default build due to
      a licencing clash. We need to reimplement what is now isolated in
      util/disasm_bpf.c using some other library to have BPF annotation
      feature that now only is available with BUILD_NONDISTRO=1.
      
      Fixes: 6d17edc1 ("perf annotate: Use libcapstone to disassemble")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZqpUSKPxMwaQKORr@x1Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ea59b70a
    • Namhyung Kim's avatar
      perf test: Update sample filtering test · 9cb3549b
      Namhyung Kim authored
      Now it can run the BPF filtering test with normal user if the BPF
      objects are pinned by 'sudo perf record --setup-filter pin'.  Let's
      update the test case to verify the behavior.  It'll skip the test if the
      filter check is failed from a normal user, but it shows a message how to
      set up the filters.
      
      First, run the test as a normal user and it fails.
      
        $ perf test -vv filtering
         95: perf record sample filtering (by BPF) tests:
        --- start ---
        test child forked, pid 425677
        Checking BPF-filter privilege
        try 'sudo perf record --setup-filter pin' first.       <<<--- here
        bpf-filter test [Skipped permission]
        ---- end(-2) ----
         95: perf record sample filtering (by BPF) tests                     : Skip
      
      According to the message, run the perf record command to pin the BPF
      objects.
      
        $ sudo perf record --setup-filter pin
      
      And re-run the test as a normal user.
      
        $ perf test -vv filtering
         95: perf record sample filtering (by BPF) tests:
        --- start ---
        test child forked, pid 424486
        Checking BPF-filter privilege
        Basic bpf-filter test
        Basic bpf-filter test [Success]
        Failing bpf-filter test
        Error: task-clock event does not have PERF_SAMPLE_CPU
        Failing bpf-filter test [Success]
        Group bpf-filter test
        Error: task-clock event does not have PERF_SAMPLE_CPU
        Error: task-clock event does not have PERF_SAMPLE_CODE_PAGE_SIZE
        Group bpf-filter test [Success]
        ---- end(0) ----
         95: perf record sample filtering (by BPF) tests                     : Ok
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20240703223035.2024586-9-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9cb3549b
    • Namhyung Kim's avatar
      perf record: Add --setup-filter option · 3dee4b83
      Namhyung Kim authored
      To allow BPF filters for unprivileged users it needs to pin the BPF
      objects to BPF-fs first.  Let's add a new option to pin and unpin the
      objects easily.  I'm not sure 'perf record' is a right place to do this
      but I don't have a better idea right now.
      
        $ sudo perf record --setup-filter pin
      
      The above command would pin BPF program and maps for the filter when the
      system has BPF-fs (usually at /sys/fs/bpf/).  To unpin the objects,
      users can run the following command (as root).
      
        $ sudo perf record --setup-filter unpin
      
      Committer testing:
      
        root@number:~# perf record --setup-filter pin
        root@number:~# ls -la /sys/fs/bpf/perf_filter/
        total 0
        drwxr-xr-x. 2 root root 0 Jul 31 10:43 .
        drwxr-xr-t. 3 root root 0 Jul 31 10:43 ..
        -rw-rw-rw-. 1 root root 0 Jul 31 10:43 dropped
        -rw-rw-rw-. 1 root root 0 Jul 31 10:43 filters
        -rwxrwxrwx. 1 root root 0 Jul 31 10:43 perf_sample_filter
        -rw-rw-rw-. 1 root root 0 Jul 31 10:43 pid_hash
        -rw-------. 1 root root 0 Jul 31 10:43 sample_f_rodata
        root@number:~# ls -la /sys/fs/bpf/perf_filter/perf_sample_filter
        -rwxrwxrwx. 1 root root 0 Jul 31 10:43 /sys/fs/bpf/perf_filter/perf_sample_filter
        root@number:~#
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20240703223035.2024586-8-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3dee4b83
    • Namhyung Kim's avatar
      perf record: Fix a potential error handling issue · 73bf63a4
      Namhyung Kim authored
      The evlist is allocated at the beginning of cmd_record().  Also free-ing
      thread masks should be paired with record__init_thread_masks() which is
      called right before __cmd_record().
      
      Let's change the order of these functions to release the resources
      correctly in case of errors.  This is maybe fine as the process exits,
      but it might be a problem if it manages some system-wide resources that
      live longer than the process.
      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: KP Singh <kpsingh@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20240703223035.2024586-7-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      73bf63a4
    • Namhyung Kim's avatar
      perf bpf-filter: Support separate lost counts for each filter · 1ec6fd34
      Namhyung Kim authored
      As the BPF filter is shared between other processes, it should have its
      own counter for each invocation.  Add a new array map (lost_count) to
      save the count using the same index as the filter.  It should clear the
      count before running the filter.
      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: KP Singh <kpsingh@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20240703223035.2024586-6-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1ec6fd34
    • Namhyung Kim's avatar
      perf bpf-filter: Support pin/unpin BPF object · 0715f65e
      Namhyung Kim authored
      And use the pinned objects for unprivileged users to profile their own
      tasks.  The BPF objects need to be pinned in the BPF-fs by root first
      and it'll be handled in the later patch.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20240703223035.2024586-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0715f65e
    • Namhyung Kim's avatar
      perf bpf-filter: Split per-task filter use case · eb1693b1
      Namhyung Kim authored
      If the target is a list of tasks, it can use a shared hash map for
      filter expressions.  The key of the filter map is an integer index like
      in an array.  A separate pid_hash map is added to get the index for the
      filter map using the tgid.
      
      For system-wide mode including per-cpu or per-user targets are handled
      by the single entry map like before.
      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: KP Singh <kpsingh@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20240703223035.2024586-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      eb1693b1
    • Namhyung Kim's avatar
      perf bpf-filter: Pass 'target' to perf_bpf_filter__prepare() · 966854e7
      Namhyung Kim authored
      This is needed to prepare target-specific actions in the later patch.
      We want to reuse the pinned BPF program and map for regular users to
      profile their own processes.
      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: KP Singh <kpsingh@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20240703223035.2024586-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      966854e7
    • Namhyung Kim's avatar
      perf bpf-filter: Make filters map a single entry hashmap · edb08cdd
      Namhyung Kim authored
      And the value is now an array.  This is to support multiple filter
      entries in the map later.
      
      No functional changes intended.
      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: KP Singh <kpsingh@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20240703223035.2024586-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      edb08cdd
    • Ian Rogers's avatar
      perf jevents: Use name for special find value (PMU_EVENTS__NOT_FOUND) · 0f2c0400
      Ian Rogers authored
      -1000 was used as a special value added in Commit 3d504549 ("perf
      pmu-events: Add pmu_events_table__find_event()") to show that 1 table
      lacked a PMU/event but that didn't terminate the search in other
      tables.
      
      Add a new constant PMU_EVENTS__NOT_FOUND for this value and use it.
      Reviewed-by: default avatarJohn Garry <john.g.garry@oracle.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: Ingo Molnar <mingo@redhat.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oliver Sang <oliver.sang@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Philip Li <philip.li@intel.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Weilin Wang <weilin.wang@intel.com>
      Cc: Xu Yang <xu.yang_2@nxp.com>
      Link: https://lore.kernel.org/r/20240730191744.3097329-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0f2c0400
    • Tiezhu Yang's avatar
      perf list: Give clues if failed to open tracing events directory · b48543c4
      Tiezhu Yang authored
      When executing the command "perf list", I met "Error: failed to open
      tracing events directory" twice, the first reason is that there is no
      "/sys/kernel/tracing/events" directory due to it does not enable the
      kernel tracing infrastructure with CONFIG_FTRACE, the second reason
      is that there is no root privileges.
      
      Add the error string to tell the users what happened and what should
      to do, and also call put_tracing_file() to free events_path a little
      later to avoid messy code in the error message.
      
      At the same time, just remove the redundant "/" of the file path in
      the function get_tracing_file(), otherwise it shows something like
      "/sys/kernel/tracing//events".
      
      Before:
      
        $ ./perf list
        Error: failed to open tracing events directory
      
      After:
      
      (1) Without CONFIG_FTRACE
      
        $ ./perf list
        Error: failed to open tracing events directory
        /sys/kernel/tracing/events: No such file or directory
      
      (2) With CONFIG_FTRACE but no root privileges
      
        $ ./perf list
        Error: failed to open tracing events directory
        /sys/kernel/tracing/events: Permission denied
      
      Committer testing:
      
      Redirect stdout to null to quickly test the patch:
      
      Before:
      
        $ perf list > /dev/null
        Error: failed to open tracing events directory
        $
      
      After:
      
        $ perf list > /dev/null
        Error: failed to open tracing events directory
        /sys/kernel/tracing/events: Permission denied
        $
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/lkml/20240730062301.23244-3-yangtiezhu@loongson.cnSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b48543c4
    • Tiezhu Yang's avatar
      perf tools: Fix wrong message when running "make JOBS=1" · 839b1832
      Tiezhu Yang authored
      There is only one job when running "make JOBS=1", it should
      print "sequential build" rather than "parallel build".
      
      Before:
      
      $ cd tools/perf && make JOBS=1
        BUILD:   Doing 'make -j1' parallel build
      
      After:
      
      $ cd tools/perf && make JOBS=1
        BUILD:   Doing 'make -j1' sequential build
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/lkml/20240730062301.23244-2-yangtiezhu@loongson.cnSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      839b1832
    • Charlie Jenkins's avatar
      libperf: Add gitignore · d261f9eb
      Charlie Jenkins authored
      Ignore files that are generated by libperf and libperf tests.
      Signed-off-by: default avatarCharlie Jenkins <charlie@rivosinc.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: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/lkml/20240729-libperf_gitignore-v1-1-1c70dd98edf9@rivosinc.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d261f9eb
    • Leo Yan's avatar
      perf arm-spe: Support multiple Arm SPE events · 1635bdca
      Leo Yan authored
      As the flag 'auxtrace' has been set for Arm SPE events, now it is ready
      to use evsel__is_aux_event() to check if an event is AUX trace event or
      not. Use this function to replace the old checking for only the first
      Arm SPE event.
      Signed-off-by: default avatarLeo Yan <leo.yan@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: James Clark <james.clark@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc:  <coresight@lists.linaro.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc:  <linux-perf-users@vger.kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1635bdca
    • Leo Yan's avatar
      perf arm-spe: Extract evsel setting up · ccd6fcda
      Leo Yan authored
      The evsel for Arm SPE PMU needs to be set up. Extract the setting up
      into a function arm_spe_setup_evsel().
      Signed-off-by: default avatarLeo Yan <leo.yan@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: James Clark <james.clark@linaro.org>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc:  <coresight@lists.linaro.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc:  <linux-perf-users@vger.kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ccd6fcda
  2. 31 Jul, 2024 20 commits