Skip to content
  1. Feb 21, 2019
    • Jiri Olsa's avatar
      perf script: Allow +- operator for type specific fields option · 6ef362fd
      Jiri Olsa authored
      
      
      Add support to add/remove fields for specific event types in -F option.
      It's now possible to use '+-' after event type, like:
      
        # cat > test.c
        #include <stdio.h>
      
        int main(void)
        {
           printf("Hello world\n");
           while(1) {}
        }
        ^D
        # gcc -g -o test test.c
        # perf probe -x test 'test.c:5'
        # perf record -e '{cpu/cpu-cycles,period=10000/,probe_test:main}:S' ./test
        ...
      
        # perf script -Ftrace:+period,-cpu
                  test  3859 396291.117343:      10275 cpu/cpu-cycles,period=10000/:      7f..
                  test  3859 396291.118234:      11041 cpu/cpu-cycles,period=10000/:  ffffff..
                  test  3859 396291.118234:          1              probe_test:main:
                  test  3859 396291.118248:       8668 cpu/cpu-cycles,period=10000/:  ffffff..
                  test  3859 396291.118263:      10139 cpu/cpu-cycles,period=10000/:  ffffff..
      
      Committer testing:
      
      Couldn't make the test above work, but tested it with:
      
        # perf probe -x hello main
        Added new event:
          probe_hello:main     (on main in /home/acme/c/hello)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe_hello:main -aR sleep 1
      
        # perf record -e probe_hello:main ./hello
        hello, world
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.025 MB perf.data (1 samples) ]
        # perf script
                 hello 21454 [002] 254116.874005: probe_hello:main: (401126)
        #
        # perf script -Ftrace:+period,-cpu
                 hello 21454 254116.874005:          1 probe_hello:main: (401126)
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190220122800.864-4-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6ef362fd
    • Jiri Olsa's avatar
      perf evsel: Force sample_type for slave events · 6e7e8b9f
      Jiri Olsa authored
      
      
      Force sample_type setup for slave events in group leader sessions.
      
      We don't get sample for slave events, we make them when delivering group
      leader sample. Set the slave event to follow the master sample_type to
      ease up report.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190220122800.864-3-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6e7e8b9f
    • Jiri Olsa's avatar
      perf session: Don't report zero period samples for slave events · 529c1a9e
      Jiri Olsa authored
      
      
      There's no reason to deliver a sample with zero period.  It means there
      was no value for slave event since its last group leader sample.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190220122800.864-2-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      529c1a9e
  2. Feb 20, 2019
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Allow dumping a BPF map after setting up BPF events · ff7a4f98
      Arnaldo Carvalho de Melo authored
      Initial use case:
      
      Dumping the maps setup by tools/perf/examples/bpf/augmented_raw_syscalls.c,
      which so far are just booleans, showing just non-zeroed entries:
      
        # cat ~/.perfconfig
        [llvm]
      	dump-obj = true
      	clang-opt = -g
        [trace]
      	#add_events = /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
      	add_events = /wb/augmented_raw_syscalls.o
        $ date
        Tue Feb 19 16:29:33 -03 2019
        $ ls -la /wb/augmented_raw_syscalls.o
        -rwxr-xr-x. 1 root root 14048 Jan 24 12:09 /wb/augmented_raw_syscalls.o
        $ file /wb/augmented_raw_syscalls.o
        /wb/augmented_raw_syscalls.o: ELF 64-bit LSB relocatable, eBPF, version 1 (SYSV), with debug_info, not stripped
        $
        # trace -e recvmmsg,sendmmsg --map-dump foobar
        ERROR: BPF map "foobar" not found
        # trace -e recvmmsg,sendmmsg --map-dump filtered_pids
        ERROR: BPF map "filtered_pids" not found
        # trace -e recvmmsg,sendmmsg --map-dump pids_filtered
        [2583] = 1,
        [2267] = 1,
        ^Z
        [1]+  Stopped                 trace -e recvmmsg,sendmmsg --map-dump pids_filtered
        # pidof trace
        2267
        # ps ax|grep gnome-terminal|grep -v grep
        2583 ?        Ssl   58:33 /usr/libexec/gnome-terminal-server
        ^C
        # trace -e recvmmsg,sendmmsg --map-dump syscalls
        [299] = 1,
        [307] = 1,
        ^C
        # grep x64_recvmmsg arch/x86/entry/syscalls/syscall_64.tbl
        299	64	recvmmsg		__x64_sys_recvmmsg
        # grep x64_sendmmsg arch/x86/entry/syscalls/syscall_64.tbl
        307	64	sendmmsg		__x64_sys_sendmmsg
        #
      
      Next step probably will be something like 'perf stat's --interval-print and
      --interval-clear.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lkml.kernel.org/n/tip-ztxj25rtx37ixo9cfajt8ocy@git.kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ff7a4f98
    • Arnaldo Carvalho de Melo's avatar
      perf bpf: Add bpf_map dumper · d19f8564
      Arnaldo Carvalho de Melo authored
      At some point I'll suggest moving this to libbpf, for now I'll
      experiment with ways to dump BPF maps set by events in 'perf trace',
      starting with a very basic dumper for the current very limited needs
      of the augmented_raw_syscalls code: dumping booleans.
      
      Having functions that apply to the map keys and values and do table
      lookup in things like syscall id to string tables should come next.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lkml.kernel.org/n/tip-lz14w0esqyt1333aon05jpwc@git.kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d19f8564
    • Thomas Richter's avatar
      perf test: Fix failure of 'evsel-tp-sched' test on s390 · 03d30971
      Thomas Richter authored
      Commit 489338a7 ("perf tests evsel-tp-sched: Fix bitwise operator")
      causes test case 14 "Parse sched tracepoints fields" to fail on s390.
      
      This test succeeds on x86.
      
      In fact this test now fails on all architectures with type char treated
      as type unsigned char.
      
      The root cause is the signed-ness of character arrays in the tracepoints
      sched_switch for structure members prev_comm and next_comm.
      
      On s390 the output of:
      
       [root@m35lp76 perf]# cat /sys/kernel/debug/tracing/events/sched/sched_switch/format
       name: sched_switch
       ID: 287
       format:
         field:unsigned short common_type; offset:0; size:2;	signed:0;
         ...
         field:char prev_comm[16]; offset:8; size:16;	signed:0;
         ...
         field:char next_comm[16]; offset:40; size:16; signed:0;
      
      reveals the character arrays prev_comm and next_comm are per
      default unsigned char and have values in the range of 0..255.
      
      On x86 both fields are signed as this output shows:
       [root@f29]# cat /sys/kernel/debug/tracing/events/sched/sched_switch/format
       name: sched_switch
       ID: 287
       format:
         field:unsigned short common_type; offset:0; size:2;	signed:0;
         ...
         field:char prev_comm[16]; offset:8; size:16;	signed:1;
         ...
         field:char next_comm[16]; offset:40; size:16; signed:1;
      
      and the character arrays prev_comm and next_comm are per default signed
      char and have values in the range of -1..127.  The implementation of
      type char is architecture specific.
      
      Since the character arrays in both tracepoints sched_switch and
      sched_wakeup should contain ascii characters, simply omit the check for
      signedness in the test case.
      
      Output before:
      
        [root@m35lp76 perf]# ./perf test -F 14
        14: Parse sched tracepoints fields                        :
        --- start ---
        sched:sched_switch: "prev_comm" signedness(0) is wrong, should be 1
        sched:sched_switch: "next_comm" signedness(0) is wrong, should be 1
        sched:sched_wakeup: "comm" signedness(0) is wrong, should be 1
        ---- end ----
        14: Parse sched tracepoints fields                        : FAILED!
        [root@m35lp76 perf]#
      
      Output after:
      
        [root@m35lp76 perf]# ./perf test -Fv 14
        14: Parse sched tracepoints fields                        :
        --- start ---
        ---- end ----
        Parse sched tracepoints fields: Ok
        [root@m35lp76 perf]#
      
      Fixes: 489338a7
      
       ("perf tests evsel-tp-sched: Fix bitwise operator")
      
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20190219153639.31267-1-tmricht@linux.ibm.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      03d30971
    • Jonas Rabenstein's avatar
      perf doc: Fix documentation of the Flags section in perf.data · 8c23a522
      Jonas Rabenstein authored
      
      
      According to the current documentation the flags section is placed after
      the file header itself but the code assumes to find the flags section
      after the data section. This change updates the documentation to that
      assumption.
      
      Signed-off-by: default avatarJonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lkml.kernel.org/r/20190219154515.3954-2-jonas.rabenstein@studium.uni-erlangen.de
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8c23a522
    • Jonas Rabenstein's avatar
      perf doc: Fix HEADER_CMDLINE description in perf.data documentation · 7a663c0f
      Jonas Rabenstein authored
      
      
      The content of the HEADER_CMDLINE feature header is a perf_header_string_list
      of the argument vector and not a perf_header_string of the commandline.
      
      Signed-off-by: default avatarJonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lkml.kernel.org/r/20190219154515.3954-1-jonas.rabenstein@studium.uni-erlangen.de
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7a663c0f
  3. Feb 19, 2019
  4. Feb 16, 2019
  5. Feb 15, 2019
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-5.1-20190214' of... · 43f4e627
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-5.1-20190214' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
       into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      perf list:
      
        Jiri Olsa:
      
        - Display metric expressions for --details option
      
      perf record:
      
        Alexey Budankov:
      
        - Implement --affinity=node|cpu option, leftover, the other patches
          in this kit were already applied.
      
      perf trace:
      
        Arnaldo Carvalho de Melo:
      
        - Fix segfaults due to not properly handling negative file descriptor syscall args.
      
        - Fix segfault related to the 'waitid' 'options' prefix showing logic.
      
        - Filter out 'gnome-terminal*' if it is a parent of 'perf trace', to reduce the
          syscall feedback loop in system wide sessions.
      
      BPF:
      
        Song Liu:
      
        - Silence "Couldn't synthesize bpf events" warning for EPERM.
      
      Build system:
      
        Arnaldo Carvalho de Melo:
      
        - Fix the test-all.c feature detection fast path that was broken for
          quite a while leading to longer build times.
      
      Event parsing:
      
        Jiri Olsa:
      
        - Fix legacy events symbol separator parsing
      
      cs-etm:
      
        Mathieu Poirier:
      
        - Fix some error path return errors and plug some memory leaks.
      
        - Add proper header file for symbols
      
        - Remove unused structure fields.
      
        - Modularize auxtrace_buffer fetch, decoder and packet processing loop.
      
      Vendor events:
      
        Paul Clarke:
      
        - Add assorted metrics for the Power8 and Power9 architectures.
      
      perf report:
      
        Thomas Richter:
      
        - Add s390 diagnostic sampling descriptor size
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      43f4e627
    • Arnaldo Carvalho de Melo's avatar
      tools build feature sched_getcpu: Undef _GNU_SOURCE at the end · 44ec8396
      Arnaldo Carvalho de Melo authored
      
      
      Since this feature test is included in test-all.c, the feature detection
      fast path compile/link phase, it can't leave any defines behind, as it
      can affect the tests included after it, so remove it.
      
      Reported-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lkml.kernel.org/n/tip-lg3kpd9tzypc797vb1f42u6k@git.kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      44ec8396
    • Jiri Olsa's avatar
      perf header: Remove unused 'cpu_nr' field from 'struct cpu_topo' · aa4df30d
      Jiri Olsa authored
      
      
      Not used at all.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-9-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      aa4df30d
    • Jiri Olsa's avatar
      perf header: Get rid of write_it label · a9aeb87b
      Jiri Olsa authored
      
      
      Simplifying the code a bit.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-8-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a9aeb87b
    • Jiri Olsa's avatar
      perf list: Display metric expressions for --details option · 33bbc571
      Jiri Olsa authored
      
      
      Display metric expression itself when --details is specified.
      
      Current list with no details:
      
        # perf list metrics
        ...
        TopDownL1:
          IPC
               [Instructions Per Cycle (per logical thread)]
          SLOTS
               [Total issue-pipeline slots]
        ...
      
      Detailed output with metric formula:
      
        # perf list --details metrics
        ...
        TopDownL1:
          IPC
               [Instructions Per Cycle (per logical thread)]
               [inst_retired.any / cpu_clk_unhalted.thread]
          SLOTS
               [Total issue-pipeline slots]
               [4*(( cpu_clk_unhalted.thread_any / 2 ) if #smt_on else cycles)]
        ...
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-6-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      33bbc571
    • Jiri Olsa's avatar
      perf tools: Fix legacy events symbol separator parsing · 714a92d8
      Jiri Olsa authored
      
      
      Fixing legacy symbol events parsing. We can't support single slash
      separator, like 'cycles/u', because it conflicts with non empty terms,
      like 'cycles/period/u'.
      
      Keeping only '//' and ':' separator for these events:
        cycles//u
        cycles:k
      
      And removing '/' separator support, which is not working
      anymore. Also adding automated tests for above events.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-5-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      714a92d8
    • Jiri Olsa's avatar
      perf tools: Rename build libperf to perf · 5ff32883
      Jiri Olsa authored
      
      
      Rename build libperf to perf, because it's used to build perf.
      
      The libperf build object name will be used for libperf library.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-4-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5ff32883
    • Jiri Olsa's avatar
      perf tools: Rename LIB_FILE to LIBPERF_A · 6368942a
      Jiri Olsa authored
      
      
      Simple rename, no functional change.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-3-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6368942a
    • Jiri Olsa's avatar
      perf tools: Compile perf with libperf-in.o instead of libperf.a · d0bfbeda
      Jiri Olsa authored
      
      
      There's no need for perf build to use libperf.a,
      we can use directly libperf-in.o.
      
      The libperf.a stays as a target if needed:
      
        $ make libperf.a
        ...
          CC       util/pmu.o
          CC       util/pmu-flex.o
          LD       util/libperf-in.o
          LD       libperf-in.o
          AR       libperf.a
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190213123246.4015-2-jolsa@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d0bfbeda
    • Mathieu Poirier's avatar
      perf cs-etm: Modularize auxtrace_buffer fetch function · 8224531c
      Mathieu Poirier authored
      
      
      Making the auxtrace_buffer fetch function modular so that it can be
      called from different decoding context (timeless vs. non-timeless),
      avoiding to repeat code.
      
      No change in functionality is introduced by this patch.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-14-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8224531c
    • Mathieu Poirier's avatar
      perf cs-etm: Modularize main packet processing loop · 3fa0e83e
      Mathieu Poirier authored
      
      
      Making the main packet processing loop modular so that it can be called
      from different decoding context (timeless vs. non-timless), avoiding to
      repeat code.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-13-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3fa0e83e
    • Mathieu Poirier's avatar
      perf cs-etm: Modularize main decoder function · f74f349c
      Mathieu Poirier authored
      
      
      Making the main decoder block modular so that it can be called from
      different decoding context (timeless vs. non-timeless), avoiding
      to repeat code.
      
      No change in functionality is introduced by this patch.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-12-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f74f349c
    • Mathieu Poirier's avatar
      perf cs-etm: Make cs_etm__run_decoder() queue independent · 23cfcd6d
      Mathieu Poirier authored
      
      
      This patch makes decoding of auxtrace buffer centered around a struct
      cs_etm_queue.  This eliminates surperflous variables and is a precursor
      for work that simplifies the main decoder loop.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-11-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      23cfcd6d
    • Mathieu Poirier's avatar
      perf cs-etm: Rethink kernel address initialisation · 4b6df11a
      Mathieu Poirier authored
      
      
      Moving initialisation of the kernel start address to function
      cs_etm__setup_queues(), considered to be the common denominator for
      queue initialisation.  That way we don't have to repeat the same code
      at different places.
      
      No change of functionatlity is introduced by this patch.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-10-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4b6df11a
    • Mathieu Poirier's avatar
      perf cs-etm: Cleaning up function cs_etm__alloc_queue() · 4f5b3713
      Mathieu Poirier authored
      
      
      Function cs_etm__alloc_queue() should only be concerned with the allocation
      of memory for the etmq and accompanying decoder.  Everything else should
      be done in the calling function.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-9-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4f5b3713
    • Mathieu Poirier's avatar
      perf cs-etm: Fix erroneous comment · e4aa592d
      Mathieu Poirier authored
      
      
      The comment just before initialising the decoder is plane wrong since it
      is part of the decoding queue setup function and the operation code
      specifically mention that trace data is to be decoded rather than printed
      out.
      
      This patch simply fix the comment to prevent people from getting really
      confused.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-8-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e4aa592d
    • Mathieu Poirier's avatar
      perf cs-etm: Introducing function cs_etm__init_trace_params() · 2507a3d9
      Mathieu Poirier authored
      
      
      The trace parameter initialisation code is repeated in two different
      places, something that bloats the file and can lead to errors.  This
      is fixed by introducing a helper function and calling the right
      protocol initialisation code when required.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-7-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2507a3d9
    • Mathieu Poirier's avatar
      perf cs-etm: Fix memory leak in error path · ae4d9f52
      Mathieu Poirier authored
      
      
      Memory allocated for variable 't_params' isn't released properly in the
      error path of function cs_etm_queue *cs_etm__alloc_queue() and
      cs_etm__dump_event(), something this patch addresses.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-6-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ae4d9f52
    • Mathieu Poirier's avatar
      perf cs-etm: Introducing function cs_etm_decoder__init_dparams() · 65963e5b
      Mathieu Poirier authored
      
      
      Introducing function cs_etm_decoder__init_dparams() to avoid repeating
      code at two different places.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-5-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      65963e5b
    • Mathieu Poirier's avatar
      perf cs-etm: Fix wrong return values in error path · d3267ad4
      Mathieu Poirier authored
      
      
      Function cs_etm__mem_access() is supposed to return a u32 but the error
      path returns negative values at a couple of places, something that really
      throws off the clients using it.  Fix the situation by return '0'.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-4-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d3267ad4
    • Mathieu Poirier's avatar
      perf cs-etm: Remove unused structure field "time" and "timestamp" · fc7ac413
      Mathieu Poirier authored
      
      
      Field "time" and "timestamp" in structure cs_etm_queue are no longer
      used and need to be removed.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-3-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fc7ac413
    • Mathieu Poirier's avatar
      perf cs-etm: Remove unused structure field "state" · b611f63b
      Mathieu Poirier authored
      
      
      Field "state" in structure cs_etm_queue is no longer used and needs
      to be removed.
      
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki K Poulouse <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: http://lkml.kernel.org/r/20190212171618.25355-2-mathieu.poirier@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b611f63b
    • Arnaldo Carvalho de Melo's avatar
      perf build: Add missing FEATURE_CHECK_LDFLAGS-libcrypto · 271402a3
      Arnaldo Carvalho de Melo authored
      When the libcrypto feature test was added we forgot to add its
      FEATURE_CHECK_LDFLAGS pointing to the library needed to link with the
      test-all.bin feature test fast path binary, so even when it was
      introduced we got this:
      
        $ cat /tmp/build/perf/feature/test-all.make.output
        /usr/bin/ld: /tmp/ccjKeJJU.o: in function `main_test_libcrypto':
        /home/acme/git/perf/tools/build/feature/test-libcrypto.c:10: undefined reference to `MD5_Init'
        /usr/bin/ld: /home/acme/git/perf/tools/build/feature/test-libcrypto.c:11: undefined reference to `MD5_Update'
        /usr/bin/ld: /home/acme/git/perf/tools/build/feature/test-libcrypto.c:12: undefined reference to `MD5_Final'
        /usr/bin/ld: /home/acme/git/perf/tools/build/feature/test-libcrypto.c:14: undefined reference to `SHA1'
        collect2: error: ld returned 1 exit status
        $ cat /tmp/build/perf/feature/test-libcrypto.
        test-libcrypto.bin          test-libcrypto.d            test-libcrypto.make.output
        $ cat /tmp/build/perf/feature/test-libcrypto.make.output
        $
      
      Fix it, so that we keep the fast path, which, at this point, will fail
      with the unwind-ARCH feature tests, that will be fixed in a followup
      patch:
      
        $ make -C tools/perf O=/tmp/build/perf
        ...                     libcrypto: [ on  ]
         <SNIP>
        $ cat /tmp/build/perf/feature/test-all.make.output
        $ ldd /tmp/build/perf/feature/test-all.bin | grep libcrypto
      	libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f9892805000)
        $
        $ grep libcrypto /tmp/build/perf/FEATURE-DUMP
        feature-libcrypto=1
        $
      
      With the unwind-ARCH tests fixed, we now finally manage to get
      test-all.bin built and linked with the features it tests, among them the
      ones fixed in this patchkit:
      
        $ ldd /tmp/build/perf/feature/test-all.bin  | egrep 'unwind|crypto'
      	libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f95cf2b8000)
      	libunwind-x86_64.so.8 => /lib64/libunwind-x86_64.so.8 (0x00007f95cf294000)
      	libunwind.so.8 => /lib64/libunwind.so.8 (0x00007f95cf278000)
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Carl Love <cel@us.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John McCutchan <johnmccutchan@google.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pawel Moll <pawel.moll@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sonny Rao <sonnyrao@chromium.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Fixes: 8ee46460 ("perf build: Add libcrypto feature detection")
      Link: https://lkml.kernel.org/n/tip-rexc248jorf5b4l3qjn888cz@git.kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      271402a3
    • Arnaldo Carvalho de Melo's avatar
      tools build: Add test-reallocarray.c to test-all.c to fix the build · a96c03e8
      Arnaldo Carvalho de Melo authored
      
      
      When a test is in the FEATURE_TESTS_BASIC list in tools/build/Makefile.feature
      must be added to tools/build/feature/test-all.c, because the successfull
      compilation and linking of that test-all.bin file means that all the
      features listed in FEATURE_TESTS_BASIC are present in the system, so we
      don't have to go on feature by feature test building them.
      
      Since reallocarray() is expected to be present in modern systems, it has
      a place in FEATURE_TESTS_BASIC, so that we speed up the build process
      building just that file.
      
      For older systems, such as ubuntu:16.04 (build failure reported by Jin
      Yao) debian:8, and for the current flagship RHEL distro, RHEL7, the
      build will fail as test-all.bin (without test-reallocarray.c included)
      passes but reallocarray() isn't present, making the build fail with:
      
          CC       /tmp/build/perf/libbpf.o
          MKDIR    /tmp/build/perf/fs/
          CC       /tmp/build/perf/fs/tracing_path.o
          LD       /tmp/build/perf/fd/libapi-in.o
          CC       /tmp/build/perf/bpf.o
        libbpf.c: In function 'bpf_object__add_program':
        libbpf.c:367:10: error: implicit declaration of function 'reallocarray' [-Werror=implicit-function-declaration]
          progs = reallocarray(progs, nr_progs + 1, sizeof(progs[0]));
                  ^
        libbpf.c:367:2: error: nested extern declaration of 'reallocarray' [-Werror=nested-externs]
          progs = reallocarray(progs, nr_progs + 1, sizeof(progs[0]));
          ^
        libbpf.c:367:8: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
          progs = reallocarray(progs, nr_progs + 1, sizeof(progs[0]));
                ^
        libbpf.c: In function 'bpf_object__elf_collect':
        libbpf.c:887:10: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
            reloc = reallocarray(reloc, nr_reloc,
                  ^
        libbpf.c: In function 'bpf_program__reloc_text':
        libbpf.c:1394:12: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
           new_insn = reallocarray(prog->insns, new_cnt, sizeof(*insn));
                    ^
          CC       /tmp/build/perf/nlattr.o
      
      Even with:
      
        $ grep reallocarray /tmp/build/perf/FEATURE-DUMP
        feature-reallocarray=1
        $
      
      Which ubuntu:16.04.5 LTS doesn't have:
      
        perfbuilder@38a153a1bba8:/$ head -2 /etc/os-release
        NAME="Ubuntu"
        VERSION="16.04.5 LTS (Xenial Xerus)"
        perfbuilder@38a153a1bba8:/$ find /usr/include/ -name "*.h" | xargs grep -w reallocarray
        perfbuilder@38a153a1bba8:/$
      
      Fix it by including it to test-all.c, which ends up forcing the
      individual tests to be triggered and for the build process to notice
      that indeed reallocarray() is not there:
      
        perfbuilder@38a153a1bba8:/$ cat /tmp/build/perf/feature/test-all.make.output
        In file included from test-all.c:178:0:
        test-reallocarray.c: In function 'main_test_reallocarray':
        test-reallocarray.c:7:11: error: implicit declaration of function 'reallocarray' [-Werror=implicit-function-declaration]
          return !!reallocarray(NULL, 1, 1);
                   ^
        cc1: all warnings being treated as errors
        perfbuilder@38a153a1bba8:/$
      
      That is the only test that is failing on Ubuntu 16.03.5 LTS, so all
      tests are forced:
      
        perfbuilder@38a153a1bba8:/tmp/build/perf/feature$ ls -lSr *.make.output
        <SNIP successful tests>
        -rw-r--r--. 1 perfbuilder perfbuilder   0 Feb 14 15:00 test-dwarf.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder   0 Feb 14 14:16 test-cplus-demangle.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder   0 Feb 14 15:00 test-bpf.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder   0 Feb 14 15:00 test-backtrace.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder 104 Feb 14 15:00 test-bionic.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder 107 Feb 14 15:00 test-libunwind-x86.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder 115 Feb 14 15:00 test-libunwind-aarch64.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder 122 Feb 14 15:00 test-libbabeltrace.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder 254 Feb 14 15:00 test-reallocarray.make.output
        -rw-r--r--. 1 perfbuilder perfbuilder 312 Feb 14 15:00 test-all.make.output
        perfbuilder@38a153a1bba8:/tmp/build/perf/feature$
      
      And that reallocarray() one shows:
      
        perfbuilder@38a153a1bba8:/tmp/build/perf/feature$ cat test-reallocarray.make.output
        test-reallocarray.c: In function 'main':
        test-reallocarray.c:7:11: error: implicit declaration of function 'reallocarray' [-Werror=implicit-function-declaration]
          return !!reallocarray(NULL, 1, 1);
                   ^
        cc1: all warnings being treated as errors
        perfbuilder@38a153a1bba8:/tmp/build/perf/feature$
      
      Which now generates the expected result:
      
        perfbuilder@38a153a1bba8:~$ grep reallocarray /tmp/build/perf/FEATURE-DUMP
        feature-reallocarray=0
        perfbuilder@38a153a1bba8:~$
      
      The fallback mechanism kicks in and libbpf and perf are again buildable
      in systems without reallocarray():
      
        $ cat tools/include/tools/libc_compat.h
        // SPDX-License-Identifier: (LGPL-2.0+ OR BSD-2-Clause)
        /* Copyright (C) 2018 Netronome Systems, Inc. */
      
        #ifndef __TOOLS_LIBC_COMPAT_H
        #define __TOOLS_LIBC_COMPAT_H
      
        #include <stdlib.h>
        #include <linux/overflow.h>
      
        #ifdef COMPAT_NEED_REALLOCARRAY
        static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
        {
      	  size_t bytes;
      
      	  if (unlikely(check_mul_overflow(nmemb, size, &bytes)))
      		  return NULL;
      	  return realloc(ptr, bytes);
        }
        #endif
        #endif
        $
      
      Reported-by: default avatarJin Yao <yao.jin@linux.intel.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Fixes: 531b014e ("tools: bpf: make use of reallocarray")
      Link: https://lkml.kernel.org/n/tip-aonqku8axii8rxki5g11w40b@git.kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a96c03e8
    • Arnaldo Carvalho de Melo's avatar
      perf unwind: Do not put libunwind-{x86,aarch64} in FEATURE_TESTS_BASIC · 5c4d7c82
      Arnaldo Carvalho de Melo authored
      As it is not normally available on x86_64 not being tested on test-all.c
      but being in FEATURE_TESTS_BASIC ends up implying that those features
      are present, which leads to trying to link with those libraries and a
      build failure now that test-all.c is finally again building
      successfully:
      
        /usr/bin/ld: cannot find -lunwind-x86
        /usr/bin/ld: cannot find -lunwind-aarch64
        collect2: error: ld returned 1 exit status
        make[3]: *** [Makefile:199: /tmp/build/perf/plugin_jbd2.so] Error 1
        make[3]: *** Waiting for unfinished jobs....
        /usr/bin/ld: cannot find -lunwind-x86
        /usr/bin/ld: cannot find -lunwind-aarch64
      
      So remove those features from there and explicitely test them.
      
      And then move this patch to just before the last one that allows this to
      be exposed, so that we keep the tree bisectable.
      
      With all this in place we get, at this point:
      
        $ ldd /tmp/build/perf/feature/test-libunwind.bin
      	linux-vdso.so.1 (0x00007fffa09c6000)
      	libunwind-x86_64.so.8 => /lib64/libunwind-x86_64.so.8 (0x00007fbcf4451000)
      	libunwind.so.8 => /lib64/libunwind.so.8 (0x00007fbcf4435000)
      	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fbcf440c000)
      	libelf.so.1 => /lib64/libelf.so.1 (0x00007fbcf43f2000)
      	libc.so.6 => /lib64/libc.so.6 (0x00007fbcf422c000)
      	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fbcf4211000)
      	/lib64/ld-linux-x86-64.so.2 (0x00007fbcf4491000)
      	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fbcf41ed000)
      	libz.so.1 => /lib64/libz.so.1 (0x00007fbcf41d3000)
        $ cat /tmp/build/perf/feature/test-libunwind-x86.make.output
        test-libunwind-x86.c:2:10: fatal error: libunwind-x86.h: No such file or directory
         #include <libunwind-x86.h>
                  ^~~~~~~~~~~~~~~~~
        compilation terminated.
        $ cat /tmp/build/perf/feature/test-libunwind-aarch64.make.output
        test-libunwind-aarch64.c:2:10: fatal error: libunwind-aarch64.h: No such file or directory
        #include <libunwind-aarch64.h>
                 ^~~~~~~~~~~~~~~~~~~~~
        compilation terminated.
        $
        $ ldd ~/bin/perf | grep unwind
      	libunwind-x86_64.so.8 => /lib64/libunwind-x86_64.so.8 (0x00007f5ceb24b000)
      	libunwind.so.8 => /lib64/libunwind.so.8 (0x00007f5ceb22f000)
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Link: https://lkml.kernel.org/n/tip-vs6kwqsvwk7oxhs6z9mq87pp@git.kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5c4d7c82
    • Arnaldo Carvalho de Melo's avatar
      perf coresight: Do not test for libopencsd by default · 1c3b28fd
      Arnaldo Carvalho de Melo authored
      Since it is not yet that generally available, avoid testing for the
      presence of libcoresight in the fast path test-all.bin feature test.
      
        # dnf search opencsd
        No matches found.
        # dnf search OpenCSD
        No matches found.
        # cat /etc/fedora-release
        Fedora release 29 (Twenty Nine)
        #
      
      I.e. right now, in my system test-all.bin is failing all the time since
      Fedora29 doesn't have libopencsd available:
      
        $ cat /tmp/build/perf/feature/test-all.make.output
        In file included from test-all.c:174:
        test-libopencsd.c:2:10: fatal error: opencsd/c_api/opencsd_c_api.h: No such file or directory
         #include <opencsd/c_api/opencsd_c_api.h>
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        compilation terminated.
      
      See:
      
        6ab2b762 ("perf build: Disable libbabeltrace check by default")
      
      For the rationale, as soon as libopencsd becomes more generally packaged
      and available, we do the same thing we did with babeltrace, enabling it
      by default, as done in:
      
        24787afb ("perf tools: Enable LIBBABELTRACE by default")
      
      For now, to explicitely ask for opencsd, make sure you have it installed
      and use:
      
         make -C tools/perf CORESIGHT=1
      
      The feature test output will be there as an empty file:
      
        $ ls -la /tmp/build/perf/feature/test-libopencsd.make.output
      
      Because the binary used for the feature check was successfully built:
      
        $ ls -la /tmp/build/perf/feature/test-libopencsd.bin
        -rwxrwxr-x. 1 acme acme 18336 Feb 12 14:49 /tmp/build/perf/feature/test-libopencsd.bin
        $ ldd /tmp/build/perf/feature/test-libopencsd.bin
      	linux-vdso.so.1 (0x00007fffe18cc000)
      	libopencsd_c_api.so.0 => /lib64/libopencsd_c_api.so.0 (0x00007fb8e67f6000)
      	libopencsd.so.0 => /lib64/libopencsd.so.0 (0x00007fb8e676f000)
      	libc.so.6 => /lib64/libc.so.6 (0x00007fb8e65a9000)
      	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fb8e6411000)
      	libm.so.6 => /lib64/libm.so.6 (0x00007fb8e628d000)
      	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fb8e6272000)
      	/lib64/ld-linux-x86-64.so.2 (0x00007fb8e6828000)
        $
      
      And the resulting perf binary will be linked with it:
      
        -rw-rw-r--. 1 acme acme 0 Feb 12 14:49 /tmp/build/perf/feature/test-libopencsd.make.output
        $ ldd ~/bin/perf | grep opencsd
      	libopencsd_c_api.so.0 => /lib64/libopencsd_c_api.so.0 (0x00007fd43097f000)
      	libopencsd.so.0 => /lib64/libopencsd.so.0 (0x00007fd4308f8000)
        $
      
      To make sure this gets built before pushing things upstream I have a
      ubuntu:19.04-x-arm64 container that has:
      
        [root@quaco x-arm64]# grep CORESIGHT Dockerfile
        ENV EXTRA_MAKE_ARGS=CORESIGHT=1
        [root@quaco x-arm64]#
      
      So that I always build with libopencsd before pushing things upstream.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kim Phillips <kim.phillips@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Mike Leach <mike.leach@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      Link: https://lkml.kernel.org/n/tip-20vyy39jw9jgrijesi30fgox@git.kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1c3b28fd