diff options
author | Zhouyi Zhou <zhouzhouyi@gmail.com> | 2013-10-24 03:43:33 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-10-28 15:06:00 -0400 |
commit | 8e50d384cc1d5afd2989cf0f7093756ed7164eb2 (patch) | |
tree | 87e34b49783a32d8552eaad510d0b5fba94ee08e /tools/perf/builtin-top.c | |
parent | ae779a630977d93fbebfa06216ea47df5b5c62c8 (diff) |
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>
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r-- | tools/perf/builtin-top.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 0df298a0e946..5a11f13e56f9 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -810,7 +810,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
810 | ret = perf_evlist__parse_sample(top->evlist, event, &sample); | 810 | ret = perf_evlist__parse_sample(top->evlist, event, &sample); |
811 | if (ret) { | 811 | if (ret) { |
812 | pr_err("Can't parse sample, err = %d\n", ret); | 812 | pr_err("Can't parse sample, err = %d\n", ret); |
813 | continue; | 813 | goto next_event; |
814 | } | 814 | } |
815 | 815 | ||
816 | evsel = perf_evlist__id2evsel(session->evlist, sample.id); | 816 | evsel = perf_evlist__id2evsel(session->evlist, sample.id); |
@@ -825,13 +825,13 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
825 | case PERF_RECORD_MISC_USER: | 825 | case PERF_RECORD_MISC_USER: |
826 | ++top->us_samples; | 826 | ++top->us_samples; |
827 | if (top->hide_user_symbols) | 827 | if (top->hide_user_symbols) |
828 | continue; | 828 | goto next_event; |
829 | machine = &session->machines.host; | 829 | machine = &session->machines.host; |
830 | break; | 830 | break; |
831 | case PERF_RECORD_MISC_KERNEL: | 831 | case PERF_RECORD_MISC_KERNEL: |
832 | ++top->kernel_samples; | 832 | ++top->kernel_samples; |
833 | if (top->hide_kernel_symbols) | 833 | if (top->hide_kernel_symbols) |
834 | continue; | 834 | goto next_event; |
835 | machine = &session->machines.host; | 835 | machine = &session->machines.host; |
836 | break; | 836 | break; |
837 | case PERF_RECORD_MISC_GUEST_KERNEL: | 837 | case PERF_RECORD_MISC_GUEST_KERNEL: |
@@ -847,7 +847,7 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
847 | */ | 847 | */ |
848 | /* Fall thru */ | 848 | /* Fall thru */ |
849 | default: | 849 | default: |
850 | continue; | 850 | goto next_event; |
851 | } | 851 | } |
852 | 852 | ||
853 | 853 | ||
@@ -859,6 +859,8 @@ static void perf_top__mmap_read_idx(struct perf_top *top, int idx) | |||
859 | machine__process_event(machine, event); | 859 | machine__process_event(machine, event); |
860 | } else | 860 | } else |
861 | ++session->stats.nr_unknown_events; | 861 | ++session->stats.nr_unknown_events; |
862 | next_event: | ||
863 | perf_evlist__mmap_consume(top->evlist, idx); | ||
862 | } | 864 | } |
863 | } | 865 | } |
864 | 866 | ||