1. 08 Aug, 2023 1 commit
    • Ivan Babrou's avatar
      perf script: Print "cgroup" field on the same line as "comm" · 8c49c6e1
      Ivan Babrou authored
      Commit 3fd7a168 ("perf script: Add 'cgroup' field for output")
      added support for printing cgroup path in perf script output.
      
      It was okay if you didn't want any stacks:
      
          $ sudo perf script --comms jpegtran:23f4bf -F comm,tid,cpu,time,cgroup
          jpegtran:23f4bf 3321915 [013] 404718.587488:  /idle.slice/polish.service
          jpegtran:23f4bf 3321915 [031] 404718.592073:  /idle.slice/polish.service
      
      With stacks it gets messier as cgroup is printed after the stack:
      
          $ perf script --comms jpegtran:23f4bf -F comm,tid,cpu,time,cgroup,ip,sym
          jpegtran:23f4bf 3321915 [013] 404718.587488:
                          5c554 compress_output
                          570d9 jpeg_finish_compress
                          3476e jpegtran_main
                          330ee jpegtran::main
                          326e2 core::ops::function::FnOnce::call_once (inlined)
                          326e2 std::sys_common::backtrace::__rust_begin_short_backtrace
          /idle.slice/polish.service
          jpegtran:23f4bf 3321915 [031] 404718.592073:
                          8474d jsimd_encode_mcu_AC_first_prepare_sse2.PADDING
                      55af68e62fff [unknown]
          /idle.slice/polish.service
      
      Let's instead print cgroup on the same line as comm:
      
          $ perf script --comms jpegtran:23f4bf -F comm,tid,cpu,time,cgroup,ip,sym
          jpegtran:23f4bf 3321915 [013] 404718.587488:  /idle.slice/polish.service
                          5c554 compress_output
                          570d9 jpeg_finish_compress
                          3476e jpegtran_main
                          330ee jpegtran::main
                          326e2 core::ops::function::FnOnce::call_once (inlined)
                          326e2 std::sys_common::backtrace::__rust_begin_short_backtrace
      
          jpegtran:23f4bf 3321915 [031] 404718.592073:  /idle.slice/polish.service
                          8474d jsimd_encode_mcu_AC_first_prepare_sse2.PADDING
                      55af68e62fff [unknown]
      
      Fixes: 3fd7a168 ("perf script: Add 'cgroup' field for output")
      Signed-off-by: default avatarIvan Babrou <ivan@cloudflare.com>
      Acked-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: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@cloudflare.com
      Link: https://lore.kernel.org/r/20230718000737.49077-1-ivan@cloudflare.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8c49c6e1
  2. 07 Aug, 2023 3 commits
    • Arnaldo Carvalho de Melo's avatar
      perf probe: Make synthesize_perf_probe_point() private to probe-event.c · aeb50d3f
      Arnaldo Carvalho de Melo authored
      Not used in any other place, so just make it static.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZM0pjfOe6R4X%2Fcql@kernel.org/Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      aeb50d3f
    • Arnaldo Carvalho de Melo's avatar
      perf probe: Free string returned by synthesize_perf_probe_point() on failure... · a612bbf8
      Arnaldo Carvalho de Melo authored
      perf probe: Free string returned by synthesize_perf_probe_point() on failure in synthesize_perf_probe_command()
      
      Building perf with EXTRA_CFLAGS="-fsanitize=address" a leak was detected
      elsewhere and lead to an audit, where we found that
      synthesize_perf_probe_command() may leak synthesize_perf_probe_point()
      return on failure, fix it.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZM0mzpQktHnhXJXr@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a612bbf8
    • Arnaldo Carvalho de Melo's avatar
      perf probe: Free string returned by synthesize_perf_probe_point() on failure to add a probe · 7bc0153c
      Arnaldo Carvalho de Melo authored
      Building perf with EXTRA_CFLAGS="-fsanitize=address" a leak is detect
      when trying to add a probe to a non-existent function:
      
        # perf probe -x ~/bin/perf dso__neW
        Probe point 'dso__neW' not found.
          Error: Failed to add events.
      
        =================================================================
        ==296634==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 128 byte(s) in 1 object(s) allocated from:
            #0 0x7f67642ba097 in calloc (/lib64/libasan.so.8+0xba097)
            #1 0x7f67641a76f1 in allocate_cfi (/lib64/libdw.so.1+0x3f6f1)
      
        Direct leak of 65 byte(s) in 1 object(s) allocated from:
            #0 0x7f67642b95b5 in __interceptor_realloc.part.0 (/lib64/libasan.so.8+0xb95b5)
            #1 0x6cac75 in strbuf_grow util/strbuf.c:64
            #2 0x6ca934 in strbuf_init util/strbuf.c:25
            #3 0x9337d2 in synthesize_perf_probe_point util/probe-event.c:2018
            #4 0x92be51 in try_to_find_probe_trace_events util/probe-event.c:964
            #5 0x93d5c6 in convert_to_probe_trace_events util/probe-event.c:3512
            #6 0x93d6d5 in convert_perf_probe_events util/probe-event.c:3529
            #7 0x56f37f in perf_add_probe_events /var/home/acme/git/perf-tools-next/tools/perf/builtin-probe.c:354
            #8 0x572fbc in __cmd_probe /var/home/acme/git/perf-tools-next/tools/perf/builtin-probe.c:738
            #9 0x5730f2 in cmd_probe /var/home/acme/git/perf-tools-next/tools/perf/builtin-probe.c:766
            #10 0x635d81 in run_builtin /var/home/acme/git/perf-tools-next/tools/perf/perf.c:323
            #11 0x6362c1 in handle_internal_command /var/home/acme/git/perf-tools-next/tools/perf/perf.c:377
            #12 0x63667a in run_argv /var/home/acme/git/perf-tools-next/tools/perf/perf.c:421
            #13 0x636b8d in main /var/home/acme/git/perf-tools-next/tools/perf/perf.c:537
            #14 0x7f676302950f in __libc_start_call_main (/lib64/libc.so.6+0x2950f)
      
        SUMMARY: AddressSanitizer: 193 byte(s) leaked in 2 allocation(s).
        #
      
      synthesize_perf_probe_point() returns a "detachec" strbuf, i.e. a
      malloc'ed string that needs to be free'd.
      
      An audit will be performed to find other such cases.
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/ZM0l1Oxamr4SVjfY@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7bc0153c
  3. 04 Aug, 2023 1 commit
  4. 03 Aug, 2023 35 commits