[PATCH] blkparse: Fix bad ordering due to non-global sequence
authorJens Axboe <axboe@suse.de>
Thu, 2 Feb 2006 12:47:51 +0000 (13:47 +0100)
committerJens Axboe <axboe@suse.de>
Thu, 2 Feb 2006 12:47:51 +0000 (13:47 +0100)
We need to let events simmer in the queue for at least one iteration
of all devices, to prevent bad outputs if one CPU has late events.

blkparse.c

index f051ee7e055e4d355b4f8baef69624cdf6eff9d4..ff7a6faeabfc5d8c05e30f53d2d015fadc72ec67 100644 (file)
@@ -194,6 +194,7 @@ struct trace {
        struct blk_io_trace *bit;
        struct rb_node rb_node;
        struct trace *next;
+       unsigned long read_sequence;
 };
 
 static struct rb_root rb_sort_root;
@@ -235,6 +236,7 @@ static unsigned long long genesis_time;
 static unsigned long long last_allowed_time;
 static unsigned long long stopwatch_start;     /* start from zero by default */
 static unsigned long long stopwatch_end = -1ULL;       /* "infinity" */
+static unsigned long read_sequence;
 
 static int per_process_stats;
 static int per_device_and_cpu_stats = 1;
@@ -1681,6 +1683,9 @@ static void show_entries_rb(int force)
                t = rb_entry(n, struct trace, rb_node);
                bit = t->bit;
 
+               if (read_sequence - t->read_sequence < 1 && !force)
+                       break;
+
                if (!pdi || pdi->dev != bit->device) {
                        pdi = get_dev_info(bit->device);
                        pci = NULL;
@@ -1813,6 +1818,7 @@ static int read_events(int fd, int always_block, int *fdblock)
                t = t_alloc();
                memset(t, 0, sizeof(*t));
                t->bit = bit;
+               t->read_sequence = read_sequence;
 
                t->next = trace_list;
                trace_list = t;
@@ -1890,6 +1896,7 @@ static int do_file(void)
 
                events_added = 0;
                last_allowed_time = -1ULL;
+               read_sequence++;
 
                for (i = 0; i < ndevices; i++) {
                        pdi = &devices[i];