[PATCH] Add option to limit rb batching for live traces
authorJens Axboe <axboe@suse.de>
Tue, 6 Sep 2005 07:09:52 +0000 (09:09 +0200)
committerJens Axboe <axboe@suse.de>
Tue, 6 Sep 2005 07:09:52 +0000 (09:09 +0200)
Right now, blkparse keeps going until there's a delay in events read.
Add an option to cap the number of pending entries (-b) and default to
1024 events.

blkparse.c

index 38d91d17baaa6a4390f67f5efec712441c428b8d..e43f89beb6dcf9b1fa32daecf7a2e2d9eb89785f 100644 (file)
@@ -54,7 +54,7 @@ struct per_cpu_info {
        unsigned long long iread_kb, iwrite_kb;
 };
 
-#define S_OPTS "i:o:"
+#define S_OPTS "i:o:b:"
 static struct option l_opts[] = {
        {
                .name = "input",
@@ -68,6 +68,12 @@ static struct option l_opts[] = {
                .flag = NULL,
                .val = 'o'
        },
+       {
+               .name = "batch",
+               .has_arg = 1,
+               .flag = NULL,
+               .val = 'b'
+       },
        {
                .name = NULL,
                .has_arg = 0,
@@ -90,6 +96,9 @@ static unsigned long long events;
 
 static char *dev, *output_name;
 
+#define RB_BATCH_DEFAULT       (1024)
+static int rb_batch = RB_BATCH_DEFAULT;
+
 #define is_done()      (*(volatile int *)(&done))
 static volatile int done;
 
@@ -671,7 +680,7 @@ static int read_sort_events(int fd, void **buffer)
 
                offset += pdu_len;
                events++;
-       } while (!is_done());
+       } while (!is_done() && events < rb_batch);
 
        return events;
 }
@@ -737,6 +746,11 @@ int main(int argc, char *argv[])
                case 'o':
                        output_name = strdup(optarg);
                        break;
+               case 'b':
+                       rb_batch = atoi(optarg);
+                       if (rb_batch <= 0)
+                               rb_batch = RB_BATCH_DEFAULT;
+                       break;
                default:
                        usage(argv[0]);
                        return 1;