Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Fix lost and unknown events handling

Fix it by explaining what can be happening and giving the number of processed
and lost events.

Also holler if unknown events were found, that can be due to processing a
perf.data file collected using a newer tool where newer events got added on
reporting using an older perf tool, that or a bug, so ask for a report to be
made.

Works on both --tui and --stdio.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+46 -1
+11
tools/perf/util/debug.c
··· 46 46 return ret; 47 47 } 48 48 49 + #ifdef NO_NEWT_SUPPORT 50 + void ui__warning(const char *format, ...) 51 + { 52 + va_list args; 53 + 54 + va_start(args, format); 55 + vfprintf(stderr, format, args); 56 + va_end(args); 57 + } 58 + #endif 59 + 49 60 static int dump_printf_color(const char *fmt, const char *color, ...) 50 61 { 51 62 va_list args;
+2
tools/perf/util/debug.h
··· 35 35 #include "ui/progress.h" 36 36 #endif 37 37 38 + void ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); 39 + 38 40 #endif /* __PERF_DEBUG_H */
+18
tools/perf/util/session.c
··· 852 852 flush_sample_queue(self, ops); 853 853 out_err: 854 854 ui_progress__delete(progress); 855 + 856 + if (ops->lost == event__process_lost && 857 + self->hists.stats.total_lost != 0) { 858 + ui__warning("Processed %Lu events and LOST %Lu!\n\n" 859 + "Check IO/CPU overload!\n\n", 860 + self->hists.stats.total_period, 861 + self->hists.stats.total_lost); 862 + } 863 + 864 + if (self->hists.stats.nr_unknown_events != 0) { 865 + ui__warning("Found %u unknown events!\n\n" 866 + "Is this an older tool processing a perf.data " 867 + "file generated by a more recent tool?\n\n" 868 + "If that is not the case, consider " 869 + "reporting to linux-kernel@vger.kernel.org.\n\n", 870 + self->hists.stats.nr_unknown_events); 871 + } 872 + 855 873 return err; 856 874 } 857 875
+15 -1
tools/perf/util/ui/util.c
··· 104 104 return rc; 105 105 } 106 106 107 - static const char yes[] = "Yes", no[] = "No"; 107 + static const char yes[] = "Yes", no[] = "No", 108 + warning_str[] = "Warning!", ok[] = "Ok"; 108 109 109 110 bool ui__dialog_yesno(const char *msg) 110 111 { 111 112 /* newtWinChoice should really be accepting const char pointers... */ 112 113 return newtWinChoice(NULL, (char *)yes, (char *)no, (char *)msg) == 1; 114 + } 115 + 116 + void ui__warning(const char *format, ...) 117 + { 118 + va_list args; 119 + 120 + va_start(args, format); 121 + if (use_browser > 0) 122 + newtWinMessagev((char *)warning_str, (char *)ok, 123 + (char *)format, args); 124 + else 125 + vfprintf(stderr, format, args); 126 + va_end(args); 113 127 }