1. 06 Dec, 2023 4 commits
  2. 05 Dec, 2023 9 commits
  3. 04 Dec, 2023 5 commits
  4. 30 Nov, 2023 4 commits
    • Ian Rogers's avatar
      tools api fs: Avoid reading whole file for a 1 byte bool · f8846a1a
      Ian Rogers authored
      sysfs__read_bool() used the first byte from a fully read file into a
      string. It then looked at the first byte's value. Avoid doing this and
      just read the first byte.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Guilherme Amadio <amadio@gentoo.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Vincent Whitchurch <vincent.whitchurch@axis.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20231127220902.1315692-6-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f8846a1a
    • Ian Rogers's avatar
      tools api fs: Switch filename__read_str to use io.h · b6a15269
      Ian Rogers authored
      filename__read_str() has its own string reading code that allocates
      memory before reading into it. The memory allocated is sized at BUFSIZ
      that is 8kb. Most strings are short and so most of this 8kb is wasted.
      
      Refactor io__getline(), as io__getdelim(), so that the newline character
      can be configurable and ignored in the case of filename__read_str().
      
      Code like build_caches_for_cpu() in perf's header.c will read many strings
      and hold them in a data structure, in this case multiple strings per
      cache level per CPU.
      
      Using io.h's io__getline() avoids the wasted memory as strings are
      temporarily read into a buffer on the stack before being copied to a
      buffer that grows 128 bytes at a time and is never sized larger than the
      string.
      
      For a 16 hyperthread system the memory consumption of "perf record
      true" is reduced by 180kb, primarily through saving memory when
      reading the cache information.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Guilherme Amadio <amadio@gentoo.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Vincent Whitchurch <vincent.whitchurch@axis.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20231127220902.1315692-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b6a15269
    • Ian Rogers's avatar
      libperf: Lazily allocate/size mmap event copy · 366efbff
      Ian Rogers authored
      The event copy in the mmap is used to have storage to read an event. Not
      all users of mmaps read the events, such as perf record. The amount of
      buffer was also statically set to PERF_SAMPLE_MAX_SIZE rather than the
      amount necessary from the header's event size.
      
      Switch to a model where the event_copy is reallocated if too small to
      the event's size. This adds the potential for the event to move, so if a
      copy of the event pointer were stored it could be broken. All the
      current users do:
      
        while(event = perf_mmap__read_event()) { ... }
      
      and so they would be broken due to the event being overwritten if they
      had stored the pointer. Manual inspection and address sanitizer testing
      also shows the event pointer not being stored.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Guilherme Amadio <amadio@gentoo.org>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Vincent Whitchurch <vincent.whitchurch@axis.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20231127220902.1315692-3-irogers@google.com
      [ Replace two lines with equivalent zfree(&map->event_copy) ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      366efbff
    • Arnaldo Carvalho de Melo's avatar
      libapi: Add missing linux/types.h header to get the __u64 type on io.h · af76b2de
      Arnaldo Carvalho de Melo authored
      There are functions using __u64, so we need to have the linux/types.h
      header otherwise we'll break when its not included before api/io.h.
      
      Fixes: e95770af ("tools api: Add a lightweight buffered reading api")
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZWjDPL+IzPPsuC3X@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      af76b2de
  5. 29 Nov, 2023 3 commits
    • Likhitha Korrapati's avatar
      perf test record+probe_libc_inet_pton: Fix call chain match on powerpc · 72a2a0a4
      Likhitha Korrapati authored
      The perf test "probe libc's inet_pton & backtrace it with ping" fails on
      powerpc as below:
      
        # perf test -v "probe libc's inet_pton & backtrace it with
        ping"
         85: probe libc's inet_pton & backtrace it with ping                 :
        --- start ---
        test child forked, pid 96028
        ping 96056 [002] 127271.101961: probe_libc:inet_pton: (7fffa1779a60)
        7fffa1779a60 __GI___inet_pton+0x0 (/usr/lib64/glibc-hwcaps/power10/libc.so.6)
        7fffa172a73c getaddrinfo+0x121c (/usr/lib64/glibc-hwcaps/power10/libc.so.6)
        FAIL: expected backtrace entry
        "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\(/usr/lib64/glibc-hwcaps/power10/libc.so.6\)$"
        got "7fffa172a73c getaddrinfo+0x121c (/usr/lib64/glibc-hwcaps/power10/libc.so.6)"
        test child finished with -1
        ---- end ----
        probe libc's inet_pton & backtrace it with ping: FAILED!
      
      This test installs a probe on libc's inet_pton function, which will use
      uprobes and then uses perf trace on a ping to localhost. It gets 3
      levels deep backtrace and checks whether it is what we expected or not.
      
      The test started failing from RHEL 9.4 where as it works in previous
      distro version (RHEL 9.2). Test expects gaih_inet function to be part of
      backtrace. But in the glibc version (2.34-86) which is part of distro
      where it fails, this function is missing and hence the test is failing.
      
      From nm and ping command output we can confirm that gaih_inet function
      is not present in the expected backtrace for glibc version glibc-2.34-86
      
        [root@xxx perf]# nm /usr/lib64/glibc-hwcaps/power10/libc.so.6 | grep gaih_inet
        00000000001273e0 t gaih_inet_serv
        00000000001cd8d8 r gaih_inet_typeproto
      
        [root@xxx perf]# perf script -i /tmp/perf.data.6E8
        ping  104048 [000] 128582.508976: probe_libc:inet_pton: (7fff83779a60)
                    7fff83779a60 __GI___inet_pton+0x0 (/usr/lib64/glibc-hwcaps/power10/libc.so.6)
                    7fff8372a73c getaddrinfo+0x121c (/usr/lib64/glibc-hwcaps/power10/libc.so.6)
                       11dc73534 [unknown] (/usr/bin/ping)
                    7fff8362a8c4 __libc_start_call_main+0x84 (/usr/lib64/glibc-hwcaps/power10/libc.so.6)
      
        FAIL: expected backtrace entry
        "gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\(/usr/lib64/glibc-hwcaps/power10/libc.so.6\)$"
        got "7fff9d52a73c getaddrinfo+0x121c (/usr/lib64/glibc-hwcaps/power10/libc.so.6)"
      
      With version glibc-2.34-60 gaih_inet function is present as part of the
      expected backtrace. So we cannot just remove the gaih_inet function from
      the backtrace.
      
        [root@xxx perf]# nm /usr/lib64/glibc-hwcaps/power10/libc.so.6 | grep gaih_inet
        0000000000130490 t gaih_inet.constprop.0
        000000000012e830 t gaih_inet_serv
        00000000001d45e4 r gaih_inet_typeproto
      
        [root@xxx perf]# ./perf script -i /tmp/perf.data.b6S
        ping   67906 [000] 22699.591699: probe_libc:inet_pton_3: (7fffbdd80820) 7fffbdd80820 __GI___inet_pton+0x0
        (/usr/lib64/glibc-hwcaps/power10/libc.so.6) 7fffbdd31160 gaih_inet.constprop.0+0xcd0
        (/usr/lib64/glibc-hwcaps/power10/libc.so.6) 7fffbdd31c7c getaddrinfo+0x14c
        (/usr/lib64/glibc-hwcaps/power10/libc.so.6) 1140d3558 [unknown] (/usr/bin/ping)
      
      This patch solves this issue by doing a conditional skip. If there is a
      gaih_inet function present in the libc then it will be added to the
      expected backtrace else the function will be skipped from being added
      to the expected backtrace.
      
      Output with the patch
      
        [root@xxx perf]# ./perf test -v "probe libc's inet_pton & backtrace it
        with ping"
         83: probe libc's inet_pton & backtrace it with ping                 :
        --- start ---
        test child forked, pid 102662
        ping 102692 [000] 127935.549973: probe_libc:inet_pton: (7fff93379a60)
        7fff93379a60 __GI___inet_pton+0x0 (/usr/lib64/glibc-hwcaps/power10/libc.so.6)
        7fff9332a73c getaddrinfo+0x121c (/usr/lib64/glibc-hwcaps/power10/libc.so.6)
        11ef03534 [unknown] (/usr/bin/ping)
        test child finished with 0
        ---- end ----
        probe libc's inet_pton & backtrace it with ping: Ok
      Reported-by: default avatarDisha Goel <disgoel@linux.ibm.com>
      Reviewed-by: default avatarAthira Jajeev <atrajeev@linux.vnet.ibm.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarLikhitha Korrapati <likhitha@linux.ibm.com>
      Tested-by: default avatarDisha Goel <disgoel@linux.ibm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Disha Goel <disgoel@linux.vnet.ibm.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: Namhyung Kim <namhyung@kernel.org>
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20231126070914.175332-1-likhitha@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      72a2a0a4
    • Arnaldo Carvalho de Melo's avatar
      perf tests sigtrap: Skip if running on a kernel with sleepable spinlocks · 650e0bde
      Arnaldo Carvalho de Melo authored
      There are issues as reported that need some more investigation on the
      RT kernel front, till that is addressed, skip this test.
      
      This test is already skipped for multiple hardware architectures where
      the tested kernel feature is not supported.
      Acked-by: default avatarMarco Elver <elver@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Kate Carcia <kcarcia@redhat.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/all/e368f2c848d77fbc8d259f44e2055fe469c219cf.camel@gmx.de/
      Link: https://lore.kernel.org/r/20231129154718.326330-3-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      650e0bde
    • Arnaldo Carvalho de Melo's avatar
      perf test sigtrap: Generalize the BTF routine to reuse it in this test · a472ee42
      Arnaldo Carvalho de Melo authored
      Move the part that loads the BTF info to a "btf__available()" that will
      lazy load the BTF info so that if we need it for some other test, which
      we will in the following cset, we can reuse it.
      
      At some point this will move from this specific 'perf test' entry to be
      used in other parts of perf, do it when needed.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kate Carcia <kcarcia@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lore.kernel.org/r/20231129154718.326330-2-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a472ee42
  6. 28 Nov, 2023 3 commits
    • Ian Rogers's avatar
      perf mmap: Lazily initialize zstd streams to save memory when not using it · 5940a20a
      Ian Rogers authored
      Zstd streams create dictionaries that can require significant RAM,
      especially when there is one per-CPU. Tools like 'perf record' won't use
      the streams without the -z option, and so the creation of the streams
      is pure overhead. Switch to creating the streams on first use.
      
      Committer notes:
      
      ssize_t comes from sys/types.h, size_t from stddef.h. This worked on
      glibc as stdlib.h includes both, but not on musl libc. So do what 'man
      size_t' says and include sys/types.h and stddef.h instead of stdlib.h
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Colin Ian King <colin.i.king@gmail.com>
      Cc: Dmitrii Dolgov <9erthalion6@gmail.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Huacai Chen <chenhuacai@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: K Prateek Nayak <kprateek.nayak@amd.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Li Dong <lidong@vivo.com>
      Cc: Liam Howlett <liam.howlett@oracle.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Ming Wang <wangming01@loongson.cn>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Sean Christopherson <seanjc@google.com>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Cc: Vincent Whitchurch <vincent.whitchurch@axis.com>
      Cc: Wenyu Liu <liuwenyu7@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Link: https://lore.kernel.org/r/20231102175735.2272696-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5940a20a
    • Namhyung Kim's avatar
      perf dwarf-aux: Add die_find_variable_by_addr() · d60469d7
      Namhyung Kim authored
      The die_find_variable_by_addr() is to find a variables in the given DIE
      using given (PC-relative) address.  Global variables will have a
      location expression with DW_OP_addr which has an address so can simply
      compare it with the address.
      
        <1><143a7>: Abbrev Number: 2 (DW_TAG_variable)
            <143a8>   DW_AT_name        : loops_per_jiffy
            <143ac>   DW_AT_type        : <0x1cca>
            <143b0>   DW_AT_external    : 1
            <143b0>   DW_AT_decl_file   : 193
            <143b1>   DW_AT_decl_line   : 213
            <143b2>   DW_AT_location    : 9 byte block: 3 b0 46 41 82 ff ff ff ff
                                           (DW_OP_addr: ffffffff824146b0)
      
      Note that the type-offset should be calculated from the base address of
      the global variable.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: linux-toolchains@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Link: https://lore.kernel.org/r/20231110000012.3538610-33-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d60469d7
    • Yang Jihong's avatar
      perf tools: Add --debug-file option to redirect debug output · 72108c0b
      Yang Jihong authored
      Currently, debug messages is output to stderr, add --debug-file option to
      support redirection to a specified file.
      
      Some test scenarios:
      
        # perf --list-opts
        --help --version --exec-path --html-path --paginate --no-pager --debugfs-dir --buildid-dir --list-cmds --list-opts --debug --debug-file
      
        # perf --debug-file
        No path given for --debug-file.
      
         Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
      
        # perf --debug-file /sys/perf.log record -v true
        Open debug file '/sys/perf.log' failed: Permission denied
      
         Usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
      
        # perf --debug-file /tmp/perf.log record -v true
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.013 MB perf.data (26 samples) ]
        # cat /tmp/perf.log
        DEBUGINFOD_URLS=
        Using CPUID GenuineIntel-6-3E-4
        nr_cblocks: 0
        affinity: SYS
        mmap flush: 1
        comp level: 0
        mmap size 528384B
        Control descriptor is not initialized
        mmap size 528384B
        Looking at the vmlinux_path (8 entries long)
        Using /proc/kcore for kernel data
        Using /proc/kallsyms for symbols
        symbol:unmap_start file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:unmap_complete file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:map_start file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:map_complete file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:reloc_start file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:reloc_complete file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:init_start file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:init_complete file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:lll_lock_wait_private file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:lll_lock_wait file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:setjmp file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:longjmp file:(null) line:0 offset:0 return:0 lazy:(null)
        symbol:longjmp_target file:(null) line:0 offset:0 return:0 lazy:(null)
        failed to write feature HYBRID_TOPOLOGY
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Acked-by: default avatarArnaldo Carvalho de Melo <acme@redhat.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/r/20231031105523.1472558-1-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      72108c0b
  7. 27 Nov, 2023 12 commits
    • Namhyung Kim's avatar
      perf annotate: Check if operand has multiple regs · 08973307
      Namhyung Kim authored
      It needs to check all possible information in an instruction.  Let's add
      a field indicating if the operand has multiple registers.  I'll be used
      to search type information like in an array access on x86 like:
      
        mov    0x10(%rax,%rbx,8), %rcx
                   -------------
                       here
      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: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: linux-toolchains@vger.kernel.org
      Cc: linux-trace-devel@vger.kernel.org
      Link: https://lore.kernel.org/r/20231012035111.676789-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      08973307
    • James Clark's avatar
      perf test: Use existing config value for objdump path · ffa96259
      James Clark authored
      There is already an existing config value for changing the objdump path,
      so instead of having two values that do the same thing, make 'perf test'
      use annotate.objdump as well.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/r/ZU5Cx4LTrB5q0sIG@kernel.org
      Link: https://lore.kernel.org/r/20231113102327.695386-1-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ffa96259
    • Inochi Amaoto's avatar
      perf vendor events riscv: add T-HEAD C9xx JSON file · 7340c6df
      Inochi Amaoto authored
      Add JSON file of T-HEAD C9xx series events.
      
      The event idx (raw value) is summary as following:
      
      event id range   | support cpu
       0x01 - 0x2a     |  c906,c910,c920
      
      The event ids are based on the public document of T-HEAD and cover the
      c900 series.
      
      These events are the max that c900 series support.  Since T-HEAD let
      manufacturers decide whether events are usable, the final support of the
      perf events is determined by the pmu node of the soc dtb.
      Signed-off-by: default avatarInochi Amaoto <inochiama@outlook.com>
      Tested-by: default avatarGuo Ren <guoren@kernel.org>
      Acked-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Albert Ou <aou@eecs.berkeley.edu>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Chen Wang <unicorn_wang@outlook.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Jisheng Zhang <jszhang@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wei Fu <wefu@redhat.com>
      Cc: linux-riscv@lists.infradead.org
      Link: https://lore.kernel.org/r/IA1PR20MB495325FCF603BAA841E29281BBBAA@IA1PR20MB4953.namprd20.prod.outlook.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7340c6df
    • Ian Rogers's avatar
      perf vendor events: Add skx, clx, icx and spr upi bandwidth metric · 19dd49c9
      Ian Rogers authored
      Add upi_data_receive_bw metric for skylakex, cascadelakex, icelakex
      and sapphirerapids. The metric was added to perfmon metrics in:
      https://github.com/intel/perfmon/pull/119Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ingo Molnar <mingo@redhat.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: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20231109232732.2973015-1-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      19dd49c9
    • Adrian Hunter's avatar
      perf tests: Skip data symbol test if buf1 symbol is missing · 124bf636
      Adrian Hunter authored
      perf data symbol test depends on finding symbol buf1 in perf, and fails if
      perf has been stripped and no debug object is available. In that case, skip
      the test instead.
      
      Example:
      
       Before:
      
        $ strip tools/perf/perf
        $ tools/perf/perf buildid-cache -p `realpath tools/perf/perf`
        $ tools/perf/perf test -v 'data symbol'
        113: Test data symbol                                                :
        --- start ---
        test child forked, pid 125646
        Recording workload...
        [ perf record: Woken up 3 times to write data ]
        [ perf record: Captured and wrote 0.577 MB /tmp/__perf_test.perf.data.Jhbdp (7794 samples) ]
        Cleaning up files...
        test child finished with -1
        ---- end ----
        Test data symbol: FAILED!
      
       After:
      
        $ tools/perf/perf test -v 'data symbol'
        113: Test data symbol                                                :
        --- start ---
        test child forked, pid 125747
        perf does not have symbol 'buf1'
        perf is missing symbols - skipping test
        test child finished with -2
        ---- end ----
        Test data symbol: Skip
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231123075848.9652-9-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      124bf636
    • Adrian Hunter's avatar
      perf tests: Make data symbol test wait for perf to start · 3b24b15c
      Adrian Hunter authored
      The perf data symbol test waits 1 second for perf to run and collect data,
      which may be too little if perf takes a long time to start up, which has
      been noticed on systems with many CPUs. Use existing wait_for_perf_to_start
      helper to wait for perf to start.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231123075848.9652-8-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3b24b15c
    • Adrian Hunter's avatar
      perf tests: Skip branch stack sampling test if brstack_bench symbol is missing · fcfb5a61
      Adrian Hunter authored
      The test "Check branch stack sampling" depends on finding symbol
      brstack_bench (and several others) in perf, and fails if perf has been
      stripped and no debug object is available. In that case, skip the test
      instead.
      
      Example:
      
       Before:
      
        $ strip tools/perf/perf
        $ tools/perf/perf buildid-cache -p `realpath tools/perf/perf`
        $ tools/perf/perf test -v 'branch stack sampling'
        112: Check branch stack sampling                                     :
        --- start ---
        test child forked, pid 123741
        Testing user branch stack sampling
        + grep -E -m1 ^brstack_bench\+[^ ]*/brstack_foo\+[^ ]*/IND_CALL/.*$ /tmp/__perf_test.program.5Dz1U/perf.script
        + cleanup
        + rm -rf /tmp/__perf_test.program.5Dz1U
        test child finished with -1
        ---- end ----
        Check branch stack sampling: FAILED!
      
       After:
      
        $ tools/perf/perf test -v 'branch stack sampling'
        112: Check branch stack sampling                                     :
        --- start ---
        test child forked, pid 125157
        perf does not have symbol 'brstack_bench'
        perf is missing symbols - skipping test
        test child finished with -2
        ---- end ----
        Check branch stack sampling: Skip
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231123075848.9652-7-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fcfb5a61
    • Adrian Hunter's avatar
      perf tests: Skip Arm64 callgraphs test if leafloop symbol is missing · fc1de29a
      Adrian Hunter authored
      The test "Check Arm64 callgraphs are complete in fp mode" depends on
      finding symbol leafloop in perf, and fails if perf has been stripped and no
      debug object is available. In that case, skip the test instead.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231123075848.9652-6-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fc1de29a
    • Adrian Hunter's avatar
      perf tests: Skip record test if test_loop symbol is missing · 3c489dbe
      Adrian Hunter authored
      perf record test depends on finding symbol test_loop in perf, and fails if
      perf has been stripped and no debug object is available. In that case, skip
      the test instead.
      
      Example:
      
       Note, building with perl support adds option -Wl,-E which causes the
       linker to add all (global) symbols to the dynamic symbol table. So the
       test_loop symbol, being global, does not get stripped unless NO_LIBPERL=1
      
       Before:
      
        $ make NO_LIBPERL=1 -C tools/perf >/dev/null 2>&1
        $ strip tools/perf/perf
        $ tools/perf/perf buildid-cache -p `realpath tools/perf/perf`
        $ tools/perf/perf test -v 'record tests'
         91: perf record tests                                               :
        --- start ---
        test child forked, pid 118750
        Basic --per-thread mode test
        Per-thread record [Failed missing output]
        Register capture test
        Register capture test [Success]
        Basic --system-wide mode test
        System-wide record [Skipped not supported]
        Basic target workload test
        Workload record [Failed missing output]
        test child finished with -1
        ---- end ----
        perf record tests: FAILED!
      
       After:
      
        $ tools/perf/perf test -v 'record tests'
         91: perf record tests                                               :
        --- start ---
        test child forked, pid 120025
        perf does not have symbol 'test_loop'
        perf is missing symbols - skipping test
        test child finished with -2
        ---- end ----
        perf record tests: Skip
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231123075848.9652-5-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3c489dbe
    • Adrian Hunter's avatar
      perf tests: Skip pipe test if noploop symbol is missing · c9526a73
      Adrian Hunter authored
      perf pipe recording and injection test depends on finding symbol noploop in
      perf, and fails if perf has been stripped and no debug object is available.
      In that case, skip the test instead.
      
      Example:
      
       Before:
      
        $ strip tools/perf/perf
        $ tools/perf/perf buildid-cache -p `realpath tools/perf/perf`
        $ tools/perf/perf test -v pipe
         86: perf pipe recording and injection test                          :
        --- start ---
        test child forked, pid 47734
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.000 MB - ]
             47741    47741       -1 |perf
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.000 MB - ]
        cannot find noploop function in pipe #1
        test child finished with -1
        ---- end ----
        perf pipe recording and injection test: FAILED!
      
      After:
      
        $ tools/perf/perf test -v pipe
         86: perf pipe recording and injection test                          :
        --- start ---
        test child forked, pid 48996
        perf does not have symbol 'noploop'
        perf is missing symbols - skipping test
        test child finished with -2
        ---- end ----
        perf pipe recording and injection test: Skip
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231123075848.9652-4-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c9526a73
    • Adrian Hunter's avatar
      perf tests lib: Add perf_has_symbol.sh · 96ba5999
      Adrian Hunter authored
      Some shell tests depend on finding symbols for perf itself, and fail if
      perf has been stripped and no debug object is available. Add helper
      functions to check if perf has a needed symbol. This is preparation for
      amending the tests themselves to be skipped if a needed symbol is not
      found.
      
      The functions make use of the "Symbols" test which reads and checks symbols
      from a dso, perf itself by default. Note the "Symbols" test will find
      symbols using the same method as other perf tests, including, for example,
      looking in the buildid cache.
      
      An alternative would be to prevent the needed symbols from being stripped,
      which seems to work with gcc's externally_visible attribute, but that
      attribute is not supported by clang.
      
      Another alternative would be to use option -Wl,-E (which is already used
      when perf is built with perl support) which causes the linker to add all
      (global) symbols to the dynamic symbol table. Then the required symbols
      need only be made global in scope to avoid being strippable. However that
      goes beyond what is needed.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231123075848.9652-3-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      96ba5999
    • Adrian Hunter's avatar
      perf header: Fix segfault on build_mem_topology() error path · 70df0783
      Adrian Hunter authored
      Do not increase the node count unless a node has been successfully read,
      because it can lead to a segfault if an error occurs.
      
      For example, if perf exceeds the open file limit in memory_node__read(),
      which, on a test system, could be made to happen by setting the file limit
      to exactly 32:
      
       Before:
      
        $ ulimit -n 32
        $ perf mem record --all-user -- sleep 1
        [ perf record: Woken up 1 times to write data ]
        failed: can't open memory sysfs data
        perf: Segmentation fault
        Obtained 14 stack frames.
        perf(sighandler_dump_stack+0x48) [0x55f4b1f59558]
        /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f4ba1c42520]
        /lib/x86_64-linux-gnu/libc.so.6(free+0x1e) [0x7f4ba1ca53fe]
        perf(+0x178ff4) [0x55f4b1f48ff4]
        perf(+0x179a70) [0x55f4b1f49a70]
        perf(+0x17ef5d) [0x55f4b1f4ef5d]
        perf(+0x85c0b) [0x55f4b1e55c0b]
        perf(cmd_record+0xe1d) [0x55f4b1e5920d]
        perf(cmd_mem+0xc96) [0x55f4b1e80e56]
        perf(+0x130460) [0x55f4b1f00460]
        perf(main+0x689) [0x55f4b1e427d9]
        /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f4ba1c29d90]
        /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7f4ba1c29e40]
        perf(_start+0x25) [0x55f4b1e42a25]
        Segmentation fault (core dumped)
        $
      
      After:
      
        $ ulimit -n 32
        $ perf mem record --all-user -- sleep 1
        [ perf record: Woken up 1 times to write data ]
        failed: can't open memory sysfs data
        [ perf record: Captured and wrote 0.005 MB perf.data (11 samples) ]
        $
      
      Fixes: f8e502b9 ("perf header: Ensure bitmaps are freed")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: German Gomez <german.gomez@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/r/20231123075848.9652-2-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      70df0783