diff options
author | Jiri Olsa <jolsa@kernel.org> | 2018-08-17 13:45:56 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-08-20 08:54:59 -0300 |
commit | 721f0dfc3ce821c6a32820ab63edfb48ed4af075 (patch) | |
tree | 0cef3ac0e69c7b5e4406b0780bf98b2099c2c5e5 /tools/arch | |
parent | 31fb4c0d7b88f036edb96a6a3bd791289ea2f931 (diff) | |
download | linux-721f0dfc3ce821c6a32820ab63edfb48ed4af075.tar.gz linux-721f0dfc3ce821c6a32820ab63edfb48ed4af075.tar.bz2 linux-721f0dfc3ce821c6a32820ab63edfb48ed4af075.zip |
perf python: Fix pyrf_evlist__read_on_cpu() interface
Jaroslav reported errors from valgrind over perf python script:
# echo 0 > /sys/devices/system/cpu/cpu4/online
# valgrind ./test.py
==7524== Memcheck, a memory error detector
...
==7524== Command: ./test.py
==7524==
pid 7526 exited
==7524== Invalid read of size 8
==7524== at 0xCC2C2B3: perf_mmap__read_forward (evlist.c:780)
==7524== by 0xCC2A681: pyrf_evlist__read_on_cpu (python.c:959)
...
==7524== Address 0x65c4868 is 16 bytes after a block of size 459,36..
==7524== at 0x4C2B955: calloc (vg_replace_malloc.c:711)
==7524== by 0xCC2F484: zalloc (util.h:35)
==7524== by 0xCC2F484: perf_evlist__alloc_mmap (evlist.c:978)
...
The reason for this is in the python interface, that allows a script to
pass arbitrary cpu number, which is then used to access struct
perf_evlist::mmap array. That's obviously wrong and works only when if
all cpus are available and fails if some cpu is missing, like in the
example above.
This patch makes pyrf_evlist__read_on_cpu() search the evlist's maps
array for the proper map to access.
It's linear search at the moment. Based on the way how is the
read_on_cpu used, I don't think we need to be fast in here. But we
could add some hash in the middle to make it fast/er.
We don't allow python interface to set write_backward event attribute,
so it's safe to check only evlist's mmaps.
Reported-by: Jaroslav Škarvada <jskarvad@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Joe Mario <jmario@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180817114556.28000-3-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/arch')
0 files changed, 0 insertions, 0 deletions