linux_dsm_epyc7002/tools/perf/util
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
..
c++ perf tools: Fix a clang 7.0 compilation error 2018-06-25 11:59:37 -03:00
cs-etm-decoder perf cs-etm: Fix start tracing packet handling 2018-07-31 10:57:56 -03:00
include
intel-pt-decoder perf intel-pt: Fix packet decoding of CYC packets 2018-06-25 11:59:36 -03:00
libunwind
scripting-engines tools lib traceevent, perf tools: Rename pevent_read_number_* APIs 2018-08-13 15:22:05 -03:00
annotate.c perf tools: Get rid of dso__needs_decompress() call in symbol__disassemble() 2018-08-20 08:54:59 -03:00
annotate.h perf annotate: Add --percent-type option 2018-08-08 15:55:53 -03:00
arm-spe-pkt-decoder.c
arm-spe-pkt-decoder.h
arm-spe.c
arm-spe.h
auxtrace.c perf auxtrace: Fix queue resize 2018-08-14 19:00:53 -03:00
auxtrace.h perf auxtrace: Support for perf report -D for s390 2018-08-03 10:34:18 -03:00
block-range.c
block-range.h
bpf-loader.c perf bpf: Make bpf__setup_output_event() return the bpf-output event 2018-08-08 15:55:58 -03:00
bpf-loader.h perf bpf: Make bpf__setup_output_event() return the bpf-output event 2018-08-08 15:55:58 -03:00
bpf-prologue.c docs: Fix some broken references 2018-06-15 18:10:01 -03:00
bpf-prologue.h
branch.c
branch.h
Build perf auxtrace: Support for perf report -D for s390 2018-08-03 10:34:18 -03:00
build-id.c
build-id.h
cache.h
call-path.c
call-path.h
callchain.c
callchain.h
cgroup.c perf cgroup: Make evlist__find_cgroup() more compact 2018-06-04 10:28:50 -03:00
cgroup.h
cloexec.c
cloexec.h
color.c
color.h
comm.c perf tools: Fix struct comm_str removal crash 2018-07-24 14:54:03 -03:00
comm.h
compress.h perf tools: Add is_compressed callback to compressions array 2018-08-20 08:54:59 -03:00
config.c
config.h
counts.c
counts.h
cpumap.c
cpumap.h
cs-etm.c perf cs-etm: Generate branch sample for CS_ETM_TRACE_ON packet 2018-07-31 11:22:50 -03:00
cs-etm.h
ctype.c
data-convert-bt.c tools lib traceevent, perf tools: Rename pevent_read_number_* APIs 2018-08-13 15:22:05 -03:00
data-convert-bt.h
data-convert.h
data.c
data.h
db-export.c
db-export.h
debug.c
debug.h
demangle-java.c
demangle-java.h
demangle-rust.c
demangle-rust.h
drv_configs.c
drv_configs.h
dso.c perf tools: Remove ext from struct kmod_path 2018-08-20 08:54:59 -03:00
dso.h perf tools: Remove ext from struct kmod_path 2018-08-20 08:54:59 -03:00
dump-insn.c
dump-insn.h
dwarf-aux.c
dwarf-aux.h
dwarf-regs.c
env.c
env.h
event.c perf map: Synthesize maps only for thread group leader 2018-08-08 15:55:59 -03:00
event.h
evlist.c perf mmap: Store real cpu number in 'struct perf_mmap' 2018-08-20 08:54:59 -03:00
evlist.h
evsel_fprintf.c
evsel.c tools lib traceevent, perf tools: Rename pevent find APIs 2018-08-13 15:21:51 -03:00
evsel.h perf annotate: Loop group events directly in annotation__calc_percent() 2018-08-08 15:55:47 -03:00
expr.h
expr.y
find-vdso-map.c
genelf_debug.c
genelf.c
genelf.h
generate-cmdlist.sh
group.h
header.c tools lib traceevent, perf tools: Rename pevent find APIs 2018-08-13 15:21:51 -03:00
header.h perf tools: Fix the build on the alpine:edge distro 2018-07-30 13:15:03 -03:00
help-unknown-cmd.c
help-unknown-cmd.h
hist.c perf hists: Reimplement hists__has_callchains() 2018-06-07 14:42:27 -03:00
hist.h perf hists: Clarify callchain disabling when available 2018-07-24 14:37:33 -03:00
intel-bts.c
intel-bts.h
intel-pt.c perf intel-pt: Fix "Unexpected indirect branch" error 2018-06-06 12:52:08 -03:00
intel-pt.h
intlist.c
intlist.h
jit.h
jitdump.c
jitdump.h
kvm-stat.h
levenshtein.c
levenshtein.h
llvm-utils.c perf llvm: Allow passing options to llc in addition to clang 2018-08-20 08:54:58 -03:00
llvm-utils.h perf llvm: Allow passing options to llc in addition to clang 2018-08-20 08:54:58 -03:00
lzma.c perf tools: Add lzma_is_compressed function 2018-08-20 08:54:59 -03:00
machine.c perf tools: Store compression id into struct dso 2018-08-20 08:54:59 -03:00
machine.h tools lib traceevent, perf tools: Rename pevent_set_* APIs 2018-08-13 15:22:10 -03:00
map.c perf map: Optimize maps__fixup_overlappings() 2018-08-08 15:56:00 -03:00
map.h perf map: Optimize maps__fixup_overlappings() 2018-08-08 15:56:00 -03:00
mem2node.c
mem2node.h
mem-events.c
mem-events.h
memswap.c
memswap.h
metricgroup.c perf list: Unify metric group description format with PMU event description 2018-07-31 11:35:44 -03:00
metricgroup.h perf stat: Add transaction flag (-T) support for s390 2018-07-24 14:49:37 -03:00
mmap.c perf mmap: Store real cpu number in 'struct perf_mmap' 2018-08-20 08:54:59 -03:00
mmap.h perf mmap: Store real cpu number in 'struct perf_mmap' 2018-08-20 08:54:59 -03:00
namespaces.c perf tools: Check for null when copying nsinfo. 2018-08-13 15:39:09 -03:00
namespaces.h perf tools: Fix the build on the alpine:edge distro 2018-07-30 13:15:03 -03:00
ordered-events.c
ordered-events.h
parse-branch-options.c
parse-branch-options.h
parse-events.c perf parser: Improve error message for PMU address filters 2018-08-20 08:54:58 -03:00
parse-events.h
parse-events.l perf record: Enable arbitrary event names thru name= modifier 2018-06-06 12:52:04 -03:00
parse-events.y perf tools: Fix error index for pmu event parser 2018-06-07 15:50:14 -03:00
parse-regs-options.c
parse-regs-options.h
path.c
path.h
perf_regs.c
perf_regs.h
perf-hooks-list.h
perf-hooks.c
perf-hooks.h
PERF-VERSION-GEN
pmu.c Revert "perf list: Add s390 support for detailed/verbose PMU event description" 2018-07-24 14:48:58 -03:00
pmu.h
pmu.l
pmu.y
print_binary.c
print_binary.h
probe-event.c perf probe: Use return of map__get() to make code more compact 2018-06-04 10:28:50 -03:00
probe-event.h
probe-file.c
probe-file.h
probe-finder.c
probe-finder.h
pstack.c
pstack.h
python-ext-sources
python.c perf python: Fix pyrf_evlist__read_on_cpu() interface 2018-08-20 08:54:59 -03:00
rb_resort.h
rblist.c
rblist.h
record.c
rwsem.c
rwsem.h
s390-cpumsf-kernel.h perf report: Add raw report support for s390 auxiliary trace 2018-08-08 15:26:48 -03:00
s390-cpumsf.c perf report: Add GUI report support for s390 auxiliary trace 2018-08-08 15:49:17 -03:00
s390-cpumsf.h perf auxtrace: Support for perf report -D for s390 2018-08-03 10:34:18 -03:00
sane_ctype.h
session.c perf evsel: Add has_callchain() helper to make code more compact/clear 2018-06-05 10:09:54 -03:00
session.h
setns.c
setup.py perf python: Remove -mcet and -fcf-protection when building with clang 2018-08-14 18:50:20 -03:00
smt.c
smt.h
sort.c tools lib traceevent, perf tools: Rename pevent_read_number_* APIs 2018-08-13 15:22:05 -03:00
sort.h tools lib traceevent, perf tools: Rename struct pevent to struct tep_handle 2018-08-10 15:29:35 -03:00
srcline.c
srcline.h
stat-shadow.c perf stat: Get rid of extra clock display function 2018-07-24 14:54:58 -03:00
stat.c
stat.h
strbuf.c
strbuf.h
strfilter.c
strfilter.h
string2.h
string.c
strlist.c
strlist.h
svghelper.c
svghelper.h
symbol_fprintf.c
symbol-elf.c
symbol-minimal.c
symbol.c perf symbols: Add BSS symbols when reading from /proc/kallsyms 2018-06-06 12:52:09 -03:00
symbol.h perf annotate: Adopt anotation options from symbol_conf 2018-06-04 10:28:53 -03:00
syscalltbl.c perf trace arm64: Use generated syscall table 2018-07-24 14:53:01 -03:00
syscalltbl.h
target.c
target.h
term.c
term.h
thread_map.c
thread_map.h
thread-stack.c
thread-stack.h
thread.c
thread.h
time-utils.c
time-utils.h
tool.h
top.c
top.h perf annotate stdio: Use annotation_options consistently 2018-06-04 10:28:52 -03:00
trace-event-info.c
trace-event-parse.c tools lib traceevent, perf tools: Rename pevent_register_* APIs 2018-08-13 15:22:08 -03:00
trace-event-read.c tools lib traceevent, perf tools: Rename 'enum pevent_flag' to 'enum tep_flag' 2018-08-13 15:22:18 -03:00
trace-event-scripting.c tools lib traceevent, perf tools: Rename struct pevent to struct tep_handle 2018-08-10 15:29:35 -03:00
trace-event.c tools lib traceevent, perf tools: Rename 'enum pevent_flag' to 'enum tep_flag' 2018-08-13 15:22:18 -03:00
trace-event.h tools lib traceevent, perf tools: Rename pevent alloc / free APIs 2018-08-13 15:21:43 -03:00
trigger.h
tsc.c
tsc.h
units.c
units.h
unwind-libdw.c perf script: Show correct offsets for DWARF-based unwinding 2018-07-24 14:53:11 -03:00
unwind-libdw.h
unwind-libunwind-local.c perf script: Show correct offsets for DWARF-based unwinding 2018-07-24 14:53:11 -03:00
unwind-libunwind.c
unwind.h
usage.c
util-cxx.h
util.c
util.h
values.c
values.h
vdso.c
vdso.h
xyarray.c
xyarray.h
zlib.c perf tools: Add gzip_is_compressed function 2018-08-20 08:54:59 -03:00