perf kvm stat live: Enable events copying
authorAlexander Yarygin <[email protected]>
Fri, 3 Oct 2014 14:40:12 +0000 (18:40 +0400)
committerArnaldo Carvalho de Melo <[email protected]>
Wed, 15 Oct 2014 20:39:03 +0000 (17:39 -0300)
Process of analyzing events caused by 2 functions: mmap_read() and
finished_round().

During mmap_read(), perf receives events from shared memory, queues
their pointers for further processing in finished_round() and notifies
the kernel that the events have been processed.

By the time when finished_round() is invoked, queued events can be
overwritten by the kernel, so the finished_round() occurs on potentially
corrupted memory.

Since there is no place where the event can be safely consumed, let's
copy events when queueing.

Signed-off-by: Alexander Yarygin <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/builtin-kvm.c

index ef9fc15fbfbfd60d63439877abcb72bf7113a17f..b65eb0507b38a97bb86b948eec3d6c045b5c27e1 100644 (file)
@@ -1358,6 +1358,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
        }
        kvm->session->evlist = kvm->evlist;
        perf_session__set_id_hdr_size(kvm->session);
+       ordered_events__set_copy_on_queue(&kvm->session->ordered_events, true);
        machine__synthesize_threads(&kvm->session->machines.host, &kvm->opts.target,
                                    kvm->evlist->threads, false);
        err = kvm_live_open_events(kvm);