1. 20 Jun, 2024 13 commits
  2. 16 Jun, 2024 5 commits
  3. 14 Jun, 2024 5 commits
  4. 10 Jun, 2024 1 commit
    • Ian Rogers's avatar
      perf evsel: Refactor tool events · 6828d692
      Ian Rogers authored
      Tool events unnecessarily open a dummy perf event which is useless
      even with `perf record` which will still open a dummy event. Change
      the behavior of tool events so:
      
       - duration_time - call `rdclock` on open and then report the count as
         a delta since the start in evsel__read_counter. This moves code out
         of builtin-stat making it more general purpose.
      
       - user_time/system_time - open the fd as either `/proc/pid/stat` or
         `/proc/stat` for cases like system wide. evsel__read_counter will
         read the appropriate field out of the procfs file. These values
         were previously supplied by wait4, if the procfs read fails then
         the wait4 values are used, assuming the process/thread terminated.
         By reading user_time and system_time this way, interval mode, per
         PID and per CPU can be supported although there are restrictions
         given what the files provide (e.g. per PID can't be combined with
         per CPU).
      
      Opening any of the tool events for `perf record` is changed to return
      invalid.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarWeilin Wang <weilin.wang@intel.com>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: Ze Gao <zegao2021@gmail.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Leo Yan <leo.yan@linux.dev>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20240503232849.17752-1-irogers@google.com
      6828d692
  5. 07 Jun, 2024 7 commits
  6. 06 Jun, 2024 1 commit
    • Clément Le Goffic's avatar
      perf: parse-events: Fix compilation error while defining DEBUG_PARSER · 9aa61d8e
      Clément Le Goffic authored
      Compiling perf tool with 'DEBUG_PARSER=1' leads to errors:
      
      $> make -C tools/perf PARSER_DEBUG=1 NO_LIBTRACEEVENT=1
      ...
        CC      util/expr-flex.o
        CC      util/expr.o
      util/parse-events.c:33:12: error: redundant redeclaration of ‘parse_events_debug’ [-Werror=redundant-decls]
         33 | extern int parse_events_debug;
            |            ^~~~~~~~~~~~~~~~~~
      In file included from util/parse-events.c:18:
      util/parse-events-bison.h:43:12: note: previous declaration of ‘parse_events_debug’ with type ‘int’
         43 | extern int parse_events_debug;
            |            ^~~~~~~~~~~~~~~~~~
      util/expr.c:27:12: error: redundant redeclaration of ‘expr_debug’ [-Werror=redundant-decls]
         27 | extern int expr_debug;
            |            ^~~~~~~~~~
      In file included from util/expr.c:11:
      util/expr-bison.h:43:12: note: previous declaration of ‘expr_debug’ with type ‘int’
         43 | extern int expr_debug;
            |            ^~~~~~~~~~
      cc-1: all warnings being treated as errors
      
      Remove extern declaration from the parse-envents.c file as there is a
      conflict with the ones generated using bison and yacc tools from the file
      parse-events.[ly].
      Signed-off-by: default avatarClément Le Goffic <clement.legoffic@foss.st.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: John Garry <john.g.garry@oracle.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20240605140453.614862-1-clement.legoffic@foss.st.com
      9aa61d8e
  7. 05 Jun, 2024 1 commit
  8. 04 Jun, 2024 2 commits
  9. 30 May, 2024 5 commits
    • Ian Rogers's avatar
      perf top: Allow filters on events · af752016
      Ian Rogers authored
      Allow filters to be added to perf top events. One use is to workaround
      issues with:
      ```
      $ perf top --uid="$(id -u)"
      ```
      which tries to scan /proc find processes belonging to the uid and can
      fail in such a pid terminates between the scan and the
      perf_event_open reporting:
      ```
      Error:
      The sys_perf_event_open() syscall returned with 3 (No such process) for event (cycles:P).
      /bin/dmesg | grep -i perf may provide additional information.
      ```
      A similar filter:
      ```
      $ perf top -e cycles:P --filter "uid == $(id -u)"
      ```
      doesn't fail this way.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: bpf@vger.kernel.org
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20240524205227.244375-4-irogers@google.com
      af752016
    • Ian Rogers's avatar
      perf bpf filter: Add uid and gid terms · d92aa899
      Ian Rogers authored
      Allow the BPF filter to use the uid and gid terms determined by the
      bpf_get_current_uid_gid BPF helper. For example, the following will
      record the cpu-clock event system wide discarding samples that don't
      belong to the current user.
      
      $ perf record -e cpu-clock --filter "uid == $(id -u)" -a sleep 0.1
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: bpf@vger.kernel.org
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20240524205227.244375-3-irogers@google.com
      d92aa899
    • Ian Rogers's avatar
      perf bpf filter: Give terms their own enum · 63b9cbd7
      Ian Rogers authored
      Give the term types their own enum so that additional terms can be
      added that don't correspond to a PERF_SAMPLE_xx flag. The term values
      are numerically ascending rather than bit field positions, this means
      they need translating to a PERF_SAMPLE_xx bit field in certain places
      using a shift.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: bpf@vger.kernel.org
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20240524205227.244375-2-irogers@google.com
      63b9cbd7
    • Ian Rogers's avatar
      tools api io: Move filling the io buffer to its own function · d163d602
      Ian Rogers authored
      In general a read fills 4kb so filling the buffer is a 1 in 4096
      operation, move it out of the io__get_char function to avoid some
      checking overhead and to better hint the function is good to inline.
      
      For perf's IO intensive internal (non-rigorous) benchmarks there's a
      small improvement to kallsyms-parsing with a default build.
      
      Before:
      ```
      $ perf bench internals all
      Computing performance of single threaded perf event synthesis by
      synthesizing events on the perf process itself:
        Average synthesis took: 146.322 usec (+- 0.305 usec)
        Average num. events: 61.000 (+- 0.000)
        Average time per event 2.399 usec
        Average data synthesis took: 145.056 usec (+- 0.155 usec)
        Average num. events: 329.000 (+- 0.000)
        Average time per event 0.441 usec
      
        Average kallsyms__parse took: 162.313 ms (+- 0.599 ms)
      ...
      Computing performance of sysfs PMU event scan for 100 times
        Average core PMU scanning took: 53.720 usec (+- 7.823 usec)
        Average PMU scanning took: 375.145 usec (+- 23.974 usec)
      ```
      After:
      ```
      $ perf bench internals all
      Computing performance of single threaded perf event synthesis by
      synthesizing events on the perf process itself:
        Average synthesis took: 127.829 usec (+- 0.079 usec)
        Average num. events: 61.000 (+- 0.000)
        Average time per event 2.096 usec
        Average data synthesis took: 133.652 usec (+- 0.101 usec)
        Average num. events: 327.000 (+- 0.000)
        Average time per event 0.409 usec
      
        Average kallsyms__parse took: 150.415 ms (+- 0.313 ms)
      ...
      Computing performance of sysfs PMU event scan for 100 times
        Average core PMU scanning took: 47.790 usec (+- 1.178 usec)
        Average PMU scanning took: 376.945 usec (+- 23.683 usec)
      ```
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20240519181716.4088459-1-irogers@google.com
      d163d602
    • Changbin Du's avatar
      perf trace beauty: Always show mmap prot even though PROT_NONE · f975c13d
      Changbin Du authored
      PROT_NONE is also useful information, so do not omit the mmap prot even
      though it is 0. syscall_arg__scnprintf_mmap_prot() could print PROT_NONE
      for prot 0.
      
      Before: PROT_NONE is not shown.
      $ sudo perf trace -e syscalls:sys_enter_mmap --filter prot==0  -- ls
           0.000 ls/2979231 syscalls:sys_enter_mmap(len: 4220888, flags: PRIVATE|ANONYMOUS)
      
      After: PROT_NONE is displayed.
      $ sudo perf trace -e syscalls:sys_enter_mmap --filter prot==0  -- ls
           0.000 ls/2975708 syscalls:sys_enter_mmap(len: 4220888, prot: NONE, flags: PRIVATE|ANONYMOUS)
      Signed-off-by: default avatarChangbin Du <changbin.du@huawei.com>
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20240522033542.1359421-3-changbin.du@huawei.com
      f975c13d