1. 19 Mar, 2019 25 commits
    • Changbin Du's avatar
      perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test() · d982b331
      Changbin Du authored
        =================================================================
        ==20875==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 1160 byte(s) in 1 object(s) allocated from:
            #0 0x7f1b6fc84138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x55bd50005599 in zalloc util/util.h:23
            #2 0x55bd500068f5 in perf_evsel__newtp_idx util/evsel.c:327
            #3 0x55bd4ff810fc in perf_evsel__newtp /home/work/linux/tools/perf/util/evsel.h:216
            #4 0x55bd4ff81608 in test__perf_evsel__tp_sched_test tests/evsel-tp-sched.c:69
            #5 0x55bd4ff528e6 in run_test tests/builtin-test.c:358
            #6 0x55bd4ff52baf in test_and_print tests/builtin-test.c:388
            #7 0x55bd4ff543fe in __cmd_test tests/builtin-test.c:583
            #8 0x55bd4ff5572f in cmd_test tests/builtin-test.c:722
            #9 0x55bd4ffc4087 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #10 0x55bd4ffc45c6 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #11 0x55bd4ffc49ca in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #12 0x55bd4ffc5138 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #13 0x7f1b6e34809a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
        Indirect leak of 19 byte(s) in 1 object(s) allocated from:
            #0 0x7f1b6fc83f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
            #1 0x7f1b6e3ac30f in vasprintf (/lib/x86_64-linux-gnu/libc.so.6+0x8830f)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 6a6cd11d ("perf test: Add test for the sched tracepoint format fields")
      Link: http://lkml.kernel.org/r/20190316080556.3075-17-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d982b331
    • Changbin Du's avatar
      perf tests: Fix memory leak by expr__find_other() in test__expr() · f97a8991
      Changbin Du authored
        =================================================================
        ==7506==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 13 byte(s) in 3 object(s) allocated from:
            #0 0x7f03339d6070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x5625e53aaef0 in expr__find_other util/expr.y:221
            #2 0x5625e51bcd3f in test__expr tests/expr.c:52
            #3 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #4 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #5 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #6 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #7 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #8 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #9 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #10 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #11 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 07516736 ("perf tools: Add a simple expression parser for JSON")
      Link: http://lkml.kernel.org/r/20190316080556.3075-16-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f97a8991
    • Changbin Du's avatar
      perf tests: Fix a memory leak of cpu_map object in the openat_syscall_event_on_all_cpus test · 93faa52e
      Changbin Du authored
        =================================================================
        ==7497==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 40 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a88f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
            #1 0x5625e5326213 in cpu_map__trim_new util/cpumap.c:45
            #2 0x5625e5326703 in cpu_map__read util/cpumap.c:103
            #3 0x5625e53267ef in cpu_map__read_all_cpu_map util/cpumap.c:120
            #4 0x5625e5326915 in cpu_map__new util/cpumap.c:135
            #5 0x5625e517b355 in test__openat_syscall_event_on_all_cpus tests/openat-syscall-all-cpus.c:36
            #6 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #7 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #8 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #9 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #10 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #11 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #12 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #13 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #14 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: f30a79b0 ("perf tools: Add reference counting for cpu_map object")
      Link: http://lkml.kernel.org/r/20190316080556.3075-15-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      93faa52e
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Free evsel->counts in perf_evsel__exit() · 42dfa451
      Arnaldo Carvalho de Melo authored
      Using gcc's ASan, Changbin reports:
      
        =================================================================
        ==7494==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 48 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x5625e5330a5e in zalloc util/util.h:23
            #2 0x5625e5330a9b in perf_counts__new util/counts.c:10
            #3 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47
            #4 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505
            #5 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347
            #6 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47
            #7 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #8 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #9 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #10 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #11 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #12 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #13 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #14 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #15 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
        Indirect leak of 72 byte(s) in 1 object(s) allocated from:
            #0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x5625e532560d in zalloc util/util.h:23
            #2 0x5625e532566b in xyarray__new util/xyarray.c:10
            #3 0x5625e5330aba in perf_counts__new util/counts.c:15
            #4 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47
            #5 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505
            #6 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347
            #7 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47
            #8 0x5625e51528e6 in run_test tests/builtin-test.c:358
            #9 0x5625e5152baf in test_and_print tests/builtin-test.c:388
            #10 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
            #11 0x5625e515572f in cmd_test tests/builtin-test.c:722
            #12 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #13 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #14 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #15 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #16 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
      His patch took care of evsel->prev_raw_counts, but the above backtraces
      are about evsel->counts, so fix that instead.
      Reported-by: default avatarChangbin Du <changbin.du@gmail.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: https://lkml.kernel.org/n/tip-hd1x13g59f0nuhe4anxhsmfp@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42dfa451
    • Changbin Du's avatar
      perf top: Fix global-buffer-overflow issue · 1e5b0cf8
      Changbin Du authored
      The array str[] should have six elements.
      
        =================================================================
        ==4322==ERROR: AddressSanitizer: global-buffer-overflow on address 0x56463844e300 at pc 0x564637e7ad0d bp 0x7f30c8c89d10 sp 0x7f30c8c89d00
        READ of size 8 at 0x56463844e300 thread T9
            #0 0x564637e7ad0c in __ordered_events__flush util/ordered-events.c:316
            #1 0x564637e7b0e4 in ordered_events__flush util/ordered-events.c:338
            #2 0x564637c6a57d in process_thread /home/changbin/work/linux/tools/perf/builtin-top.c:1073
            #3 0x7f30d173a163 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x8163)
            #4 0x7f30cfffbdee in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11adee)
      
        0x56463844e300 is located 32 bytes to the left of global variable 'flags' defined in 'util/trace-event-parse.c:229:26' (0x56463844e320) of size 192
        0x56463844e300 is located 0 bytes to the right of global variable 'str' defined in 'util/ordered-events.c:268:28' (0x56463844e2e0) of size 32
        SUMMARY: AddressSanitizer: global-buffer-overflow util/ordered-events.c:316 in __ordered_events__flush
        Shadow bytes around the buggy address:
          0x0ac947081c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
          0x0ac947081c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
          0x0ac947081c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
          0x0ac947081c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
          0x0ac947081c50: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 00 00 00
        =>0x0ac947081c60:[f9]f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
          0x0ac947081c70: 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9
          0x0ac947081c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
          0x0ac947081c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
          0x0ac947081ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
          0x0ac947081cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        Shadow byte legend (one shadow byte represents 8 application bytes):
          Addressable:           00
          Partially addressable: 01 02 03 04 05 06 07
          Heap left redzone:       fa
          Freed heap region:       fd
          Stack left redzone:      f1
          Stack mid redzone:       f2
          Stack right redzone:     f3
          Stack after return:      f5
          Stack use after scope:   f8
          Global redzone:          f9
          Global init order:       f6
          Poisoned by user:        f7
          Container overflow:      fc
          Array cookie:            ac
          Intra object redzone:    bb
          ASan internal:           fe
          Left alloca redzone:     ca
          Right alloca redzone:    cb
        Thread T9 created by T0 here:
            #0 0x7f30d179de5f in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x4ae5f)
            #1 0x564637c6b954 in __cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1253
            #2 0x564637c7173c in cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1642
            #3 0x564637d85038 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #4 0x564637d85577 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #5 0x564637d8597b in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #6 0x564637d860e9 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #7 0x7f30cff0509a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Fixes: 16c66bc1 ("perf top: Add processing thread")
      Fixes: 68ca5d07 ("perf ordered_events: Add ordered_events__flush_time interface")
      Link: http://lkml.kernel.org/r/20190316080556.3075-13-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1e5b0cf8
    • Changbin Du's avatar
      perf maps: Purge all maps from the 'names' tree · da3a53a7
      Changbin Du authored
      Add function __maps__purge_names() to purge all maps from the names
      tree.  We need to cleanup the names tree in maps__exit().
      
      Detected with gcc's ASan.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 1e628569 ("perf symbols: Fix slowness due to -ffunction-section")
      Link: http://lkml.kernel.org/r/20190316080556.3075-12-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      da3a53a7
    • Changbin Du's avatar
      perf map: Remove map from 'names' tree in __maps__remove() · b49265e0
      Changbin Du authored
      There are two trees for each map inserted by maps__insert(), so remove
      it from the 'names' tree in __maps__remove().
      
      Detected with gcc's ASan.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Eric Saint-Etienne <eric.saint.etienne@oracle.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 1e628569 ("perf symbols: Fix slowness due to -ffunction-section")
      Link: http://lkml.kernel.org/r/20190316080556.3075-11-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b49265e0
    • Changbin Du's avatar
      perf hist: Add missing map__put() in error case · cb6186ae
      Changbin Du authored
      We need to map__put() before returning from failure of
      sample__resolve_callchain().
      
      Detected with gcc's ASan.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 9c68ae98 ("perf callchain: Reference count maps")
      Link: http://lkml.kernel.org/r/20190316080556.3075-10-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cb6186ae
    • Changbin Du's avatar
      perf top: Fix error handling in cmd_top() · 70c819e4
      Changbin Du authored
      We should go to the cleanup path, to avoid leaks, detected using gcc's
      ASan.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/20190316080556.3075-9-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      70c819e4
    • Changbin Du's avatar
      perf top: Delete the evlist before perf_session, fixing heap-use-after-free issue · 0dba9e4b
      Changbin Du authored
      The evlist should be destroyed before the perf session.
      
      Detected with gcc's ASan:
      
        =================================================================
        ==27350==ERROR: AddressSanitizer: heap-use-after-free on address 0x62b000002e38 at pc 0x5611da276999 bp 0x7ffce8f1d1a0 sp 0x7ffce8f1d190
        WRITE of size 8 at 0x62b000002e38 thread T0
            #0 0x5611da276998 in __list_del /home/work/linux/tools/include/linux/list.h:89
            #1 0x5611da276d4a in __list_del_entry /home/work/linux/tools/include/linux/list.h:102
            #2 0x5611da276e77 in list_del_init /home/work/linux/tools/include/linux/list.h:145
            #3 0x5611da2781cd in thread__put util/thread.c:130
            #4 0x5611da2cc0a8 in __thread__zput util/thread.h:68
            #5 0x5611da2d2dcb in hist_entry__delete util/hist.c:1148
            #6 0x5611da2cdf91 in hists__delete_entry util/hist.c:337
            #7 0x5611da2ce19e in hists__delete_entries util/hist.c:365
            #8 0x5611da2db2ab in hists__delete_all_entries util/hist.c:2639
            #9 0x5611da2db325 in hists_evsel__exit util/hist.c:2651
            #10 0x5611da1c5352 in perf_evsel__exit util/evsel.c:1304
            #11 0x5611da1c5390 in perf_evsel__delete util/evsel.c:1309
            #12 0x5611da1b35f0 in perf_evlist__purge util/evlist.c:124
            #13 0x5611da1b38e2 in perf_evlist__delete util/evlist.c:148
            #14 0x5611da069781 in cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1645
            #15 0x5611da17d038 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #16 0x5611da17d577 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #17 0x5611da17d97b in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #18 0x5611da17e0e9 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #19 0x7fdcc970f09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
            #20 0x5611d9ff35c9 in _start (/home/work/linux/tools/perf/perf+0x3e95c9)
      
        0x62b000002e38 is located 11320 bytes inside of 27448-byte region [0x62b000000200,0x62b000006d38)
        freed by thread T0 here:
            #0 0x7fdccb04ab70 in free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedb70)
            #1 0x5611da260df4 in perf_session__delete util/session.c:201
            #2 0x5611da063de5 in __cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1300
            #3 0x5611da06973c in cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1642
            #4 0x5611da17d038 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #5 0x5611da17d577 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #6 0x5611da17d97b in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #7 0x5611da17e0e9 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #8 0x7fdcc970f09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
        previously allocated by thread T0 here:
            #0 0x7fdccb04b138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
            #1 0x5611da26010c in zalloc util/util.h:23
            #2 0x5611da260824 in perf_session__new util/session.c:118
            #3 0x5611da0633a6 in __cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1192
            #4 0x5611da06973c in cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1642
            #5 0x5611da17d038 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #6 0x5611da17d577 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #7 0x5611da17d97b in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #8 0x5611da17e0e9 in main /home/changbin/work/linux/tools/perf/perf.c:520
            #9 0x7fdcc970f09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      
        SUMMARY: AddressSanitizer: heap-use-after-free /home/work/linux/tools/include/linux/list.h:89 in __list_del
        Shadow bytes around the buggy address:
          0x0c567fff8570: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
          0x0c567fff8580: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
          0x0c567fff8590: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
          0x0c567fff85a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
          0x0c567fff85b0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        =>0x0c567fff85c0: fd fd fd fd fd fd fd[fd]fd fd fd fd fd fd fd fd
          0x0c567fff85d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
          0x0c567fff85e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
          0x0c567fff85f0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
          0x0c567fff8600: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
          0x0c567fff8610: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
        Shadow byte legend (one shadow byte represents 8 application bytes):
          Addressable:           00
          Partially addressable: 01 02 03 04 05 06 07
          Heap left redzone:       fa
          Freed heap region:       fd
          Stack left redzone:      f1
          Stack mid redzone:       f2
          Stack right redzone:     f3
          Stack after return:      f5
          Stack use after scope:   f8
          Global redzone:          f9
          Global init order:       f6
          Poisoned by user:        f7
          Container overflow:      fc
          Array cookie:            ac
          Intra object redzone:    bb
          ASan internal:           fe
          Left alloca redzone:     ca
          Right alloca redzone:    cb
        ==27350==ABORTING
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/20190316080556.3075-8-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0dba9e4b
    • Changbin Du's avatar
      perf build-id: Fix memory leak in print_sdt_events() · 8bde8516
      Changbin Du authored
      Detected with gcc's ASan:
      
        Direct leak of 4356 byte(s) in 120 object(s) allocated from:
            #0 0x7ff1a2b5a070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x55719aef4814 in build_id_cache__origname util/build-id.c:215
            #2 0x55719af649b6 in print_sdt_events util/parse-events.c:2339
            #3 0x55719af66272 in print_events util/parse-events.c:2542
            #4 0x55719ad1ecaa in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
            #5 0x55719aec745d in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
            #6 0x55719aec7d1a in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
            #7 0x55719aec8184 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
            #8 0x55719aeca41a in main /home/changbin/work/linux/tools/perf/perf.c:520
            #9 0x7ff1a07ae09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 40218dae ("perf list: Show SDT and pre-cached events")
      Link: http://lkml.kernel.org/r/20190316080556.3075-7-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8bde8516
    • Changbin Du's avatar
      perf config: Fix a memory leak in collect_config() · 54569ba4
      Changbin Du authored
      Detected with gcc's ASan:
      
        Direct leak of 66 byte(s) in 5 object(s) allocated from:
            #0 0x7ff3b1f32070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
            #1 0x560c8761034d in collect_config util/config.c:597
            #2 0x560c8760d9cb in get_value util/config.c:169
            #3 0x560c8760dfd7 in perf_parse_file util/config.c:285
            #4 0x560c8760e0d2 in perf_config_from_file util/config.c:476
            #5 0x560c876108fd in perf_config_set__init util/config.c:661
            #6 0x560c87610c72 in perf_config_set__new util/config.c:709
            #7 0x560c87610d2f in perf_config__init util/config.c:718
            #8 0x560c87610e5d in perf_config util/config.c:730
            #9 0x560c875ddea0 in main /home/changbin/work/linux/tools/perf/perf.c:442
            #10 0x7ff3afb8609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Fixes: 20105ca1 ("perf config: Introduce perf_config_set class")
      Link: http://lkml.kernel.org/r/20190316080556.3075-6-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      54569ba4
    • Changbin Du's avatar
      perf config: Fix an error in the config template documentation · 9b40dff7
      Changbin Du authored
      The option 'sort-order' should be 'sort_order'.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 893c5c79 ("perf config: Show default report configuration in example and docs")
      Link: http://lkml.kernel.org/r/20190316080556.3075-5-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9b40dff7
    • Changbin Du's avatar
      perf tools: Fix errors under optimization level '-Og' · 11c1ea6f
      Changbin Du authored
      Optimization level '-Og' offers a reasonable level of optimization while
      maintaining fast compilation and a good debugging experience. This patch
      tries to make it work.
      
        $ make DEBUG=1 EXTRA_CFLAGS='-Og'
        bench/epoll-ctl.c: In function ‘do_threads’:
        bench/epoll-ctl.c:274:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
          return ret;
                 ^~~
        ...
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/20190316080556.3075-4-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      11c1ea6f
    • Changbin Du's avatar
      perf list: Don't forget to drop the reference to the allocated thread_map · 39df730b
      Changbin Du authored
      Detected via gcc's ASan:
      
        Direct leak of 2048 byte(s) in 64 object(s) allocated from:
          6     #0 0x7f606512e370 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee370)
          7     #1 0x556b0f1d7ddd in thread_map__realloc util/thread_map.c:43
          8     #2 0x556b0f1d84c7 in thread_map__new_by_tid util/thread_map.c:85
          9     #3 0x556b0f0e045e in is_event_supported util/parse-events.c:2250
         10     #4 0x556b0f0e1aa1 in print_hwcache_events util/parse-events.c:2382
         11     #5 0x556b0f0e3231 in print_events util/parse-events.c:2514
         12     #6 0x556b0ee0a66e in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
         13     #7 0x556b0f01e0ae in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
         14     #8 0x556b0f01e859 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
         15     #9 0x556b0f01edc8 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
         16     #10 0x556b0f01f71f in main /home/changbin/work/linux/tools/perf/perf.c:520
         17     #11 0x7f6062ccf09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Fixes: 89896051 ("perf tools: Do not put a variable sized type not at the end of a struct")
      Link: http://lkml.kernel.org/r/20190316080556.3075-3-changbin.du@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      39df730b
    • Changbin Du's avatar
      perf tools: Add doc about how to build perf with Asan and UBSan · af7a14a7
      Changbin Du authored
      AddressSanitizer (or ASan) and UndefinedBehaviorSanitizer (or UBSan) are
      very useful tools to detect program bugs:
      
       - AddressSanitizer (or ASan) is a GCC feature that detects memory
         corruption bugs such as buffer overflows and memory leaks.
      
       - UndefinedBehaviorSanitizer (or UBSan) is a fast undefined behavior
         detector supported by GCC. UBSan detects undefined behaviors of programs
         at runtime.
      
      This patch adds a document about how to use them on perf. Later patches will fix
      some of the issues disclosed by them.
      Signed-off-by: default avatarChangbin Du <changbin.du@gmail.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/20190316080556.3075-2-changbin.du@gmail.com
      [ Make some changes based on comments made by Jiri Olsa ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      af7a14a7
    • Mamatha Inamdar's avatar
      perf vendor events: Remove P8 HW events which are not supported · c3b4d5c4
      Mamatha Inamdar authored
      This patch is to remove following hardware events from JSON file which
      are not supported on POWER8.
      
        pm_co_disp_fail
        pm_co_tm_sc_footprint
        pm_iside_disp
        pm_iside_disp_fail
        pm_iside_disp_fail_other
        pm_iside_mru_touch
        pm_l2_castout_mod
        pm_l2_castout_shr
        pm_l2_dc_inv
        pm_l2_disp_all_l2miss
        pm_l2_grp_guess_correct
        pm_l2_grp_guess_wrong
        pm_l2_ic_inv
        pm_l2_inst
        pm_l2_inst_miss
        pm_l2_ld
        pm_l2_ld_disp
        pm_l2_ld_hit
        pm_l2_ld_miss
        pm_l2_loc_guess_correct
        pm_l2_loc_guess_wrong
        pm_l2_rcld_disp
        pm_l2_rcld_disp_fail_addr
        pm_l2_rcld_disp_fail_other
        pm_l2_rcst_disp
        pm_l2_rcst_disp_fail_addr
        pm_l2_rcst_disp_fail_other
        pm_l2_rc_st_done
        pm_l2_rty_ld
        pm_l2_sn_m_rd_done
        pm_l2_sn_m_wr_done
        pm_l2_sn_sx_i_done
        pm_l2_st_disp
        pm_l2_st_hit
        pm_l2_sys_guess_correct
        pm_l2_sys_guess_wrong
        pm_l2_sys_pump
        pm_l3_ci_hit
        pm_l3_ci_miss
        pm_l3_cinj
        pm_l3_co
        pm_l3_co_lco
        pm_l3_grp_guess_correct
        pm_l3_grp_guess_wrong_high
        pm_l3_grp_guess_wrong_low
        pm_l3_hit
        pm_l3_l2_co_hit
        pm_l3_l2_co_miss
        pm_l3_lat_ci_hit
        pm_l3_lat_ci_miss
        pm_l3_ld_hit
        pm_l3_ld_miss
        pm_l3_loc_guess_correct
        pm_l3_loc_guess_wrong
        pm_l3_miss
        pm_l3_p0_co_l31
        pm_l3_p0_co_mem
        pm_l3_p0_co_rty
        pm_l3_p0_grp_pump
        pm_l3_p0_lco_data
        pm_l3_p0_lco_no_data
        pm_l3_p0_lco_rty
        pm_l3_p0_node_pump
        pm_l3_p0_pf_rty
        pm_l3_p0_sn_hit
        pm_l3_p0_sn_inv
        pm_l3_p0_sn_miss
        pm_l3_p0_sys_pump
        pm_l3_p1_co_l31
        pm_l3_p1_co_mem
        pm_l3_p1_co_rty
        pm_l3_p1_grp_pump
        pm_l3_p1_lco_data
        pm_l3_p1_lco_no_data
        pm_l3_p1_lco_rty
        pm_l3_p1_node_pump
        pm_l3_p1_pf_rty
        pm_l3_p1_sn_hit
        pm_l3_p1_sn_inv
        pm_l3_p1_sn_miss
        pm_l3_p1_sys_pump
        pm_l3_pf_hit_l3
        pm_l3_sys_guess_correct
        pm_l3_sys_guess_wrong
        pm_l3_trans_pf
        pm_l3_wi0_busy
        pm_l3_wi_usage
        pm_non_tm_rst_sc
        pm_rd_clearing_sc
        pm_rd_forming_sc
        pm_rd_hit_pf
        pm_snp_tm_hit_m
        pm_snp_tm_hit_t
        pm_st_caused_fail
        pm_tm_cam_overflow
        pm_tm_cap_overflow
        pm_tm_fav_caused_fail
        pm_tm_ld_caused_fail
        pm_tm_ld_conf
        pm_tm_rst_sc
        pm_tm_sc_co
        pm_tm_st_caused_fail
        pm_tm_st_conf
      Signed-off-by: default avatarMamatha Inamdar <mamatha4@linux.vnet.ibm.com>
      Acked-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Fixes: 2a81fa3b ("perf vendor events: Add power8 PMU events")
      Link: http://lkml.kernel.org/r/154953186583.11022.14819560028300370163.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c3b4d5c4
    • Andi Kleen's avatar
      perf stat: Improve scaling · 42a5864c
      Andi Kleen authored
      The multiplexing scaling in perf stat mysteriously adds 0.5 to the
      value. This dates back to the original perf tool. Other scaling code
      doesn't use that strange convention. Remove the extra 0.5.
      
      Before:
      
      $ perf stat -e 'cycles,cycles,cycles,cycles,cycles,cycles' grep -rq foo
      
       Performance counter stats for 'grep -rq foo':
      
               6,403,580      cycles                                                        (81.62%)
               6,404,341      cycles                                                        (81.64%)
               6,402,983      cycles                                                        (81.62%)
               6,399,941      cycles                                                        (81.63%)
               6,399,451      cycles                                                        (81.62%)
               6,436,105      cycles                                                        (91.87%)
      
             0.005843799 seconds time elapsed
      
             0.002905000 seconds user
             0.002902000 seconds sys
      
      After:
      
      $ perf stat -e 'cycles,cycles,cycles,cycles,cycles,cycles' grep -rq foo
      
       Performance counter stats for 'grep -rq foo':
      
               6,422,704      cycles                                                        (81.68%)
               6,401,842      cycles                                                        (81.68%)
               6,398,432      cycles                                                        (81.68%)
               6,397,098      cycles                                                        (81.68%)
               6,396,074      cycles                                                        (81.67%)
               6,434,980      cycles                                                        (91.62%)
      
             0.005884437 seconds time elapsed
      
             0.003580000 seconds user
             0.002356000 seconds sys
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      LPU-Reference: 20190314225002.30108-10-andi@firstfloor.org
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      42a5864c
    • Andi Kleen's avatar
      perf stat: Fix --no-scale · 75998bb2
      Andi Kleen authored
      The -c option to enable multiplex scaling has been useless for quite
      some time because scaling is default.
      
      It's only useful as --no-scale to disable scaling. But the non scaling
      code path has bitrotted and doesn't print anything because perf output
      code relies on value run/ena information.
      
      Also even when we don't want to scale a value it's still useful to show
      its multiplex percentage.
      
      This patch:
        - Fixes help and documentation to show --no-scale instead of -c
        - Removes -c, only keeps the long option because -c doesn't support negatives.
        - Enables running/enabled even with --no-scale
        - And fixes some other problems in the no-scale output.
      
      Before:
      
        $ perf stat --no-scale -e cycles true
      
         Performance counter stats for 'true':
      
             <not counted>      cycles
      
               0.000984154 seconds time elapsed
      
      After:
      
        $ ./perf stat --no-scale -e cycles true
      
         Performance counter stats for 'true':
      
                   706,070      cycles
      
               0.001219821 seconds time elapsed
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      LPU-Reference: 20190314225002.30108-9-andi@firstfloor.org
      Link: https://lkml.kernel.org/n/tip-xggjvwcdaj2aqy8ib3i4b1g6@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      75998bb2
    • Andi Kleen's avatar
      perf script: Support relative time · 90b10f47
      Andi Kleen authored
      When comparing time stamps in 'perf script' traces it can be annoying to
      work with the full perf time stamps.
      
      Add a --reltime option that displays time stamps relative to the trace
      start to make it easier to read the traces.
      
      Note: not currently supported for --time. Report an error in this
      case.
      
      Before:
      
        % perf script
            swapper 0 [000] 245402.891216:    1 cycles:ppp: ffffffffa0068814 native_write_msr+0x4 ([kernel.kallsyms])
            swapper 0 [000] 245402.891223:    1 cycles:ppp: ffffffffa0068814 native_write_msr+0x4 ([kernel.kallsyms])
            swapper 0 [000] 245402.891227:    5 cycles:ppp: ffffffffa0068814 native_write_msr+0x4 ([kernel.kallsyms])
            swapper 0 [000] 245402.891231:   41 cycles:ppp: ffffffffa0068816 native_write_msr+0x6 ([kernel.kallsyms])
            swapper 0 [000] 245402.891235:  355 cycles:ppp: ffffffffa000dd51 intel_bts_enable_local+0x21 ([kernel.kallsyms])
            swapper 0 [000] 245402.891239: 3084 cycles:ppp: ffffffffa0a0150a end_repeat_nmi+0x48 ([kernel.kallsyms])
      
      After:
      
        % perf script --reltime
      
            swapper 0 [000]     0.000000:    1 cycles:ppp: ffffffffa0068814 native_write_msr+0x4 ([kernel.kallsyms])
            swapper 0 [000]     0.000006:    1 cycles:ppp: ffffffffa0068814 native_write_msr+0x4 ([kernel.kallsyms])
            swapper 0 [000]     0.000010:    5 cycles:ppp: ffffffffa0068814 native_write_msr+0x4 ([kernel.kallsyms])
            swapper 0 [000]     0.000014:   41 cycles:ppp: ffffffffa0068816 native_write_msr+0x6 ([kernel.kallsyms])
            swapper 0 [000]     0.000018:  355 cycles:ppp: ffffffffa000dd51 intel_bts_enable_local+0x21 ([kernel.kallsyms])
            swapper 0 [000]     0.000022: 3084 cycles:ppp: ffffffffa0a0150a end_repeat_nmi+0x48 ([kernel.kallsyms])
      
      Committer notes:
      
      Do not use 'time' as the name of a variable, as this breaks the build on
      older glibcs:
      
        cc1: warnings being treated as errors
        builtin-script.c: In function 'perf_sample__fprintf_start':
        builtin-script.c:691: warning: declaration of 'time' shadows a global declaration
        /usr/include/time.h:187: warning: shadowed declaration is here
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      LPU-Reference: 20190314225002.30108-8-andi@firstfloor.org
      Link: https://lkml.kernel.org/n/tip-bpahyi6pr9r399mvihu65fvc@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      90b10f47
    • Andi Kleen's avatar
      perf report: Indicate JITed code better in report · a4e7e6ef
      Andi Kleen authored
      Print [TID] tid %d instead of the crypted /tmp/perf-%d.map default.
      
      % cat >loop.java
        public class loop {
                public static void main(String[] args)
                {
                        for (;;);
                }
        }
        ^D
        % javac loop.java
        % perf record java loop
        ^C
      
      Before:
      
        % perf report --stdio
        ...
            56.09%  java     perf-34724.map      [.] 0x00007fd5bd021896
            19.12%  java     perf-34724.map      [.] 0x00007fd5bd021887
             9.79%  java     perf-34724.map      [.] 0x00007fd5bd021783
             8.97%  java     perf-34724.map      [.] 0x00007fd5bd02175b
      
      After:
      
        % perf report --stdio
        ...
            56.09%  java     [JIT] tid 34724     [.] 0x00007fd5bd021896
            19.12%  java     [JIT] tid 34724     [.] 0x00007fd5bd021887
             9.79%  java     [JIT] tid 34724     [.] 0x00007fd5bd021783
             8.97%  java     [JIT] tid 34724     [.] 0x00007fd5bd02175b
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      LPU-Reference: 20190314225002.30108-7-andi@firstfloor.org
      Link: https://lkml.kernel.org/n/tip-r17l6py9g0sezb7mi1f286gt@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a4e7e6ef
    • Andi Kleen's avatar
      perf report: Show all sort keys in help output · 702fb9b4
      Andi Kleen authored
      Show all the supported sort keys in the command line help output, so
      that it's not needed to refer to the manpage.
      
      Before:
      
        % perf report -h
        ...
             -s, --sort <key[,key2...]>
                                  sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ... Please refer the man page for the complete list.
      
      After:
      
        % perf report -h
        ...
            -s, --sort <key[,key2...]>
                                  sort by key(s): overhead overhead_sys overhead_us overhead_guest_sys overhead_guest_us overhead_children sample period pid comm dso symbol parent cpu ...
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      LPU-Reference: 20190314225002.30108-5-andi@firstfloor.org
      Link: https://lkml.kernel.org/n/tip-9r3uz2ch4izoi1uln3f889co@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      702fb9b4
    • Andi Kleen's avatar
      perf record: Clarify help for --switch-output · c38dab7d
      Andi Kleen authored
      The help description for --switch-output looks like there are multiple
      comma separated fields. But it's actually a choice of different options.
      Make it clear and less confusing.
      
      Before:
      
        % perf record -h
        ...
                --switch-output[=<signal,size,time>]
                                  Switch output when receive SIGUSR2 or cross size,time threshold
      
      After:
      
        % perf record -h
        ...
      
                --switch-output[=<signal or size[BKMG] or time[smhd]>]
                                  Switch output when receiving SIGUSR2 (signal) or cross a size or time threshold
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      LPU-Reference: 20190314225002.30108-4-andi@firstfloor.org
      Link: https://lkml.kernel.org/n/tip-9yecyuha04nyg8toyd1b2pgi@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c38dab7d
    • Andi Kleen's avatar
      perf record: Allow to limit number of reported perf.data files · 03724b2e
      Andi Kleen authored
      When doing long term recording and waiting for some event to snapshot
      on, we often only care about the last minute or so.
      
      The --switch-output command line option supports rotating the perf.data
      file when the size exceeds a threshold. But the disk would still be
      filled with unnecessary old files.
      
      Add a new option to only keep a number of rotated files, so that the
      disk space usage can be limited.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      LPU-Reference: 20190314225002.30108-3-andi@firstfloor.org
      Link: https://lkml.kernel.org/n/tip-y5u2lik0ragt4vlktz6qc9ks@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      03724b2e
    • Andi Kleen's avatar
      perf list: Filter metrics too · 6f40b2a5
      Andi Kleen authored
      When a filter is specified on the command line, filter the metrics too.
      
      Before:
      
        % perf list foo
        List of pre-defined events (to be used in -e):
      
        Metric Groups:
      
        DSB:
          DSB_Coverage
               [Fraction of Uops delivered by the DSB (aka Decoded Icache; or Uop Cache)]
        ... more metrics ...
      
      After:
      
      % perf list foo
      
        List of pre-defined events (to be used in -e):
      
        Metric Groups:
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      LPU-Reference: 20190314225002.30108-1-andi@firstfloor.org
      Link: https://lkml.kernel.org/n/tip-1y8oi2s8c4jhjtykgs5zvda1@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6f40b2a5
  2. 11 Mar, 2019 15 commits