int backwards;
unsigned long long events;
unsigned long long last_reported_time;
+ unsigned long long last_read_time;
struct io_stats io_stats;
unsigned long last_sequence;
unsigned long skips;
static char *output_name;
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 = ULONG_LONG_MAX; /* "infinity" */
struct rb_node *parent = NULL;
struct trace *__t;
- if (genesis_time == 0 || t->bit->time < genesis_time)
- genesis_time = t->bit->time;
-
while (*p) {
parent = *p;
__t = rb_entry(parent, struct trace, rb_node);
pdi = &devices[ndevices - 1];
pdi->id = id;
pdi->last_sequence = -1;
+ pdi->last_read_time = 0;
return pdi;
}
struct blk_io_trace *bit;
struct rb_node *n;
struct trace *t;
- __u32 device = 0;
- int cpu = 0;
while ((n = rb_first(&rb_sort_root)) != NULL) {
t = rb_entry(n, struct trace, rb_node);
bit = t->bit;
- if (!pdi || device != bit->device) {
- device = bit->device;
- pdi = get_dev_info(device);
- }
+ if (!pdi || pdi->id != bit->device)
+ pdi = get_dev_info(bit->device);
if (!pdi) {
fprintf(stderr, "Unknown device ID? (%d,%d)\n",
break;
}
- if (!pci || cpu != bit->cpu) {
- cpu = bit->cpu;
- pci = get_cpu_info(pdi, cpu);
- }
-
/*
* back off displaying more info if we are out of sync
* on SMP systems. to prevent stalling on lost events,
- * only allow an event to us a few times
+ * only allow an event to skip us a few times
*/
if (bit->sequence != (pdi->last_sequence + 1)
&& pdi->last_sequence != -1) {
pdi->last_sequence = bit->sequence;
- bit->time -= genesis_time;
- if (bit->time >= stopwatch_end)
+ if (bit->time >= stopwatch_end || bit->time > last_allowed_time)
break;
if (bit->time >= stopwatch_start) {
check_time(pdi, bit);
+ if (!pci || pci->cpu != bit->cpu)
+ pci = get_cpu_info(pdi, bit->cpu);
+
dump_trace(bit, pci, pdi);
}
return 0;
}
-static int read_sort_events(int fd)
+static int read_events(int fd)
{
+ struct per_dev_info *pdi = NULL;
int events = 0;
while (!is_done() && events < rb_batch) {
t->next = trace_list;
trace_list = t;
+ if (genesis_time == 0 || t->bit->time < genesis_time)
+ genesis_time = t->bit->time;
+
+ bit->time -= genesis_time;
+
+ if (!pdi || pdi->id != bit->device)
+ pdi = get_dev_info(bit->device);
+
+ if (bit->time > pdi->last_read_time)
+ pdi->last_read_time = bit->time;
+
events++;
}
*/
do {
events_added = 0;
+ last_allowed_time = -1ULL;
for (i = 0; i < ndevices; i++) {
pdi = &devices[i];
if (pci->fd == -1)
continue;
- events = read_sort_events(pci->fd);
+ events = read_events(pci->fd);
if (!events) {
close(pci->fd);
pci->fd = -1;
continue;
}
- if (sort_entries() == -1)
- continue;
+ if (pdi->last_read_time < last_allowed_time)
+ last_allowed_time = pdi->last_read_time;
events_added += events;
}
}
+ if (sort_entries() == -1)
+ break;
+
show_entries_rb();
} while (events_added);
do {
int events;
- events = read_sort_events(fd);
+ events = read_events(fd);
if (!events)
break;