}
}
-static void find_genesis(void)
-{
- struct trace *t = trace_list;
-
- genesis_time = -1ULL;
- while (t != NULL) {
- if (t->bit->time < genesis_time)
- genesis_time = t->bit->time;
-
- t = t->next;
- }
-}
-
-static int sort_entries(void)
-{
- struct trace *t;
- int nr = 0;
-
- if (!genesis_time)
- find_genesis();
-
- while ((t = trace_list) != NULL) {
- trace_list = t->next;
-
- if (verify_trace(t->bit))
- continue;
-
- t->bit->time -= genesis_time;
-
- if (trace_rb_insert(t))
- break;
- nr++;
- }
-
- return nr;
-}
-
/*
* struct trace and blktrace allocation cache, we do potentially
* millions of mallocs for these structures while only using at most
return malloc(sizeof(*bit));
}
+static void find_genesis(void)
+{
+ struct trace *t = trace_list;
+
+ genesis_time = -1ULL;
+ while (t != NULL) {
+ if (t->bit->time < genesis_time)
+ genesis_time = t->bit->time;
+
+ t = t->next;
+ }
+}
+
+static inline int check_stopwatch(struct blk_io_trace *bit)
+{
+ if (bit->time < stopwatch_end &&
+ bit->time >= stopwatch_start)
+ return 0;
+
+ return 1;
+}
+
+static int sort_entries(void)
+{
+ struct trace *t;
+ int nr = 0;
+
+ if (!genesis_time)
+ find_genesis();
+
+ while ((t = trace_list) != NULL) {
+ struct blk_io_trace *bit = t->bit;
+
+ trace_list = t->next;
+
+ if (verify_trace(bit))
+ continue;
+
+ bit->time -= genesis_time;
+
+ if (check_stopwatch(bit)) {
+ bit_free(bit);
+ t_free(t);
+ continue;
+ }
+
+ if (trace_rb_insert(t))
+ break;
+
+ nr++;
+ }
+
+ return nr;
+}
+
static void show_entries_rb(int force)
{
struct per_dev_info *pdi = NULL;
}
ok:
- if (bit->time >= stopwatch_end)
- break;
-
if (!force && bit->time > last_allowed_time)
break;
pdi->last_sequence = bit->sequence;
- if (bit->time >= stopwatch_start) {
- check_time(pdi, bit);
+ check_time(pdi, bit);
- if (!pci || pci->cpu != bit->cpu)
- pci = get_cpu_info(pdi, bit->cpu);
+ if (!pci || pci->cpu != bit->cpu)
+ pci = get_cpu_info(pdi, bit->cpu);
- dump_trace(bit, pci, pdi);
- }
+ dump_trace(bit, pci, pdi);
rb_erase(&t->rb_node, &rb_sort_root);
rb_sort_entries--;
t->bit = bit;
trace_to_cpu(bit);
+
t->next = trace_list;
trace_list = t;