linux/tools/perf
Alexander Yarygin 54bf53b1cb perf session: Add option to copy events when queueing
When processing events the session code has an ordered samples queue
which is used to time-sort events coming in across multiple mmaps. At a
later point in time samples on the queue are flushed up to some
timestamp at which point the event is actually processed.

When analyzing events live (ie., record/analysis path in the same
command) there is a race that leads to corrupted events and parse errors
which cause perf to terminate. The problem is that when the event is
placed in the ordered samples queue it is only a reference to the event
which is really sitting in the mmap buffer. Even though the event is
queued for later processing the mmap tail pointer is updated which
indicates to the kernel that the event has been processed. The race is
flushing the event from the queue before it gets overwritten by some
other event. For commands trying to process events live (versus just
writing to a file) and processing a high rate of events this leads to
parse failures and perf terminates.

Examples hitting this problem are 'perf kvm stat live', especially with
nested VMs which generate 100,000+ traces per second, and a command
processing scheduling events with a high rate of context switching --
e.g., running 'perf bench sched pipe'.

This patch offers live commands an option to copy the event when it is
placed in the ordered samples queue.

Based on a patch from David Ahern <dsahern@gmail.com>

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1412347212-28237-2-git-send-email-yarygin@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-15 17:39:03 -03:00
..
arch perf tools: Fix build breakage on arm64 targets 2014-10-01 14:44:17 -03:00
bench perf bench futex: Sanitize -q option in requeue 2014-09-29 15:43:26 -03:00
config perf tools: Fix GNU-only grep usage in Makefile 2014-09-17 17:08:09 -03:00
Documentation perf Documentation: Fix typos in perf/Documentation 2014-10-15 17:39:02 -03:00
python perf python: Remove duplicate TID bit from mask 2013-08-07 17:35:25 -03:00
scripts perf script: Add callchain to generic and tracepoint events 2014-07-16 17:57:33 -03:00
tests perf report: Set callchain_param.record_mode for future use 2014-10-15 16:20:03 -03:00
ui perf top: Add a visual cue for toggle zeroing of samples 2014-10-15 15:47:48 -03:00
util perf session: Add option to copy events when queueing 2014-10-15 17:39:03 -03:00
.gitignore perf tools: Add perf-with-kcore script 2014-09-17 17:08:08 -03:00
builtin-annotate.c perf tools: Remove hists from evsel 2014-10-14 17:32:52 -03:00
builtin-bench.c perf bench: Add --repeat option 2014-06-19 16:13:15 -03:00
builtin-buildid-cache.c perf buildid-cache: Use strerror_r instead of strerror 2014-08-15 13:07:59 -03:00
builtin-buildid-list.c perf session: Separating data file properties from session 2013-10-21 17:33:25 -03:00
builtin-diff.c perf evsel: Add hists helper 2014-10-09 13:13:41 -03:00
builtin-evlist.c perf tools: Modify error code for when perf_session__new() fails 2014-09-26 12:32:58 -03:00
builtin-help.c perf help: Use strerror_r instead of strerror 2014-08-15 13:08:26 -03:00
builtin-inject.c perf tools: Modify error code for when perf_session__new() fails 2014-09-26 12:32:58 -03:00
builtin-kmem.c perf tools: Modify error code for when perf_session__new() fails 2014-09-26 12:32:58 -03:00
builtin-kvm.c perf kvm: Use thread_{,_set}_priv helpers 2014-10-15 17:39:01 -03:00
builtin-list.c perf list: Add usage 2013-11-05 14:26:41 -03:00
builtin-lock.c perf tools: Modify error code for when perf_session__new() fails 2014-09-26 12:32:58 -03:00
builtin-mem.c perf tools: Modify error code for when perf_session__new() fails 2014-09-26 12:32:58 -03:00
builtin-probe.c perf probe: Do not access kallsyms when analyzing user binaries 2014-09-17 18:01:14 -03:00
builtin-record.c perf callchain: Move the callchain_param extern to callchain.h 2014-10-14 17:32:51 -03:00
builtin-report.c perf report: Set callchain_param.record_mode for future use 2014-10-15 16:20:03 -03:00
builtin-sched.c perf sched: Stop updating hists stats, not used 2014-10-09 11:46:35 -03:00
builtin-script.c perf script: Stop updating hists stats, not used 2014-10-09 11:46:41 -03:00
builtin-stat.c perf stat: Fix --per-core on multi socket systems 2014-09-26 10:17:13 -03:00
builtin-timechart.c perf tools: Modify error code for when perf_session__new() fails 2014-09-26 12:32:58 -03:00
builtin-top.c perf tools: Remove hists from evsel 2014-10-14 17:32:52 -03:00
builtin-trace.c perf trace: Use thread_{,_set}_priv helpers 2014-10-15 17:39:02 -03:00
builtin.h perf tools: Add new mem command for memory access profiling 2013-04-01 12:21:44 -03:00
command-list.txt perf tools: Add new mem command for memory access profiling 2013-04-01 12:21:44 -03:00
CREDITS perf_counter tools: Add CREDITS file for Git contributors 2009-06-24 19:54:29 +02:00
design.txt perf tools: Update some code references in design.txt 2014-03-18 18:17:06 -03:00
Makefile perf tools: Add 'build-test' make target 2014-01-16 16:26:26 -03:00
Makefile.perf tools lib api: Adopt fdarray class from perf's evlist 2014-09-25 16:46:55 -03:00
MANIFEST perf kvm: Add stat support on s390 2014-07-16 17:57:33 -03:00
perf-archive.sh perf archive: Make 'f' the last parameter for tar 2012-09-17 13:10:42 -03:00
perf-completion.sh perf sched: Introduce --list-cmds for use by scripts 2014-04-16 17:16:05 +02:00
perf-sys.h perf tools: Allow to use cpuinfo on s390 2014-07-07 16:55:24 -03:00
perf-with-kcore.sh perf tools: Add perf-with-kcore script 2014-09-17 17:08:08 -03:00
perf.c perf: Use strerror_r instead of strerror 2014-08-15 10:54:29 -03:00
perf.h perf tools: Move callchain config from record_opts to callchain_param 2014-09-26 12:40:33 -03:00