__u32 pid;
struct io_stats io_stats;
struct per_process_info *hash_next, *list_next;
+ int more_than_one;
/*
* individual io stats
if (ppi_hash_by_pid)
return ppi_hash_pid(ppi->pid);
- if (ppi->name[0] == 0)
- fprintf(stderr, "bad\n");
-
return ppi_hash_name(ppi->name);
}
static struct per_process_info *find_process(__u32 pid, char *name)
{
+ struct per_process_info *ppi;
+
if (ppi_hash_by_pid)
return find_process_by_pid(pid);
- return find_process_by_name(name);
+ ppi = find_process_by_name(name);
+ if (ppi && ppi->pid != pid)
+ ppi->more_than_one = 1;
+
+ return ppi;
}
static inline int trace_rb_insert(struct trace *t)
while (ppi) {
char name[64];
- if (ppi_hash_by_pid)
- sprintf(name, "%s (%u)", ppi->name, ppi->pid);
- else
+ if (ppi->more_than_one)
sprintf(name, "%s (%u, ...)", ppi->name, ppi->pid);
+ else
+ sprintf(name, "%s (%u)", ppi->name, ppi->pid);
dump_io_stats(&ppi->io_stats, name);
dump_wait_stats(ppi);
}
}
-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;
return 1;
break;
case 'n':
- ppi_hash_by_pid = 1;
+ ppi_hash_by_pid = 0;
break;
case 'v':
printf("%s version %s\n", argv[0], blkparse_version);