perf tools: Fixup mmap event consumption
The tail position of the event buffer should only be modified after actually use that event. If not the event buffer could be invalid before use, and segment fault occurs when invoking perf top -G. Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn> Cc: David Ahern <dsahern@gmail.com> Cc: Zhouyi Zhou <yizhouzhou@ict.ac.cn> Link: http://lkml.kernel.org/r/1382600613-32177-1-git-send-email-zhouzhouyi@gmail.com [ Simplified the logic using exit gotos and renamed write_tail method to mmap_consume ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
ae779a6309
commit
8e50d384cc
@@ -987,7 +987,7 @@ again:
|
||||
err = perf_evlist__parse_sample(evlist, event, &sample);
|
||||
if (err) {
|
||||
fprintf(trace->output, "Can't parse sample, err = %d, skipping...\n", err);
|
||||
continue;
|
||||
goto next_event;
|
||||
}
|
||||
|
||||
if (trace->base_time == 0)
|
||||
@@ -1001,18 +1001,20 @@ again:
|
||||
evsel = perf_evlist__id2evsel(evlist, sample.id);
|
||||
if (evsel == NULL) {
|
||||
fprintf(trace->output, "Unknown tp ID %" PRIu64 ", skipping...\n", sample.id);
|
||||
continue;
|
||||
goto next_event;
|
||||
}
|
||||
|
||||
if (sample.raw_data == NULL) {
|
||||
fprintf(trace->output, "%s sample with no payload for tid: %d, cpu %d, raw_size=%d, skipping...\n",
|
||||
perf_evsel__name(evsel), sample.tid,
|
||||
sample.cpu, sample.raw_size);
|
||||
continue;
|
||||
goto next_event;
|
||||
}
|
||||
|
||||
handler = evsel->handler.func;
|
||||
handler(trace, evsel, &sample);
|
||||
next_event:
|
||||
perf_evlist__mmap_consume(evlist, i);
|
||||
|
||||
if (done)
|
||||
goto out_unmap_evlist;
|
||||
|
Reference in New Issue
Block a user