1. 25 4月, 2017 2 次提交
  2. 20 4月, 2017 4 次提交
  3. 12 4月, 2017 1 次提交
  4. 28 3月, 2017 2 次提交
  5. 17 2月, 2017 2 次提交
    • 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
  6. 09 2月, 2017 1 次提交
    • 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
  7. 26 1月, 2017 1 次提交
  8. 17 1月, 2017 1 次提交
  9. 24 10月, 2016 3 次提交
  10. 13 10月, 2016 1 次提交
  11. 24 8月, 2016 1 次提交
  12. 05 7月, 2016 1 次提交
  13. 23 6月, 2016 1 次提交
  14. 12 5月, 2016 1 次提交
  15. 10 5月, 2016 1 次提交
  16. 12 3月, 2016 1 次提交
    • S
      perf test: Remove 'core_id' check in topo test · 4c9d6c18
      Sukadev Bhattiprolu 提交于
      The topology test case of 'perf test' seems to be broken on my x86
      system - due to the comparison of a "core-id" with # of CPUs online.
      
      There are 8 online CPUs:
      
      	$ cat /sys/devices/system/cpu/online
      	0-7
      
      but core-ids are not sequential and some core-ids exceed the number
      of online CPUs.
      
      	$ cat /sys/devices/system/cpu/cpu?/topology/core_id
      	0
      	1
      	9
      	10
      	0
      	1
      	9
      	10
      
      Looks like we can safely remove the check.  Output before:
      
      	$ perf --version
      	perf version 4.4.rc1.g34258a
      
      	$ perf test -v topo
      	36: Test topology in session                                 :
      	--- start ---
      	test child forked, pid 5906
      	templ file: /tmp/perf-test-vCwWG3
      	core_id number is too big.You may need to upgrade the perf tool.
      	test child interrupted
      	---- end ----
      	Test topology in session: FAILED!
      
      and after:
      
      	$ perf test -v topo
      	36: Test topology in session                                 :
      	--- start ---
      	test child forked, pid 6532
      	templ file: /tmp/perf-test-y10wFJ
      	CPU 0, core 0, socket 0
      	CPU 1, core 1, socket 0
      	CPU 2, core 9, socket 0
      	CPU 3, core 10, socket 0
      	CPU 4, core 0, socket 1
      	CPU 5, core 1, socket 1
      	CPU 6, core 9, socket 1
      	CPU 7, core 10, socket 1
      	test child finished with 0
      	---- end ----
      	Test topology in session: Ok
      Signed-off-by: NSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Jan Stancek <jstancek@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Link: http://lkml.kernel.org/r/20151203233219.GA27696@us.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4c9d6c18
  17. 17 2月, 2016 1 次提交
  18. 18 12月, 2015 7 次提交
  19. 10 12月, 2015 1 次提交
  20. 14 9月, 2015 4 次提交
  21. 13 9月, 2015 1 次提交
    • A
      perf header: Fixup reading of HEADER_NRCPUS feature · caa47047
      Arnaldo Carvalho de Melo 提交于
      The original patch introducing this header wrote the number of CPUs available
      and online in one order and then swapped those values when reading, fix it.
      
      Before:
      
        # perf record usleep 1
        # perf report --header-only | grep 'nrcpus \(online\|avail\)'
        # nrcpus online : 4
        # nrcpus avail : 4
        # echo 0 > /sys/devices/system/cpu/cpu2/online
        # perf record usleep 1
        # perf report --header-only | grep 'nrcpus \(online\|avail\)'
        # nrcpus online : 4
        # nrcpus avail : 3
        # echo 0 > /sys/devices/system/cpu/cpu1/online
        # perf record usleep 1
        # perf report --header-only | grep 'nrcpus \(online\|avail\)'
        # nrcpus online : 4
        # nrcpus avail : 2
      
      After the fix, bringing back the CPUs online:
      
        # perf report --header-only | grep 'nrcpus \(online\|avail\)'
        # nrcpus online : 2
        # nrcpus avail : 4
        # echo 1 > /sys/devices/system/cpu/cpu2/online
        # perf record usleep 1
        # perf report --header-only | grep 'nrcpus \(online\|avail\)'
        # nrcpus online : 3
        # nrcpus avail : 4
        # echo 1 > /sys/devices/system/cpu/cpu1/online
        # perf record usleep 1
        # perf report --header-only | grep 'nrcpus \(online\|avail\)'
        # nrcpus online : 4
        # nrcpus avail : 4
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: fbe96f29 ("perf tools: Make perf.data more self-descriptive (v8)")
      Link: http://lkml.kernel.org/r/20150911153323.GP23511@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      caa47047
  22. 03 9月, 2015 1 次提交
    • K
      perf tools: Store the cpu socket and core ids in the perf.data header · 2bb00d2f
      Kan Liang 提交于
      This patch stores the cpu socket_id and core_id in a perf.data header,
      and reads them into the perf_env struct when processing perf.data files.
      
      The changes modifies the CPU_TOPOLOGY section, making sure it is
      backward/forward compatible.
      
      The patch checks the section size before reading the core and socket ids.
      
      It never reads data crossing the section boundary.  An old perf binary
      without this patch can also correctly read the perf.data from a new perf
      with this patch.
      
      Because the new info is added at the end of the cpu_topology section, an
      old perf tool ignores the extra data.
      
      Examples:
      
      1. New perf with this patch read perf.data from an old perf without the
         patch:
      
        $ perf_new report -i perf_old.data --header-only -I
        ......
        # sibling threads : 33
        # sibling threads : 34
        # sibling threads : 35
        # Core ID and Socket ID information is not available
        # node0 meminfo  : total = 32823872 kB, free = 29315548 kB
        # node0 cpu list : 0-17,36-53
        ......
      
      2. Old perf without the patch reads perf.data from a new perf with the
         patch:
      
        $ perf_old report -i perf_new.data --header-only -I
        ......
        # sibling threads : 33
        # sibling threads : 34
        # sibling threads : 35
        # node0 meminfo  : total = 32823872 kB, free = 29190932 kB
        # node0 cpu list : 0-17,36-53
        ......
      
      3. New perf read new perf.data:
      
        $ perf_new report -i perf_new.data --header-only -I
        ......
        # sibling threads : 33
        # sibling threads : 34
        # sibling threads : 35
        # CPU 0: Core ID 0, Socket ID 0
        # CPU 1: Core ID 1, Socket ID 0
        ......
        # CPU 61: Core ID 10, Socket ID 1
        # CPU 62: Core ID 11, Socket ID 1
        # CPU 63: Core ID 16, Socket ID 1
        # node0 meminfo  : total = 32823872 kB, free = 29190932 kB
        # node0 cpu list : 0-17,36-53
      Signed-off-by: NKan Liang <kan.liang@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/1441115893-22006-2-git-send-email-kan.liang@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2bb00d2f
  23. 29 8月, 2015 1 次提交