Jiri Olsa
721f0dfc3c
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 >
2018-08-20 08:54:59 -03:00
..
2018-06-25 11:59:37 -03:00
2018-07-31 10:57:56 -03:00
2017-11-02 11:10:55 +01:00
2018-06-25 11:59:36 -03:00
2017-11-02 11:10:55 +01:00
2018-08-13 15:22:05 -03:00
2018-08-20 08:54:59 -03:00
2018-08-08 15:55:53 -03:00
2018-01-17 10:23:31 -03:00
2018-01-17 10:23:31 -03:00
2018-01-17 10:23:31 -03:00
2018-01-17 10:23:31 -03:00
2018-08-14 19:00:53 -03:00
2018-08-03 10:34:18 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-08-08 15:55:58 -03:00
2018-08-08 15:55:58 -03:00
2018-06-15 18:10:01 -03:00
2017-11-02 11:10:55 +01:00
2017-07-18 23:14:40 -03:00
2017-07-25 22:46:35 -03:00
2018-08-03 10:34:18 -03:00
2018-04-26 13:47:08 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-01-17 10:23:32 -03:00
2018-01-17 10:23:32 -03:00
2018-06-04 10:28:50 -03:00
2018-03-07 10:22:26 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-07-24 14:54:03 -03:00
2017-11-02 11:10:55 +01:00
2018-08-20 08:54:59 -03:00
2018-05-16 16:11:09 -03:00
2018-05-16 16:11:09 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-07-31 11:22:50 -03:00
2018-04-19 12:29:41 -03:00
2017-11-02 11:10:55 +01:00
2018-08-13 15:22:05 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-01-23 09:48:20 -03:00
2017-11-07 10:30:18 +01:00
2018-04-27 10:47:06 -03:00
2018-03-16 16:39:02 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-04-19 13:01:51 -03:00
2016-09-22 12:19:41 -03:00
2018-08-20 08:54:59 -03:00
2018-08-20 08:54:59 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-02 13:50:24 -03:00
2016-09-29 11:17:08 -03:00
2017-11-02 11:10:55 +01:00
2018-05-22 10:52:49 -03:00
2018-05-22 10:52:49 -03:00
2018-08-08 15:55:59 -03:00
2018-05-23 10:26:39 -03:00
2018-08-20 08:54:59 -03:00
2018-05-21 14:40:54 -03:00
2017-11-07 10:30:18 +01:00
2018-08-13 15:21:51 -03:00
2018-08-08 15:55:47 -03:00
2017-11-02 11:10:55 +01:00
2017-08-22 12:19:08 -03:00
2017-11-02 11:10:55 +01:00
2017-06-19 15:27:07 -03:00
2018-04-30 12:02:03 -03:00
2017-11-02 11:10:55 +01:00
2018-04-12 10:33:31 -03:00
2017-11-02 11:10:55 +01:00
2018-08-13 15:21:51 -03:00
2018-07-30 13:15:03 -03:00
2017-11-02 11:10:55 +01:00
2018-06-07 14:42:27 -03:00
2018-07-24 14:37:33 -03:00
2018-04-26 13:47:08 -03:00
2018-06-06 12:52:08 -03:00
2016-09-29 11:17:05 -03:00
2017-11-02 11:10:55 +01:00
2017-11-07 10:30:18 +01:00
2017-11-07 10:30:18 +01:00
2016-10-24 11:07:39 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-08-20 08:54:58 -03:00
2018-08-20 08:54:58 -03:00
2018-08-20 08:54:59 -03:00
2018-08-20 08:54:59 -03:00
2018-08-13 15:22:10 -03:00
2018-08-08 15:56:00 -03:00
2018-08-08 15:56:00 -03:00
2018-03-16 13:52:37 -03:00
2018-03-16 13:52:37 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-07-31 11:35:44 -03:00
2018-07-24 14:49:37 -03:00
2018-08-20 08:54:59 -03:00
2018-08-20 08:54:59 -03:00
2018-08-13 15:39:09 -03:00
2018-07-30 13:15:03 -03:00
2017-11-17 12:14:09 -03:00
2017-11-17 12:14:09 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-08-20 08:54:58 -03:00
2018-05-30 10:40:44 -03:00
2018-06-06 12:52:04 -03:00
2018-06-07 15:50:14 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-12-27 12:15:48 -03:00
2017-12-27 12:15:48 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2016-11-29 12:13:27 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-07-24 14:48:58 -03:00
2017-12-05 10:24:33 -03:00
2017-11-07 10:30:18 +01:00
2017-11-07 10:30:18 +01:00
2018-06-04 10:28:50 -03:00
2017-11-02 11:10:55 +01:00
2018-05-16 16:27:14 -03:00
2017-11-02 11:10:55 +01:00
2018-03-19 13:51:53 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-12-27 12:15:56 -03:00
2018-08-20 08:54:59 -03:00
2017-11-07 10:30:18 +01:00
2017-12-05 10:24:31 -03:00
2017-12-05 10:24:31 -03:00
2018-03-05 11:52:41 -03:00
2017-09-21 13:28:06 -03:00
2017-09-21 13:28:06 -03:00
2018-08-08 15:26:48 -03:00
2018-08-08 15:49:17 -03:00
2018-08-03 10:34:18 -03:00
2017-11-02 11:10:55 +01:00
2018-06-05 10:09:54 -03:00
2017-11-18 08:59:27 +01:00
2017-07-18 23:14:08 -03:00
2018-08-14 18:50:20 -03:00
2017-08-22 12:09:04 -03:00
2017-08-22 12:09:04 -03:00
2018-08-13 15:22:05 -03:00
2018-08-10 15:29:35 -03:00
2018-04-26 13:47:18 -03:00
2018-01-08 11:11:57 -03:00
2018-07-24 14:54:58 -03:00
2018-03-16 13:56:17 -03:00
2018-04-26 09:30:27 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-12-27 12:15:55 -03:00
2017-12-27 12:15:55 -03:00
2017-04-24 13:43:33 -03:00
2017-11-02 11:10:55 +01:00
2016-08-23 15:37:33 -03:00
2017-11-02 11:10:55 +01:00
2018-04-27 10:47:06 -03:00
2018-05-23 10:26:44 -03:00
2018-04-27 10:47:06 -03:00
2018-06-06 12:52:09 -03:00
2018-06-04 10:28:53 -03:00
2018-07-24 14:53:01 -03:00
2017-11-02 11:10:55 +01:00
2016-07-29 11:54:35 -03:00
2017-12-27 12:15:47 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-02-27 11:29:21 -03:00
2018-02-27 11:29:21 -03:00
2017-04-19 13:01:51 -03:00
2018-04-27 10:47:06 -03:00
2018-04-26 13:47:17 -03:00
2018-01-17 10:23:36 -03:00
2018-01-17 10:23:36 -03:00
2018-01-10 12:00:55 -03:00
2018-06-04 10:28:52 -03:00
2018-05-17 12:01:50 -03:00
2018-08-13 15:22:08 -03:00
2018-08-13 15:22:18 -03:00
2018-08-10 15:29:35 -03:00
2018-08-13 15:22:18 -03:00
2018-08-13 15:21:43 -03:00
2018-03-06 11:31:14 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-07-24 14:53:11 -03:00
2017-11-02 11:10:55 +01:00
2018-07-24 14:53:11 -03:00
2017-12-27 12:15:52 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-05-17 16:31:32 -03:00
2018-05-17 16:31:32 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-04-26 13:47:15 -03:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2017-11-02 11:10:55 +01:00
2018-08-20 08:54:59 -03:00