1. 17 2月, 2017 7 次提交
    • J
      perf tools: Replace _SC_NPROCESSORS_CONF with max_present_cpu in cpu_topology_map · da8a58b5
      Jan Stancek 提交于
      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: NJan 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      da8a58b5
    • J
      perf header: Make build_cpu_topology skip offline/absent CPUs · 43db2843
      Jan Stancek 提交于
      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: NJan Stancek <jstancek@redhat.com>
      Acked-by: NJiri 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      43db2843
    • J
      perf cpumap: Add cpu__max_present_cpu() · 92a7e127
      Jan Stancek 提交于
      Similar to cpu__max_cpu() (which returns the max possible CPU), returns
      the max present CPU.
      Signed-off-by: NJan Stancek <jstancek@redhat.com>
      Acked-by: NJiri 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      92a7e127
    • A
      perf session: Fix DEBUG=1 build with clang · 8074bf51
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      8074bf51
    • S
      tools lib traceevent: It's preempt not prempt · 9c72fd0f
      Steven Rostedt (VMware) 提交于
      Fix the typo of the function name pevent_data_prempt_count()
      Signed-off-by: NSteven 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      9c72fd0f
    • A
      perf python: Filter out -specs=/a/b/c from the python binding cc options · 4be92cf0
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      4be92cf0
    • A
      tools perf scripting python: clang doesn't have -spec, remove it · 8bd8c653
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      8bd8c653
  2. 15 2月, 2017 12 次提交
    • A
      perf tools: Add missing parse_events_error() prototype · 34a0548f
      Arnaldo Carvalho de Melo 提交于
      As pointed out by clang, we were not providing a prototype for a
      function before using it:
      
        util/parse-events.y:699:6: error: conflicting types for 'parse_events_error'
        void parse_events_error(YYLTYPE *loc, void *data,
             ^
        /tmp/build/perf/util/parse-events-bison.c:2224:7: note: previous implicit declaration is here
              yyerror (&yylloc, _data, scanner, YY_("syntax error"));
              ^
        /tmp/build/perf/util/parse-events-bison.c:65:25: note: expanded from macro 'yyerror'
        #define yyerror         parse_events_error
      
        1 error generated.
      
      One line fix it.
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20170215130605.GC4020@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      34a0548f
    • A
      perf pmu: Fix check for unset alias->unit array · b30a7d1f
      Arnaldo Carvalho de Melo 提交于
      The alias->unit field is an array, so to check that it is not set we
      should see if it is an empty string, i.e. alias->unit[0], instead of
      checking alias->unit != NULL, as this will _always_ evaluate to 'true'.
      
      Pointed out by clang.
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20170214182435.GD4458@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b30a7d1f
    • A
      perf tools: Be consistent on the type of map->symbols[] interator · a0b2f5af
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      a0b2f5af
    • A
      perf intel pt decoder: clang has no -Wno-override-init · 35670dd0
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      35670dd0
    • A
      perf evsel: Do not put a variable sized type not at the end of a struct · c24ae6d9
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      c24ae6d9
    • A
      perf probe: Avoid accessing uninitialized 'map' variable · 8a2efd6d
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      8a2efd6d
    • A
      perf tools: Do not put a variable sized type not at the end of a struct · 89896051
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      89896051
    • A
      perf record: Do not put a variable sized type not at the end of a struct · 9d6aae72
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      9d6aae72
    • A
      perf tests: Synthesize struct instead of using field after variable sized type · 423d856a
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      423d856a
    • A
      perf bench numa: Make sure dprintf() is not defined · 6aa4d826
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      6aa4d826
    • A
      Revert "perf bench futex: Sanitize numeric parameters" · 16cab322
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      16cab322
    • A
      tools lib subcmd: Make it an error to pass a signed value to OPTION_UINTEGER · b9889716
      Arnaldo Carvalho de Melo 提交于
      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: NArnaldo Carvalho de Melo <acme@redhat.com>
      b9889716
  3. 14 2月, 2017 14 次提交
  4. 10 2月, 2017 3 次提交
    • A
      perf intel-pt: Use __fallthrough · 7ea6856d
      Arnaldo Carvalho de Melo 提交于
      To address new warnings emmited by gcc 7, e.g.::
      
          CC       /tmp/build/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.o
          CC       /tmp/build/perf/tests/parse-events.o
        util/intel-pt-decoder/intel-pt-pkt-decoder.c: In function 'intel_pt_pkt_desc':
        util/intel-pt-decoder/intel-pt-pkt-decoder.c:499:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
           if (!(packet->count))
              ^
        util/intel-pt-decoder/intel-pt-pkt-decoder.c:501:2: note: here
          case INTEL_PT_CYC:
          ^~~~
          CC       /tmp/build/perf/util/intel-pt-decoder/intel-pt-decoder.o
        cc1: all warnings being treated as errors
      Acked-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@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-mf0hw789pu9x855us5l32c83@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7ea6856d
    • A
      perf tests: Avoid possible truncation with dirent->d_name + snprintf · 2e2bbc03
      Arnaldo Carvalho de Melo 提交于
      Addressing a few cases spotted by a new warning in gcc 7:
      
        tests/parse-events.c: In function 'test_pmu_events':
        tests/parse-events.c:1790:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 90 [-Werror=format-truncation=]
           snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name);
                                             ^~
        In file included from /usr/include/stdio.h:939:0,
                         from /git/linux/tools/perf/util/map.h:9,
                         from /git/linux/tools/perf/util/symbol.h:7,
                         from /git/linux/tools/perf/util/evsel.h:10,
                         from tests/parse-events.c:3:
        /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 13 and 268 bytes into a destination of size 100
           return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                __bos (__s), __fmt, __va_arg_pack ());
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        tests/parse-events.c:1798:29: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 100 [-Werror=format-truncation=]
           snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
      
      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>
      Fixes: 945aea22 ("perf tests: Move test objects into 'tests' directory")
      Link: http://lkml.kernel.org/n/tip-ty4q2p8zp1dp3mskvubxskm5@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2e2bbc03
    • A
      perf bench numa: Avoid possible truncation when using snprintf() · 3aff8ba0
      Arnaldo Carvalho de Melo 提交于
      Addressing this warning from gcc 7:
      
          CC       /tmp/build/perf/bench/numa.o
        bench/numa.c: In function '__bench_numa':
        bench/numa.c:1582:42: error: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size between 8 and 17 [-Werror=format-truncation=]
             snprintf(tname, 32, "process%d:thread%d", p, t);
                                                  ^~
        bench/numa.c:1582:25: note: directive argument in the range [0, 2147483647]
             snprintf(tname, 32, "process%d:thread%d", p, t);
                                 ^~~~~~~~~~~~~~~~~~~~
        In file included from /usr/include/stdio.h:939:0,
                         from bench/../util/util.h:47,
                         from bench/../builtin.h:4,
                         from bench/numa.c:11:
        /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 17 and 35 bytes into a destination of size 32
           return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                __bos (__s), __fmt, __va_arg_pack ());
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        cc1: all warnings being treated as errors
      
      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: Petr Holasek <pholasek@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-twa37vsfqcie5gwpqwnjuuz9@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3aff8ba0
  5. 09 2月, 2017 4 次提交
    • A
      perf header: Fix handling of PERF_EVENT_UPDATE__SCALE · 8434a2ec
      Arnaldo Carvalho de Melo 提交于
      In commit daeecbc0 ("perf tools: Add event_update event scale type"), the
      handling of PERF_EVENT_UPDATE__SCALE cast struct event_update_event->data to a
      pointer to event_update_event_scale, uses some field from this casted struct
      and then ends up falling through to the handling of another event type,
      PERF_EVENT_UPDATE__CPUS were it casts that ev->data to yet another type, oops,
      fix it by inserting the missing break.
      
      Noticed when building perf using gcc 7 on Fedora Rawhide:
      
        util/header.c: In function 'perf_event__process_event_update':
        util/header.c:3207:16: error: this statement may fall through [-Werror=implicit-fallthrough=]
           evsel->scale = ev_scale->scale;
           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
        util/header.c:3208:2: note: here
          case PERF_EVENT_UPDATE__CPUS:
          ^~~~
      
      This wasn't noticed because probably PERF_EVENT_UPDATE__CPUS comes after
      PERF_EVENT_UPDATE__SCALE, so we would just create a bogus evsel->own_cpus when
      processing a PERF_EVENT_UPDATE__SCALE to then leak it and create a new cpu map
      with the correct data.
      
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Fixes: daeecbc0 ("perf tools: Add event_update event scale type")
      Link: http://lkml.kernel.org/n/tip-lukcf9hdj092ax2914ss95at@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8434a2ec
    • A
      perf thread_map: Correctly size buffer used with dirent->dt_name · bdf23a9a
      Arnaldo Carvalho de Melo 提交于
      The size of dirent->dt_name is NAME_MAX + 1, but the size for the 'path'
      buffer is hard coded at 256, which may truncate it because we also
      prepend "/proc/", so that all that into account and thank gcc 7 for this
      warning:
      
        /git/linux/tools/perf/util/thread_map.c: In function 'thread_map__new_by_uid':
        /git/linux/tools/perf/util/thread_map.c:119:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 250 [-Werror=format-truncation=]
           snprintf(path, sizeof(path), "/proc/%s", dirent->d_name);
                                               ^~
        In file included from /usr/include/stdio.h:939:0,
                         from /git/linux/tools/perf/util/thread_map.c:5:
        /usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 7 and 262 bytes into a destination of size 256
           return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                __bos (__s), __fmt, __va_arg_pack ());
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      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-csy0r8zrvz5efccgd4k12c82@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bdf23a9a
    • A
      perf top: Use __fallthrough · 7b0214b7
      Arnaldo Carvalho de Melo 提交于
      The implicit fall through case label here is intended, so let us inform
      that to gcc >= 7:
      
          CC       /tmp/build/perf/builtin-top.o
        builtin-top.c: In function 'display_thread':
        builtin-top.c:644:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
            if (errno == EINTR)
               ^
        builtin-top.c:647:3: note: here
           default:
         ^~~~~~~
      
      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-lmcfnnyx9ic0m6j0aud98p4e@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b0214b7
    • A
      tools strfilter: Use __fallthrough · d64b721d
      Arnaldo Carvalho de Melo 提交于
      The implicit fall through case label here is intended, so let us inform
      that to gcc >= 7:
      
        util/strfilter.c: In function 'strfilter_node__sprint':
        util/strfilter.c:270:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
           if (len < 0)
              ^
        util/strfilter.c:272:2: note: here
          case '!':
          ^~~~
        cc1: all warnings being treated as errors
      
      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-z2dpywg7u8fim000hjfbpyfm@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d64b721d