1. 17 Feb, 2017 12 commits
    • Jiri Olsa's avatar
      perf record: Add -a as default target · 483635a9
      Jiri Olsa authored
      Running 'perf record' with no target (-a, -p, -t, etc) will now collect
      system wide data.
      
      Commiter notes:
      
      Testing it:
      
        [root@jouet ~]# perf record
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.351 MB perf.data (366 samples) ]
        #
      
      is equivalent to:
      
        # perf record -a
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.411 MB perf.data (978 samples) ]
        #
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170217170018.GA15389@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      483635a9
    • Jiri Olsa's avatar
      perf stat: Add -a as default target · 0d79f8b9
      Jiri Olsa authored
      Boris asked for default -a option in case we monitor only uncore events.
      
      While implementing that I thought it might be actually useful to make it
      overall default.
      
      Running 'perf stat' will now collect system wide data.
      
      Committer note:
      
      Testing it:
      
        # perf stat
        ^C
         Performance counter stats for 'system wide':
      
               3571.559178      cpu-clock (msec)          #    4.000 CPUs utilized
                     3,346      context-switches          #    0.937 K/sec
                       277      cpu-migrations            #    0.078 K/sec
                    57,271      page-faults               #    0.016 M/sec
             4,535,633,835      cycles                    #    1.270 GHz
             6,389,736,516      instructions              #    1.41  insn per cycle
             1,541,293,875      branches                  #  431.547 M/sec
                14,526,396      branch-misses             #    0.94% of all branches
      
               0.892950118 seconds time elapsed
      
        #
      Requested-and-Acked-by: default avatarBorislav Petkov <bp@alien8.de>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20170217170034.GB15389@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0d79f8b9
    • Jiri Olsa's avatar
      perf tools: Fail on using multiple bits long terms without value · 99e7138e
      Jiri Olsa authored
      Currently we allow not to specify value for numeric terms and we set
      them to value 1. This was originaly meant just for single bit terms to
      allow user to type:
      
        $ perf record -e 'cpu/cpu-cycles,any'
      
      instead of:
      
        $ perf record -e 'cpu/cpu-cycles,any=1'
      
      However it works also for multi bits terms like:
      
        $ perf record -e 'cpu/event/' ls
        ...
        $ perf evlist -v
        ..., config: 0x1, ...
      
      After discussion with Peter we decided making such term usage to fail,
      like:
      
        $ perf record -e 'cpu/event/' ls
        event syntax error: 'cpu/event/'
                             \___ no value assigned for term
        ...
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1487340058-10496-4-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      99e7138e
    • Jiri Olsa's avatar
      perf tools: Move new_term arguments into struct parse_events_term template · 67b49b38
      Jiri Olsa authored
      We need to add yet another parameter to new_term function in following
      patch, so it's better to move first all the current params into template
      struct parse_events_term and use it as a single argument.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1487340058-10496-3-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      67b49b38
    • Jiri Olsa's avatar
      perf build: Add special fixdep cleaning rule · 85e0d509
      Jiri Olsa authored
      Ingo reported following build failure:
      
      On Sat, Feb 11, 2017 at 12:12:34PM +0100, Ingo Molnar wrote:
      >
      > So I had this oldish 32-bit 15.10 Ubuntu installation around (fully updated), and
      > trying to build perf gave me:
      >
      > deimos:~/tip/tools/perf> make
      >   BUILD:   Doing 'make -j4' parallel build
      > make[3]: *** No rule to make target '/usr/include/x86_64-linux-gnu/sys/types.h', needed by 'fixdep.o'.  Stop.
      > Makefile:42: recipe for target 'fixdep-in.o' failed
      > make[2]: *** [fixdep-in.o] Error 2
      > /home/mingo/tip/tools/build/Makefile.include:4: recipe for target 'fixdep' failed
      > make[1]: *** [fixdep] Error 2
      > Makefile:68: recipe for target 'all' failed
      > make: *** [all] Error 2
      >
      > Now this got a bit better after I did a 'make mrproper' in the kernel tree:
      >
      > deimos:~/tip/tools/perf> make
      >   BUILD:   Doing 'make -j4' parallel build
      >   HOSTCC   fixdep.o
      > /home/mingo/tip/tools/build/fixdep: 1: /home/mingo/tip/tools/build/fixdep: Syntax error: "(" unexpected
      > /home/mingo/tip/tools/build/Makefile.build:101: recipe for target 'fixdep.o' failed
      > make[3]: *** [fixdep.o] Error 2
      > Makefile:42: recipe for target 'fixdep-in.o' failed
      > make[2]: *** [fixdep-in.o] Error 2
      > /home/mingo/tip/tools/build/Makefile.include:4: recipe for target 'fixdep' failed
      > make[1]: *** [fixdep] Error 2
      > Makefile:68: recipe for target 'all' failed
      > make: *** [all] Error 2
      >
      > After some digging it turns out that my 'fixdep' binary was 64-bit:
      >
      > deimos:~/tip/tools/perf> file /home/mingo/tip/tools/build/fixdep
      > /home/mingo/tip/tools/build/fixdep: ELF 64-bit LSB executable, x86-64, version 1
      > (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux
      > 2.6.32, BuildID[sha1]=d527f736b57b5ba47210fbcb562a3b52867d21c1, not stripped
      >
      > But it did not get cleaned out by 'make clean'.
      >
      > Only after I did a 'make clean' in tools/ itself, did it get built properly.
      
      It shows we don't clean up properly the fixdep objects, so adding
      special rule for that.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Reported-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1487340058-10496-2-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      85e0d509
    • Jan Stancek's avatar
      perf tools: Replace _SC_NPROCESSORS_CONF with max_present_cpu in cpu_topology_map · da8a58b5
      Jan Stancek authored
      There are 2 problems wrt. cpu_topology_map on systems with sparse CPUs:
      
      1. offline/absent CPUs will have their socket_id and core_id set to -1
         which triggers:
         "socket_id number is too big.You may need to upgrade the perf tool."
      
      2. size of cpu_topology_map (perf_env.cpu[]) is allocated based on
         _SC_NPROCESSORS_CONF, but can be indexed with CPU ids going above.
         Users of perf_env.cpu[] are using CPU id as index. This can lead
         to read beyond what was allocated:
         ==19991== Invalid read of size 4
         ==19991==    at 0x490CEB: check_cpu_topology (topology.c:69)
         ==19991==    by 0x490CEB: test_session_topology (topology.c:106)
         ...
      
      For example:
        _SC_NPROCESSORS_CONF == 16
        available: 2 nodes (0-1)
        node 0 cpus: 0 6 8 10 16 22 24 26
        node 0 size: 12004 MB
        node 0 free: 9470 MB
        node 1 cpus: 1 7 9 11 23 25 27
        node 1 size: 12093 MB
        node 1 free: 9406 MB
        node distances:
        node   0   1
          0:  10  20
          1:  20  10
      
      This patch changes HEADER_NRCPUS.nr_cpus_available from _SC_NPROCESSORS_CONF
      to max_present_cpu and updates any user of cpu_topology_map to iterate
      with nr_cpus_avail.
      
      As a consequence HEADER_CPU_TOPOLOGY core_id and socket_id lists get longer,
      but maintain compatibility with pre-patch state - index to cpu_topology_map is
      CPU id.
      
        perf test 36 -v
        36: Session topology                           :
        --- start ---
        test child forked, pid 22211
        templ file: /tmp/perf-test-gmdX5i
        CPU 0, core 0, socket 0
        CPU 1, core 0, socket 1
        CPU 6, core 10, socket 0
        CPU 7, core 10, socket 1
        CPU 8, core 1, socket 0
        CPU 9, core 1, socket 1
        CPU 10, core 9, socket 0
        CPU 11, core 9, socket 1
        CPU 16, core 0, socket 0
        CPU 22, core 10, socket 0
        CPU 23, core 10, socket 1
        CPU 24, core 1, socket 0
        CPU 25, core 1, socket 1
        CPU 26, core 9, socket 0
        CPU 27, core 9, socket 1
        test child finished with 0
        ---- end ----
        Session topology: Ok
      Signed-off-by: default avatarJan Stancek <jstancek@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/d7c05c6445fca74a8442c2c73cfffd349c52c44f.1487146877.git.jstancek@redhat.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      da8a58b5
    • Jan Stancek's avatar
      perf header: Make build_cpu_topology skip offline/absent CPUs · 43db2843
      Jan Stancek authored
      When build_cpu_topo() encounters offline/absent CPUs, it fails to find any
      sysfs entries and returns failure.
      
      This leads to build_cpu_topology() and write_cpu_topology() failing as
      well.
      
      Because HEADER_CPU_TOPOLOGY has not been written, read leaves cpu_topology_map
      NULL and we get NULL ptr deref at:
      
        ...
         cmd_test
          __cmd_test
           test_and_print
            run_test
             test_session_topology
              check_cpu_topology
      
        36: Session topology                           :
        --- start ---
        test child forked, pid 14902
        templ file: /tmp/perf-test-4CKocW
        failed to write feature HEADER_CPU_TOPOLOGY
        perf: Segmentation fault
        Obtained 9 stack frames.
        ./perf(sighandler_dump_stack+0x41) [0x5095f1]
        /lib64/libc.so.6(+0x35250) [0x7f4b7c3c9250]
        ./perf(test_session_topology+0x1db) [0x490ceb]
        ./perf() [0x475b68]
        ./perf(cmd_test+0x5b9) [0x4763c9]
        ./perf() [0x4945a3]
        ./perf(main+0x69f) [0x427e8f]
        /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f4b7c3b5b35]
        ./perf() [0x427fb9]
        test child interrupted
        ---- end ----
        Session topology: FAILED!
      
      This patch makes build_cpu_topology() skip offline/absent CPUs, by checking
      their presence against cpu_map built from online CPUs.
      Signed-off-by: default avatarJan Stancek <jstancek@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/a271b770175524f4961d4903af33798358a4a518.1487146877.git.jstancek@redhat.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      43db2843
    • Jan Stancek's avatar
      perf cpumap: Add cpu__max_present_cpu() · 92a7e127
      Jan Stancek authored
      Similar to cpu__max_cpu() (which returns the max possible CPU), returns
      the max present CPU.
      Signed-off-by: default avatarJan Stancek <jstancek@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/8ea4601b5cacc49927235b4ebac424bd6eeccb06.1487146877.git.jstancek@redhat.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      92a7e127
    • Arnaldo Carvalho de Melo's avatar
      perf session: Fix DEBUG=1 build with clang · 8074bf51
      Arnaldo Carvalho de Melo authored
      The struct branch_stack->branch_stack.cycles field is a u64 :16
      bitfield, and this somehow confuses clang 4.0 when checking the
      arguments of a printf format, so cast the :16 to unsigned short to help
      it.
      
      Silences this:
      
        util/session.c:935:4: error: format specifies type 'unsigned short' but the argument has type 'u64' (aka 'unsigned long') [-Werror,-Wformat]
                                e->flags.cycles,
                                ^~~~~~~~~~~~~~~
        1 error generated.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-eo2t4uhlbne105z72tvyzkp1@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8074bf51
    • Steven Rostedt (VMware)'s avatar
      tools lib traceevent: It's preempt not prempt · 9c72fd0f
      Steven Rostedt (VMware) authored
      Fix the typo of the function name pevent_data_prempt_count()
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Fixes: c52d9e4e ("tools lib traceevent: Add retrieval of preempt count and latency flags")
      Link: http://lkml.kernel.org/r/20170216201352.469c99de@grimm.local.homeSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9c72fd0f
    • Arnaldo Carvalho de Melo's avatar
      perf python: Filter out -specs=/a/b/c from the python binding cc options · 4be92cf0
      Arnaldo Carvalho de Melo authored
      The -spec=/path/to/file can be used to change what gcc puts in the cc,
      ld, etc command lines, but this is not present in clang, filter it out
      at the setup.py file by changing python2's internal variable where it
      keeps its initial CFLAGS value.
      
      With this all of perf can be built in at least Fedora 25, fixing this
      problem:
      
          GEN      /tmp/build/perf/python/perf.so
          CC       /tmp/build/perf/builtin-buildid-list.o
        clang-4.0: error: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Werror,-Wunused-command-line-argument]
        clang-4.0: error: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Werror,-Wunused-command-line-argument]
        error: command 'clang' failed with exit status 1
      
      Now I need to change all the containers where I have clang to build
      perf with it, so that we can check that in other distros (opensuse, debian,
      ubuntu, etc) this also works.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-g9lhgr162ao8ao29vvf0hgm1@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4be92cf0
    • Arnaldo Carvalho de Melo's avatar
      tools perf scripting python: clang doesn't have -spec, remove it · 8bd8c653
      Arnaldo Carvalho de Melo authored
      Gcc has a -spec option to override what options to pass to cc, etc, and
      in some distros this is used, like in fedora, where we end up getting
      this passed to gcc that makes clang, that doesn't have this option to
      stop the build:
      
        CC       /tmp/build/perf/util/scripting-engines/trace-event-python.o
      clang-4.0: error: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Werror,-Wunused-command-line-argument]
      
      So filter this out when the compiler used is clang, this way we
      can build the python scripting support in tools/perf/.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-2gosxoiouf24pnlknp7w7q4z@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8bd8c653
  2. 16 Feb, 2017 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.11-20170215' of... · 0c8967c9
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-4.11-20170215' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core clang fixes from Arnaldo Carvalho de Melo:
      
      Changes to make tools/{perf,lib/{bpf,traceevent,api}} build with
      CC=clang, to, for instance, take advantage of warnings (Arnaldo Carvalho de Melo):
      
      - Conditionally request some warning options not available on clang
      
      - Set the maximum optimization level to -O3 when using CC=clang, leave
        the previous setting of -O6 otherwise.
      
      - Make it an error to pass a signed value to OPTION_UINTEGER, so that
        we can remove abs(unsigned int) calls in 'perf bench futex'.
      
      - Make sure dprintf() is not defined before using that name in 'perf bench numa'
      
      - Avoid using field after variable sized type, its a GNU extension, use
        equivalent code.
      
      - Fix some bugs where some variables could be used unitialized,
        something not caught by gcc.
      
      - Fix some spots where we were testing struct->array[] members against
        NULL, it will always evaluate to 'true'.
      
      - Add missing parse_events_error() prototype in the bison file.
      
      There are still one problem when trying to build the python support, but
      this are the 'size' outputs for 'make -C tools/perf NO_LIBPYTHON' for
      gcc and clang builds:
      
        DW_AT_producer: clang version 4.0.0 (http://llvm.org/git/clang.git f5be8ba13adc4ba1011a7ccd60c844bd60427c1c) (ht
      
        $ size ~/bin/perf
           text    data     bss     dec     hex     filename
        3447514  831320 23901696  28180530  1ae0032 /home/acme/bin/perf
      
        DW_AT_producer: GNU C99 6.3.1 20161221 (Red Hat 6.3.1-1) -mtune=generic -march=x86-64 -ggdb3 -O6 -std=gnu99
      +-fno-omit-frame-pointer -funwind-tables -fstack-protector-all
      
        $ size ~/bin/perf
           text    data     bss     dec     hex     filename
        3671662  836480 23902752  28410894  1b1840e /home/acme/bin/perf
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0c8967c9
  3. 15 Feb, 2017 2 commits
  4. 14 Feb, 2017 14 commits
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Be consistent on the type of map->symbols[] interator · a0b2f5af
      Arnaldo Carvalho de Melo authored
      In a few cases we were using 'enum map_type' and that triggered this
      warning when using clang:
      
        util/session.c:1923:16: error: comparison of constant 2 with expression of type 'enum map_type' is always true
            [-Werror,-Wtautological-constant-out-of-range-compare]
              for (i = 0; i < MAP__NR_TYPES; ++i) {
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-i6uyo6bsopa2dghnx8qo7rri@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a0b2f5af
    • Arnaldo Carvalho de Melo's avatar
      perf intel pt decoder: clang has no -Wno-override-init · 35670dd0
      Arnaldo Carvalho de Melo authored
      So set it only for other compilers, allowing us to overcome yet another
      build failure due to an inexistent clang -W option:
      
        error: unknown warning option '-Wno-override-init'; did you mean '-Wno-override-module'? [-Werror,-Wunknown-warning-option]
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-oaa1ici3j8nygp4pzl2oobh3@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      35670dd0
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Do not put a variable sized type not at the end of a struct · c24ae6d9
      Arnaldo Carvalho de Melo authored
      As this is a GNU extension and while harmless in this case, we can do
      the same thing in a more clearer way by using a existing thread_map and
      cpu_map constructors:
      
      With this we avoid this while compiling with clang:
      
        util/evsel.c:1659:17: error: field 'map' with variable sized type 'struct cpu_map' not at the end of a struct or class is a GNU extension
              [-Werror,-Wgnu-variable-sized-type-not-at-end]
                struct cpu_map map;
                               ^
        util/evsel.c:1667:20: error: field 'map' with variable sized type 'struct thread_map' not at the end of a struct or class is a GNU extension
              [-Werror,-Wgnu-variable-sized-type-not-at-end]
                struct thread_map map;
                                  ^
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-207juvrqjiar7uvas2s83v5i@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c24ae6d9
    • Arnaldo Carvalho de Melo's avatar
      perf probe: Avoid accessing uninitialized 'map' variable · 8a2efd6d
      Arnaldo Carvalho de Melo authored
      Genuine problem detected with clang, the warnings are spot on:
      
        util/probe-event.c:2079:7: error: variable 'map' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                        if (addr) {
                            ^~~~
        util/probe-event.c:2094:6: note: uninitialized use occurs here
                if (map && !is_kprobe) {
                    ^~~
        util/probe-event.c:2079:3: note: remove the 'if' if its condition is always true
                        if (addr) {
                        ^~~~~~~~~~
        util/probe-event.c:2075:8: error: variable 'map' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
                                if (kernel_get_symbol_address_by_name(tp->symbol,
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        util/probe-event.c:2094:6: note: uninitialized use occurs here
                if (map && !is_kprobe) {
                    ^~~
        util/probe-event.c:2075:4: note: remove the 'if' if its condition is always false
                                if (kernel_get_symbol_address_by_name(tp->symbol,
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        util/probe-event.c:2064:17: note: initialize the variable 'map' to silence this warning
                struct map *map;
                               ^
                                = NULL
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-m3501el55i10hctfbmi2qxzr@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8a2efd6d
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Do not put a variable sized type not at the end of a struct · 89896051
      Arnaldo Carvalho de Melo authored
      As this is a GNU extension and while harmless in this case, we can do
      the same thing in a more clearer way by using an existing thread_map
      constructor.
      
      With this we avoid this while compiling with clang:
      
        util/parse-events.c:2024:21: error: field 'map' with variable sized type 'struct thread_map' not at the end of a struct or class is a GNU extension
              [-Werror,-Wgnu-variable-sized-type-not-at-end]
                        struct thread_map map;
                                        ^
        1 error generated.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-tqocbplnyyhpst6drgm2u4m3@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      89896051
    • Arnaldo Carvalho de Melo's avatar
      perf record: Do not put a variable sized type not at the end of a struct · 9d6aae72
      Arnaldo Carvalho de Melo authored
      As this is a GNU extension and while harmless in this case, we can do
      the same thing in a more clearer way by using an existing thread_map
      constructor.
      
      With this we avoid this while compiling with clang:
      
        builtin-record.c:659:21: error: field 'map' with variable sized type 'struct thread_map' not at the end of a struct or class is a GNU extension
              [-Werror,-Wgnu-variable-sized-type-not-at-end]
                        struct thread_map map;
                                          ^
        1 error generated.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-c9drclo52ezxmwa7qxklin2y@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9d6aae72
    • Arnaldo Carvalho de Melo's avatar
      perf tests: Synthesize struct instead of using field after variable sized type · 423d856a
      Arnaldo Carvalho de Melo authored
      End result is the same, its an ABI, so the struct won't change, avoid
      using a GNU extension, so that we can catch other cases that may be bugs.
      
      Caught when building with clang:
      
        tests/parse-no-sample-id-all.c:53:20: error: field 'attr' with variable sized type 'struct attr_event' not at the end of a struct or class is a GNU extension
              [-Werror,-Wgnu-variable-sized-type-not-at-end]
                struct attr_event attr;
                                  ^
        1 error generated.
      
      Testing it:
      
        # perf test sample_id
        24: Parse with no sample_id_all bit set        : Ok
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-e2vs1x771fc208uvxnwcf08b@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      423d856a
    • Arnaldo Carvalho de Melo's avatar
      perf bench numa: Make sure dprintf() is not defined · 6aa4d826
      Arnaldo Carvalho de Melo authored
      When building with clang we get this error:
      
        bench/numa.c:46:9: error: 'dprintf' macro redefined [-Werror,-Wmacro-redefined]
        #define dprintf(x...) do { if (g && g->p.show_details >= 1) printf(x); } while (0)
                ^
        /usr/include/bits/stdio2.h:145:12: note: previous definition is here
        #   define dprintf(fd, ...) \
                   ^
          CC       /tmp/build/perf/tests/parse-no-sample-id-all.o
        1 error generated.
      
      So, make sure it is undefined before using that name.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
      Cc: Jakub Jelen <jjelen@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-f654o2svtrutamvxt7igwz74@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6aa4d826
    • Arnaldo Carvalho de Melo's avatar
      Revert "perf bench futex: Sanitize numeric parameters" · 16cab322
      Arnaldo Carvalho de Melo authored
      This reverts commit 60758d66.
      
      Now that libsubcmd makes sure that OPT_UINTEGER options will not
      return negative values, we can revert this patch while addressing
      the problem it solved:
      
        # perf bench futex hash -t  -4
        # Running 'futex/hash' benchmark:
         Error: switch `t' expects an unsigned numerical value
         Usage: perf bench futex hash <options>
      
            -t, --threads <n>     Specify amount of threads
        # perf bench futex hash -t-4
        # Running 'futex/hash' benchmark:
         Error: switch `t' expects an unsigned numerical value
         Usage: perf bench futex hash <options>
      
            -t, --threads <n>     Specify amount of threads
        #
      
      IMO it is more reasonable to flat out refuse to process a negative
      number than to silently turn it into an absolute value.
      
      This also helps in silencing clang's complaint about asking for an
      absolute value of an unsigned integer:
      
        bench/futex-hash.c:133:10: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
                nsecs = futexbench_sanitize_numeric(nsecs);
                      ^
        bench/futex.h:104:42: note: expanded from macro 'futexbench_sanitize_numeric'
        #define futexbench_sanitize_numeric(__n) abs((__n))
                                                 ^
        bench/futex-hash.c:133:10: note: remove the call to 'abs' since unsigned values cannot be negative
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-2kl68v22or31vw643m2exz8x@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      16cab322
    • Arnaldo Carvalho de Melo's avatar
      tools lib subcmd: Make it an error to pass a signed value to OPTION_UINTEGER · b9889716
      Arnaldo Carvalho de Melo authored
      Options marked OPTION_UINTEGER or OPTION_U64 clearly indicates that an
      unsigned value is expected, so just error out when a negative value is
      passed, instead of returning something undesired to the tool.
      
      E.g.:
      
        # perf bench futex hash -t -4
        # Running 'futex/hash' benchmark:
         Error: switch `t' expects an unsigned numerical value
         Usage: perf bench futex hash <options>
      
            -t, --threads <n>     Specify amount of threads
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Davidlohr Bueso <dbueso@suse.de>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-2mdn8s2raatyhz7tamrsz22r@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b9889716
    • Arnaldo Carvalho de Melo's avatar
      tools: Set the maximum optimization level according to the compiler being used · 49b3cd30
      Arnaldo Carvalho de Melo authored
      To avoid this when using clang:
      
        warning: optimization level '-O6' is not supported; using '-O3' instead
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-kaghp8ddvzdsg03putemcq96@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      49b3cd30
    • Arnaldo Carvalho de Melo's avatar
      tools: Suppress request for warning options not existent in clang · 093b75ef
      Arnaldo Carvalho de Melo authored
      To allow building with clang, avoiding:
      
        error: unknown warning option '-Wstrict-aliasing=3'; did you mean '-Wstring-plus-int'? [-Werror,-Wunknown-warning-option]
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-xvthlvmhzfnt7jx73jgmaea1@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      093b75ef
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.11-20170213' of... · 277d6f1d
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-4.11-20170213' 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:
      
      New features:
      
       - Introduce the 'delta-abs' 'perf diff' compute method, that orders the
         histogram entries by the absolute value of the percentage delta for a
         function in two perf.data files, i.e. the functions that changed the
         most (increase or decrease in samples) comes first (Namhyung Kim)
      
      User visible changes:
      
       - Improve message about tweaking the kernel.perf_event_paranoid setting,
         telling how to make the change permanent by editing /etc/sysctl.conf
         (Arnaldo Carvalho de Melo)
      
      Infrastructure changes:
      
       - Introduce linux/compiler-gcc.h as a counterpart to the kernel's,
         initially containing the definition of __fallthrough, more to
         come (__maybe_unused, etc) (Arnaldo Carvalho de Melo)
      
       - Fixes for problems uncovered by building tools/perf with clang, such
         as always true tests of arrays against NULL and variables that sometimes
         were used without being initialized (Arnaldo Carvalho de Melo, Steven Rostedt)
      
       - Before loading a new ELF, clear global variables set by the
         samples/bpf loader (Mickaël Salaün)
      
       - Ignore already processed ELF sections in the samples/bpf
         loader (Mickaël Salaün)
      
       - Fix compile error in the scripting code with some perl5
         versions (Wang YanQing)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      277d6f1d
    • Ingo Molnar's avatar
      210f400d
  5. 13 Feb, 2017 11 commits