1. 14 3月, 2017 1 次提交
    • H
      perf tools: Add PERF_RECORD_NAMESPACES to include namespaces related info · f3b3614a
      Hari Bathini 提交于
      Introduce a new option to record PERF_RECORD_NAMESPACES events emitted
      by the kernel when fork, clone, setns or unshare are invoked. And update
      perf-record documentation with the new option to record namespace
      events.
      
      Committer notes:
      
      Combined it with a later patch to allow printing it via 'perf report -D'
      and be able to test the feature introduced in this patch. Had to move
      here also perf_ns__name(), that was introduced in another later patch.
      
      Also used PRIu64 and PRIx64 to fix the build in some enfironments wrt:
      
        util/event.c:1129:39: error: format '%lx' expects argument of type 'long unsigned int', but argument 6 has type 'long long unsigned int' [-Werror=format=]
           ret  += fprintf(fp, "%u/%s: %lu/0x%lx%s", idx
                                               ^
      Testing it:
      
        # perf record --namespaces -a
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 1.083 MB perf.data (423 samples) ]
        #
        # perf report -D
        <SNIP>
        3 2028902078892 0x115140 [0xa0]: PERF_RECORD_NAMESPACES 14783/14783 - nr_namespaces: 7
                      [0/net: 3/0xf0000081, 1/uts: 3/0xeffffffe, 2/ipc: 3/0xefffffff, 3/pid: 3/0xeffffffc,
                       4/user: 3/0xeffffffd, 5/mnt: 3/0xf0000000, 6/cgroup: 3/0xeffffffb]
      
        0x1151e0 [0x30]: event: 9
        .
        . ... raw event: size 48 bytes
        .  0000:  09 00 00 00 02 00 30 00 c4 71 82 68 0c 7f 00 00  ......0..q.h....
        .  0010:  a9 39 00 00 a9 39 00 00 94 28 fe 63 d8 01 00 00  .9...9...(.c....
        .  0020:  03 00 00 00 00 00 00 00 ce c4 02 00 00 00 00 00  ................
        <SNIP>
              NAMESPACES events:          1
        <SNIP>
        #
      Signed-off-by: NHari Bathini <hbathini@linux.vnet.ibm.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@fb.com>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sargun Dhillon <sargun@sargun.me>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/148891930386.25309.18412039920746995488.stgit@hbathini.in.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f3b3614a
  2. 13 3月, 2017 1 次提交
  3. 04 3月, 2017 16 次提交
  4. 28 2月, 2017 2 次提交
  5. 20 2月, 2017 2 次提交
  6. 18 2月, 2017 2 次提交
  7. 17 2月, 2017 6 次提交
    • 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
    • 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
  8. 15 2月, 2017 7 次提交
  9. 14 2月, 2017 3 次提交