alistair23-linux/tools
Stephane Eranian 8ad9219e08 perf stat: Fix memory corruption of xyarray when cpumask is used
This patch fixes a memory corruption problem with the xyarray when the
evsel fds get closed at the end of the run_perf_stat() call.

It could be triggered with:

 # perf stat -a -e power/energy-cores/ ls

When cpumask are used by events (.e.g, RAPL or uncores) then the evsel
fds are allocated based on the actual number of CPUs monitored. That
number can be smaller than the total number of CPUs on the system.

The problem arises at the end by perf stat closes the fds twice. When
fds are closed, their entry in the xyarray are set to -1.

The first close() on the evsel is made from __run_perf_stat() and it
uses the actual number of CPUS for the event which is how the xyarray
was allocated for.

The second is from perf_evlist_close() but that one is on the total
number of CPUs in the system, so it assume the xyarray was allocated to
cover it. However it was not, and some writes corrupt memory.

The fix is in perf_evlist_close() is to first try with the evsel->cpus
if present, if not use the evlist->cpus. That fixes the problem.

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1389972846-6566-3-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-01-20 16:19:09 -03:00
..
cgroup
firewire
hv
include tools include: Include <linux/compiler.h> from asm/bug.h 2014-01-13 10:14:13 -03:00
lguest
lib tools lib traceevent: Unregister handler when xen plugin is unloaded 2014-01-16 16:26:25 -03:00
net
nfsd
perf perf stat: Fix memory corruption of xyarray when cpumask is used 2014-01-20 16:19:09 -03:00
power cpupower: Fix segfault due to incorrect getopt_long arugments 2013-12-17 11:29:30 -08:00
scripts tools lib traceevent: Add global QUIET_CC_FPIC build output 2013-12-19 16:18:10 -03:00
testing H8/300 has been dead for several years, the kernel for it has 2013-11-12 14:13:14 +09:00
thermal/tmon tools/thermal: Introduce tmon, a tool for thermal subsystem 2013-11-07 08:45:34 +08:00
usb usb: tools: fix a regression issue that gcc can't link to pthread 2013-12-04 15:10:54 -08:00
virtio virtio_test: verify if virtqueue_kick() succeeded 2013-10-29 11:28:16 +10:30
vm tools/: Convert to new topic libraries 2013-12-16 16:03:27 -03:00
Makefile tools/: Convert to new topic libraries 2013-12-16 16:03:27 -03:00