Lines Matching refs:pdi
321 static void resize_cpu_info(struct per_dev_info *pdi, int cpu)
323 struct per_cpu_info *cpus = pdi->cpus;
324 int ncpus = pdi->ncpus;
334 get_dev_name(pdi, name, sizeof(name)), size);
342 pdi->ncpus = new_count;
343 pdi->cpus = cpus;
345 for (new_count = 0; new_count < pdi->ncpus; new_count++) {
346 struct per_cpu_info *pci = &pdi->cpus[new_count];
357 static struct per_cpu_info *get_cpu_info(struct per_dev_info *pdi, int cpu)
361 if (cpu >= pdi->ncpus)
362 resize_cpu_info(pdi, cpu);
364 pci = &pdi->cpus[cpu];
387 struct per_dev_info *pdi;
400 pdi = &devices[ndevices - 1];
401 pdi->dev = dev;
402 pdi->first_reported_time = 0;
403 pdi->last_read_time = 0;
405 return pdi;
482 static void collect_pdi_skips(struct per_dev_info *pdi)
487 pdi->skips = 0;
488 pdi->seq_skips = 0;
490 for (cpu = 0; cpu < pdi->ncpus; cpu++) {
491 struct per_cpu_info *pci = &pdi->cpus[cpu];
494 pdi->skips++;
495 pdi->seq_skips += (sip->end - sip->start + 1);
498 MAJOR(pdi->dev), MINOR(pdi->dev),
504 static void cpu_mark_online(struct per_dev_info *pdi, unsigned int cpu)
506 if (cpu >= pdi->cpu_map_max || !pdi->cpu_map) {
512 if (pdi->cpu_map) {
513 memcpy(map, pdi->cpu_map, pdi->cpu_map_max / sizeof(long));
514 free(pdi->cpu_map);
517 pdi->cpu_map = map;
518 pdi->cpu_map_max = new_max;
521 pdi->cpu_map[CPU_IDX(cpu)] |= (1UL << CPU_BIT(cpu));
524 static inline void cpu_mark_offline(struct per_dev_info *pdi, int cpu)
526 pdi->cpu_map[CPU_IDX(cpu)] &= ~(1UL << CPU_BIT(cpu));
529 static inline int cpu_is_online(struct per_dev_info *pdi, int cpu)
531 return (pdi->cpu_map[CPU_IDX(cpu)] & (1UL << CPU_BIT(cpu))) != 0;
778 static inline void __put_trace_last(struct per_dev_info *pdi, struct trace *t)
780 struct per_cpu_info *pci = get_cpu_info(pdi, t->bit->cpu);
789 static void put_trace(struct per_dev_info *pdi, struct trace *t)
794 trace_rb_insert_last(pdi, t);
837 static int trace_rb_insert_last(struct per_dev_info *pdi, struct trace *t)
839 struct per_cpu_info *pci = get_cpu_info(pdi, t->bit->cpu);
846 if (pci->rb_last_entries > rb_batch * pdi->nfiles) {
850 __put_trace_last(pdi, t);
903 static inline struct trace *trace_rb_find_last(struct per_dev_info *pdi,
907 return trace_rb_find(pdi->dev, seq, &pci->rb_last, 0);
910 static inline int track_rb_insert(struct per_dev_info *pdi,struct io_track *iot)
912 struct rb_node **p = &pdi->rb_track.rb_node;
928 MAJOR(pdi->dev), MINOR(pdi->dev));
934 rb_insert_color(&iot->rb_node, &pdi->rb_track);
938 static struct io_track *__find_track(struct per_dev_info *pdi, __u64 sector)
940 struct rb_node *n = pdi->rb_track.rb_node;
957 static struct io_track *find_track(struct per_dev_info *pdi, pid_t pid,
962 iot = __find_track(pdi, sector);
969 track_rb_insert(pdi, iot);
975 static void log_track_frontmerge(struct per_dev_info *pdi,
983 iot = __find_track(pdi, t->sector + t_sec(t));
987 MAJOR(pdi->dev), MINOR(pdi->dev),
992 rb_erase(&iot->rb_node, &pdi->rb_track);
994 track_rb_insert(pdi, iot);
997 static void log_track_getrq(struct per_dev_info *pdi, struct blk_io_trace *t)
1004 iot = find_track(pdi, t->pid, t->sector);
1008 static inline int is_remapper(struct per_dev_info *pdi)
1010 int major = MAJOR(pdi->dev);
1019 static void log_track_queue(struct per_dev_info *pdi, struct blk_io_trace *t)
1025 if (!is_remapper(pdi))
1028 iot = find_track(pdi, t->pid, t->sector);
1035 static unsigned long long log_track_insert(struct per_dev_info *pdi,
1044 iot = find_track(pdi, t->pid, t->sector);
1066 static unsigned long long log_track_issue(struct per_dev_info *pdi,
1077 iot = __find_track(pdi, t->sector);
1081 MAJOR(pdi->dev), MINOR(pdi->dev),
1103 static unsigned long long log_track_complete(struct per_dev_info *pdi,
1112 iot = __find_track(pdi, t->sector);
1116 MAJOR(pdi->dev), MINOR(pdi->dev),
1135 rb_erase(&iot->rb_node, &pdi->rb_track);
1159 static char *get_dev_name(struct per_dev_info *pdi, char *buffer, int size)
1161 if (pdi->name)
1162 snprintf(buffer, size, "%s", pdi->name);
1164 snprintf(buffer, size, "%d,%d",MAJOR(pdi->dev),MINOR(pdi->dev));
1168 static void check_time(struct per_dev_info *pdi, struct blk_io_trace *bit)
1171 unsigned long long last = pdi->last_reported_time;
1173 pdi->backwards = (this < last) ? 'B' : ' ';
1174 pdi->last_reported_time = this;
1408 static void log_complete(struct per_dev_info *pdi, struct per_cpu_info *pci,
1411 process_fmt(act, pci, t, log_track_complete(pdi, t), 0, NULL);
1414 static void log_insert(struct per_dev_info *pdi, struct per_cpu_info *pci,
1417 process_fmt(act, pci, t, log_track_insert(pdi, t), 0, NULL);
1426 static void log_issue(struct per_dev_info *pdi, struct per_cpu_info *pci,
1429 process_fmt(act, pci, t, log_track_issue(pdi, t), 0, NULL);
1432 static void log_merge(struct per_dev_info *pdi, struct per_cpu_info *pci,
1436 log_track_frontmerge(pdi, t);
1472 static void dump_trace_pc(struct blk_io_trace *t, struct per_dev_info *pdi,
1494 if (pdi->cur_depth[w])
1495 pdi->cur_depth[w]--;
1501 pdi->cur_depth[w]++;
1502 if (pdi->cur_depth[w] > pdi->max_depth[w])
1503 pdi->max_depth[w] = pdi->cur_depth[w];
1507 if (pdi->cur_depth[w])
1508 pdi->cur_depth[w]--;
1521 static void dump_trace_fs(struct blk_io_trace *t, struct per_dev_info *pdi,
1529 log_track_queue(pdi, t);
1534 log_insert(pdi, pci, t, "I");
1538 log_merge(pdi, pci, t, "M");
1542 log_merge(pdi, pci, t, "F");
1545 log_track_getrq(pdi, t);
1556 if (pdi->cur_depth[w])
1557 pdi->cur_depth[w]--;
1563 pdi->cur_depth[w]++;
1564 if (pdi->cur_depth[w] > pdi->max_depth[w])
1565 pdi->max_depth[w] = pdi->cur_depth[w];
1566 log_issue(pdi, pci, t, "D");
1569 if (pdi->cur_depth[w])
1570 pdi->cur_depth[w]--;
1572 log_complete(pdi, pci, t, "C");
1605 struct per_dev_info *pdi)
1611 dump_trace_pc(t, pdi, pci);
1613 dump_trace_fs(t, pdi, pci);
1616 if (!pdi->events)
1617 pdi->first_reported_time = t->time;
1619 pdi->events++;
1648 static void dump_io_stats(struct per_dev_info *pdi, struct io_stats *ios,
1665 if (pdi) {
1666 fprintf(ofp, " Read depth: %'8u%8c\t", pdi->max_depth[0], ' ');
1667 fprintf(ofp, " Write depth: %'8u\n", pdi->max_depth[1]);
1769 struct per_dev_info *pdi;
1778 for (pdi = devices, i = 0; i < ndevices; i++, pdi++) {
1786 for (pci = pdi->cpus, j = 0; j < pdi->ncpus; j++, pci++) {
1827 j, get_dev_name(pdi, name, sizeof(name)));
1828 dump_io_stats(pdi, ios, line);
1835 get_dev_name(pdi, name, sizeof(name)));
1840 msec = (pdi->last_reported_time - pdi->first_reported_time) / 1000000;
1849 get_dev_name(pdi, line, sizeof(line)), pdi->events);
1851 collect_pdi_skips(pdi);
1852 if (!pdi->skips && !pdi->events)
1855 ratio = 100.0 * ((double)pdi->seq_skips /
1856 (double)(pdi->events + pdi->seq_skips));
1858 pdi->skips, pdi->seq_skips, ratio);
1908 struct per_dev_info *pdi = NULL;
1926 if (!pdi || pdi->dev != bit->device) {
1927 pdi = get_dev_info(bit->device);
1932 pci = get_cpu_info(pdi, bit->cpu);
1953 static int check_cpu_map(struct per_dev_info *pdi)
1964 cpu_map = malloc(pdi->cpu_map_max / sizeof(long));
1975 * we can't continue if pdi->cpu_map has entries set that we don't
1979 for (i = 0; i < pdi->cpu_map_max / CPUS_PER_LONG; i++) {
1980 if (pdi->cpu_map[i] & ~(cpu_map[i])) {
1990 static int check_sequence(struct per_dev_info *pdi, struct trace *t, int force)
1997 pci = get_cpu_info(pdi, bit->cpu);
2009 return check_cpu_map(pdi);
2020 __t = trace_rb_find_last(pdi, pci, expected_sequence);
2024 __put_trace_last(pdi, __t);
2041 struct per_dev_info *pdi = NULL;
2057 if (!pdi || pdi->dev != bit->device) {
2058 pdi = get_dev_info(bit->device);
2062 if (!pdi) {
2068 if (check_sequence(pdi, t, force))
2074 check_time(pdi, bit);
2077 pci = get_cpu_info(pdi, bit->cpu);
2084 dump_trace(bit, pci, pdi);
2086 put_trace(pdi, t);
2156 struct per_dev_info *pdi = NULL;
2226 if (!pdi || pdi->dev != bit->device)
2227 pdi = get_dev_info(bit->device);
2229 if (bit->time > pdi->last_read_time)
2230 pdi->last_read_time = bit->time;
2245 struct per_dev_info *pdi;
2316 struct per_dev_info *pdi = msp->pdi;
2317 struct per_cpu_info *pci = get_cpu_info(pdi, msp->cpu);
2364 if (bit->time > pdi->last_read_time)
2365 pdi->last_read_time = bit->time;
2386 cpu_mark_offline(pdi, pci->cpu);
2393 static struct ms_stream *ms_alloc(struct per_dev_info *pdi, int cpu)
2399 msp->pdi = pdi;
2408 static int setup_file(struct per_dev_info *pdi, int cpu)
2413 struct per_cpu_info *pci = get_cpu_info(pdi, cpu);
2418 p = strdup(pdi->name);
2422 p = strdup(pdi->name);
2423 strcpy(pdi->name, basename(p));
2431 "%s.blktrace.%d", pdi->name, pci->cpu);
2444 cpu_mark_online(pdi, pci->cpu);
2446 pdi->nfiles++;
2447 ms_alloc(pdi, pci->cpu);
2455 struct per_dev_info *pdi;
2462 pdi = msp->pdi;
2463 pci = get_cpu_info(pdi, msp->cpu);
2470 pdi->last_reported_time = bit->time;
2473 dump_trace(bit, pci, pdi);
2478 trace_rb_insert_last(pdi, t);
2508 struct per_dev_info *pdi;
2514 pdi = &devices[i];
2515 ret = name_fixup(pdi->name);
2519 for (cpu = 0; setup_file(pdi, cpu); cpu++)