[PATCH] blktrace: add warning about increasing buffer size with dropped events
authorJens Axboe <axboe@suse.de>
Fri, 13 Jan 2006 14:28:01 +0000 (15:28 +0100)
committerJens Axboe <axboe@suse.de>
Fri, 13 Jan 2006 14:28:01 +0000 (15:28 +0100)
blktrace.c

index 3edfc67c9219aa1ba2b55178bc518081ee40c8e7..882c403c6f5165725921be83d9fb76ee32f0c8a0 100644 (file)
@@ -683,26 +683,34 @@ static int get_dropped_count(const char *buts_name)
 
 static void show_stats(void)
 {
-       int i, j, dropped;
+       int i, j, dropped, total_drops, no_stdout = 0;
        struct device_information *dip;
        struct thread_information *tip;
        unsigned long long events_processed;
 
        if (output_name && !strcmp(output_name, "-"))
-               return;
+               no_stdout = 1;
 
+       total_drops = 0;
        for_each_dip(dip, i) {
-               printf("Device: %s\n", dip->path);
+               if (!no_stdout)
+                       printf("Device: %s\n", dip->path);
                events_processed = 0;
                for_each_tip(dip, tip, j) {
-                       printf("  CPU%3d: %20ld events\n",
-                              tip->cpu, tip->events_processed);
+                       if (!no_stdout)
+                               printf("  CPU%3d: %20ld events\n",
+                                       tip->cpu, tip->events_processed);
                        events_processed += tip->events_processed;
                }
                dropped = get_dropped_count(dip->buts_name);
-               printf("  Total:  %20lld events (dropped %d)\n",
-                               events_processed, dropped);
+               total_drops += dropped;
+               if (!no_stdout)
+                       printf("  Total:  %20lld events (dropped %d)\n",
+                                       events_processed, dropped);
        }
+
+       if (total_drops)
+               fprintf(stderr, "You have dropped events, consider using a larger buffer size (-b)\n");
 }
 
 static char usage_str[] = \