diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-10-29 10:15:04 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-11-02 10:27:23 -0400 |
commit | 7b27509fc62686c53e9301560034e6b0b001174d (patch) | |
tree | 7b4fc36012d76d5319537df73fd5f7f50104b137 /tools/perf/util | |
parent | 1ca4ff41a3d887b8211e4a6c6c89c8f153d6bfa0 (diff) |
perf hists browser: Warn about lost events
Just like the old perf top --tui and the --stdio version.
But because we have the initial menu to choose which event to show in a
session with multiple events we can see how many chunks were lost in
each of the event types, clarifying which events are being affected the
most.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-47yyqbubmjzch2chezmb21m6@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/hist.h | 1 | ||||
-rw-r--r-- | tools/perf/util/session.c | 29 | ||||
-rw-r--r-- | tools/perf/util/top.h | 1 | ||||
-rw-r--r-- | tools/perf/util/ui/browser.c | 21 | ||||
-rw-r--r-- | tools/perf/util/ui/browser.h | 3 | ||||
-rw-r--r-- | tools/perf/util/ui/browsers/hists.c | 49 |
6 files changed, 86 insertions, 18 deletions
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index ff93ddc91c5c..c86c1d27bd1e 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -28,6 +28,7 @@ struct events_stats { | |||
28 | u64 total_lost; | 28 | u64 total_lost; |
29 | u64 total_invalid_chains; | 29 | u64 total_invalid_chains; |
30 | u32 nr_events[PERF_RECORD_HEADER_MAX]; | 30 | u32 nr_events[PERF_RECORD_HEADER_MAX]; |
31 | u32 nr_lost_warned; | ||
31 | u32 nr_unknown_events; | 32 | u32 nr_unknown_events; |
32 | u32 nr_invalid_chains; | 33 | u32 nr_invalid_chains; |
33 | u32 nr_unknown_id; | 34 | u32 nr_unknown_id; |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 91c6442ef966..da354fe5e085 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -738,10 +738,27 @@ static int perf_session_deliver_event(struct perf_session *session, | |||
738 | 738 | ||
739 | dump_event(session, event, file_offset, sample); | 739 | dump_event(session, event, file_offset, sample); |
740 | 740 | ||
741 | evsel = perf_evlist__id2evsel(session->evlist, sample->id); | ||
742 | if (evsel != NULL && event->header.type != PERF_RECORD_SAMPLE) { | ||
743 | /* | ||
744 | * XXX We're leaving PERF_RECORD_SAMPLE unnacounted here | ||
745 | * because the tools right now may apply filters, discarding | ||
746 | * some of the samples. For consistency, in the future we | ||
747 | * should have something like nr_filtered_samples and remove | ||
748 | * the sample->period from total_sample_period, etc, KISS for | ||
749 | * now tho. | ||
750 | * | ||
751 | * Also testing against NULL allows us to handle files without | ||
752 | * attr.sample_id_all and/or without PERF_SAMPLE_ID. In the | ||
753 | * future probably it'll be a good idea to restrict event | ||
754 | * processing via perf_session to files with both set. | ||
755 | */ | ||
756 | hists__inc_nr_events(&evsel->hists, event->header.type); | ||
757 | } | ||
758 | |||
741 | switch (event->header.type) { | 759 | switch (event->header.type) { |
742 | case PERF_RECORD_SAMPLE: | 760 | case PERF_RECORD_SAMPLE: |
743 | dump_sample(session, event, sample); | 761 | dump_sample(session, event, sample); |
744 | evsel = perf_evlist__id2evsel(session->evlist, sample->id); | ||
745 | if (evsel == NULL) { | 762 | if (evsel == NULL) { |
746 | ++session->hists.stats.nr_unknown_id; | 763 | ++session->hists.stats.nr_unknown_id; |
747 | return -1; | 764 | return -1; |
@@ -874,11 +891,11 @@ static void perf_session__warn_about_errors(const struct perf_session *session, | |||
874 | const struct perf_event_ops *ops) | 891 | const struct perf_event_ops *ops) |
875 | { | 892 | { |
876 | if (ops->lost == perf_event__process_lost && | 893 | if (ops->lost == perf_event__process_lost && |
877 | session->hists.stats.total_lost != 0) { | 894 | session->hists.stats.nr_events[PERF_RECORD_LOST] != 0) { |
878 | ui__warning("Processed %" PRIu64 " events and LOST %" PRIu64 | 895 | ui__warning("Processed %d events and lost %d chunks!\n\n" |
879 | "!\n\nCheck IO/CPU overload!\n\n", | 896 | "Check IO/CPU overload!\n\n", |
880 | session->hists.stats.total_period, | 897 | session->hists.stats.nr_events[0], |
881 | session->hists.stats.total_lost); | 898 | session->hists.stats.nr_events[PERF_RECORD_LOST]); |
882 | } | 899 | } |
883 | 900 | ||
884 | if (session->hists.stats.nr_unknown_events != 0) { | 901 | if (session->hists.stats.nr_unknown_events != 0) { |
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 01d1057f3074..399650967958 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h | |||
@@ -19,7 +19,6 @@ struct perf_top { | |||
19 | u64 kernel_samples, us_samples; | 19 | u64 kernel_samples, us_samples; |
20 | u64 exact_samples; | 20 | u64 exact_samples; |
21 | u64 guest_us_samples, guest_kernel_samples; | 21 | u64 guest_us_samples, guest_kernel_samples; |
22 | u64 total_lost_warned; | ||
23 | int print_entries, count_filter, delay_secs; | 22 | int print_entries, count_filter, delay_secs; |
24 | int freq; | 23 | int freq; |
25 | pid_t target_pid, target_tid; | 24 | pid_t target_pid, target_tid; |
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c index d2051be04f12..556829124b02 100644 --- a/tools/perf/util/ui/browser.c +++ b/tools/perf/util/ui/browser.c | |||
@@ -176,16 +176,29 @@ void ui_browser__handle_resize(struct ui_browser *browser) | |||
176 | ui_browser__refresh(browser); | 176 | ui_browser__refresh(browser); |
177 | } | 177 | } |
178 | 178 | ||
179 | int ui_browser__warning(struct ui_browser *browser, const char *format, ...) | 179 | int ui_browser__warning(struct ui_browser *browser, int timeout, |
180 | const char *format, ...) | ||
180 | { | 181 | { |
181 | va_list args; | 182 | va_list args; |
182 | int key; | 183 | char *text; |
184 | int key = 0, err; | ||
183 | 185 | ||
184 | va_start(args, format); | 186 | va_start(args, format); |
185 | while ((key = __ui__warning("Warning!", format, args)) == K_RESIZE) | 187 | err = vasprintf(&text, format, args); |
186 | ui_browser__handle_resize(browser); | ||
187 | va_end(args); | 188 | va_end(args); |
188 | 189 | ||
190 | if (err < 0) { | ||
191 | va_start(args, format); | ||
192 | ui_helpline__vpush(format, args); | ||
193 | va_end(args); | ||
194 | } else { | ||
195 | while ((key == ui__question_window("Warning!", text, | ||
196 | "Press any key...", | ||
197 | timeout)) == K_RESIZE) | ||
198 | ui_browser__handle_resize(browser); | ||
199 | free(text); | ||
200 | } | ||
201 | |||
189 | return key; | 202 | return key; |
190 | } | 203 | } |
191 | 204 | ||
diff --git a/tools/perf/util/ui/browser.h b/tools/perf/util/ui/browser.h index fb1c59883e6a..84d761b730c1 100644 --- a/tools/perf/util/ui/browser.h +++ b/tools/perf/util/ui/browser.h | |||
@@ -45,7 +45,8 @@ int ui_browser__run(struct ui_browser *browser, int delay_secs); | |||
45 | void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); | 45 | void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); |
46 | void ui_browser__handle_resize(struct ui_browser *browser); | 46 | void ui_browser__handle_resize(struct ui_browser *browser); |
47 | 47 | ||
48 | int ui_browser__warning(struct ui_browser *browser, const char *format, ...); | 48 | int ui_browser__warning(struct ui_browser *browser, int timeout, |
49 | const char *format, ...); | ||
49 | int ui_browser__help_window(struct ui_browser *browser, const char *text); | 50 | int ui_browser__help_window(struct ui_browser *browser, const char *text); |
50 | bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text); | 51 | bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text); |
51 | 52 | ||
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c index b8733c0770cd..d0c94b459685 100644 --- a/tools/perf/util/ui/browsers/hists.c +++ b/tools/perf/util/ui/browsers/hists.c | |||
@@ -295,6 +295,15 @@ static void hist_browser__set_folding(struct hist_browser *self, bool unfold) | |||
295 | ui_browser__reset_index(&self->b); | 295 | ui_browser__reset_index(&self->b); |
296 | } | 296 | } |
297 | 297 | ||
298 | static void ui_browser__warn_lost_events(struct ui_browser *browser) | ||
299 | { | ||
300 | ui_browser__warning(browser, 4, | ||
301 | "Events are being lost, check IO/CPU overload!\n\n" | ||
302 | "You may want to run 'perf' using a RT scheduler policy:\n\n" | ||
303 | " perf top -r 80\n\n" | ||
304 | "Or reduce the sampling frequency."); | ||
305 | } | ||
306 | |||
298 | static int hist_browser__run(struct hist_browser *self, const char *ev_name, | 307 | static int hist_browser__run(struct hist_browser *self, const char *ev_name, |
299 | void(*timer)(void *arg), void *arg, int delay_secs) | 308 | void(*timer)(void *arg), void *arg, int delay_secs) |
300 | { | 309 | { |
@@ -318,8 +327,15 @@ static int hist_browser__run(struct hist_browser *self, const char *ev_name, | |||
318 | case K_TIMER: | 327 | case K_TIMER: |
319 | timer(arg); | 328 | timer(arg); |
320 | ui_browser__update_nr_entries(&self->b, self->hists->nr_entries); | 329 | ui_browser__update_nr_entries(&self->b, self->hists->nr_entries); |
321 | hists__browser_title(self->hists, title, sizeof(title), | 330 | |
322 | ev_name); | 331 | if (self->hists->stats.nr_lost_warned != |
332 | self->hists->stats.nr_events[PERF_RECORD_LOST]) { | ||
333 | self->hists->stats.nr_lost_warned = | ||
334 | self->hists->stats.nr_events[PERF_RECORD_LOST]; | ||
335 | ui_browser__warn_lost_events(&self->b); | ||
336 | } | ||
337 | |||
338 | hists__browser_title(self->hists, title, sizeof(title), ev_name); | ||
323 | ui_browser__show_title(&self->b, title); | 339 | ui_browser__show_title(&self->b, title); |
324 | continue; | 340 | continue; |
325 | case 'D': { /* Debug */ | 341 | case 'D': { /* Debug */ |
@@ -883,7 +899,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
883 | goto out_free_stack; | 899 | goto out_free_stack; |
884 | case 'a': | 900 | case 'a': |
885 | if (!browser->has_symbols) { | 901 | if (!browser->has_symbols) { |
886 | ui_browser__warning(&browser->b, | 902 | ui_browser__warning(&browser->b, delay_secs * 2, |
887 | "Annotation is only available for symbolic views, " | 903 | "Annotation is only available for symbolic views, " |
888 | "include \"sym\" in --sort to use it."); | 904 | "include \"sym\" in --sort to use it."); |
889 | continue; | 905 | continue; |
@@ -1061,6 +1077,7 @@ out: | |||
1061 | struct perf_evsel_menu { | 1077 | struct perf_evsel_menu { |
1062 | struct ui_browser b; | 1078 | struct ui_browser b; |
1063 | struct perf_evsel *selection; | 1079 | struct perf_evsel *selection; |
1080 | bool lost_events, lost_events_warned; | ||
1064 | }; | 1081 | }; |
1065 | 1082 | ||
1066 | static void perf_evsel_menu__write(struct ui_browser *browser, | 1083 | static void perf_evsel_menu__write(struct ui_browser *browser, |
@@ -1073,14 +1090,29 @@ static void perf_evsel_menu__write(struct ui_browser *browser, | |||
1073 | unsigned long nr_events = evsel->hists.stats.nr_events[PERF_RECORD_SAMPLE]; | 1090 | unsigned long nr_events = evsel->hists.stats.nr_events[PERF_RECORD_SAMPLE]; |
1074 | const char *ev_name = event_name(evsel); | 1091 | const char *ev_name = event_name(evsel); |
1075 | char bf[256], unit; | 1092 | char bf[256], unit; |
1093 | const char *warn = " "; | ||
1094 | size_t printed; | ||
1076 | 1095 | ||
1077 | ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED : | 1096 | ui_browser__set_color(browser, current_entry ? HE_COLORSET_SELECTED : |
1078 | HE_COLORSET_NORMAL); | 1097 | HE_COLORSET_NORMAL); |
1079 | 1098 | ||
1080 | nr_events = convert_unit(nr_events, &unit); | 1099 | nr_events = convert_unit(nr_events, &unit); |
1081 | snprintf(bf, sizeof(bf), "%lu%c%s%s", nr_events, | 1100 | printed = snprintf(bf, sizeof(bf), "%lu%c%s%s", nr_events, |
1082 | unit, unit == ' ' ? "" : " ", ev_name); | 1101 | unit, unit == ' ' ? "" : " ", ev_name); |
1083 | slsmg_write_nstring(bf, browser->width); | 1102 | slsmg_printf("%s", bf); |
1103 | |||
1104 | nr_events = evsel->hists.stats.nr_events[PERF_RECORD_LOST]; | ||
1105 | if (nr_events != 0) { | ||
1106 | menu->lost_events = true; | ||
1107 | if (!current_entry) | ||
1108 | ui_browser__set_color(browser, HE_COLORSET_TOP); | ||
1109 | nr_events = convert_unit(nr_events, &unit); | ||
1110 | snprintf(bf, sizeof(bf), ": %ld%c%schunks LOST!", nr_events, | ||
1111 | unit, unit == ' ' ? "" : " "); | ||
1112 | warn = bf; | ||
1113 | } | ||
1114 | |||
1115 | slsmg_write_nstring(warn, browser->width - printed); | ||
1084 | 1116 | ||
1085 | if (current_entry) | 1117 | if (current_entry) |
1086 | menu->selection = evsel; | 1118 | menu->selection = evsel; |
@@ -1105,6 +1137,11 @@ static int perf_evsel_menu__run(struct perf_evsel_menu *menu, | |||
1105 | switch (key) { | 1137 | switch (key) { |
1106 | case K_TIMER: | 1138 | case K_TIMER: |
1107 | timer(arg); | 1139 | timer(arg); |
1140 | |||
1141 | if (!menu->lost_events_warned && menu->lost_events) { | ||
1142 | ui_browser__warn_lost_events(&menu->b); | ||
1143 | menu->lost_events_warned = true; | ||
1144 | } | ||
1108 | continue; | 1145 | continue; |
1109 | case K_RIGHT: | 1146 | case K_RIGHT: |
1110 | case K_ENTER: | 1147 | case K_ENTER: |