Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | #include <sys/time.h> |
| 4 | #include <sys/types.h> |
Jens Axboe | 5c4e1db | 2006-06-07 14:17:08 +0200 | [diff] [blame] | 5 | #include <sys/stat.h> |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 6 | #include <dirent.h> |
| 7 | #include <libgen.h> |
| 8 | #include <math.h> |
| 9 | |
| 10 | #include "fio.h" |
Jens Axboe | 7c9b1bc | 2009-06-03 09:25:57 +0200 | [diff] [blame] | 11 | #include "diskutil.h" |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 12 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 13 | void update_rusage_stat(struct thread_data *td) |
| 14 | { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 15 | struct thread_stat *ts = &td->ts; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 16 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 17 | getrusage(RUSAGE_SELF, &ts->ru_end); |
| 18 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 19 | ts->usr_time += mtime_since(&ts->ru_start.ru_utime, |
| 20 | &ts->ru_end.ru_utime); |
| 21 | ts->sys_time += mtime_since(&ts->ru_start.ru_stime, |
| 22 | &ts->ru_end.ru_stime); |
| 23 | ts->ctx += ts->ru_end.ru_nvcsw + ts->ru_end.ru_nivcsw |
| 24 | - (ts->ru_start.ru_nvcsw + ts->ru_start.ru_nivcsw); |
Jens Axboe | e7823a9 | 2007-09-07 20:33:33 +0200 | [diff] [blame] | 25 | ts->minf += ts->ru_end.ru_minflt - ts->ru_start.ru_minflt; |
| 26 | ts->majf += ts->ru_end.ru_majflt - ts->ru_start.ru_majflt; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 27 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 28 | memcpy(&ts->ru_start, &ts->ru_end, sizeof(ts->ru_end)); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | static int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, |
| 32 | double *mean, double *dev) |
| 33 | { |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 34 | double n = is->samples; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 35 | |
| 36 | if (is->samples == 0) |
| 37 | return 0; |
| 38 | |
| 39 | *min = is->min_val; |
| 40 | *max = is->max_val; |
| 41 | |
| 42 | n = (double) is->samples; |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 43 | *mean = is->mean; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 44 | |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 45 | if (n > 1.0) |
| 46 | *dev = sqrt(is->S / (n - 1.0)); |
Jens Axboe | ef9c5c4 | 2007-01-03 14:21:13 +0100 | [diff] [blame] | 47 | else |
Jens Axboe | 4b43f54 | 2007-07-19 21:38:35 +0200 | [diff] [blame] | 48 | *dev = 0; |
Jens Axboe | ef9c5c4 | 2007-01-03 14:21:13 +0100 | [diff] [blame] | 49 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 50 | return 1; |
| 51 | } |
| 52 | |
| 53 | static void show_group_stats(struct group_run_stats *rs, int id) |
| 54 | { |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 55 | char *p1, *p2, *p3, *p4; |
| 56 | const char *ddir_str[] = { " READ", " WRITE" }; |
| 57 | int i; |
| 58 | |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 59 | log_info("\nRun status group %d (all jobs):\n", id); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 60 | |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 61 | for (i = 0; i <= DDIR_WRITE; i++) { |
| 62 | if (!rs->max_run[i]) |
| 63 | continue; |
| 64 | |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 65 | p1 = num2str(rs->io_kb[i], 6, 1024, 1); |
| 66 | p2 = num2str(rs->agg[i], 6, 1024, 1); |
| 67 | p3 = num2str(rs->min_bw[i], 6, 1024, 1); |
| 68 | p4 = num2str(rs->max_bw[i], 6, 1024, 1); |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 69 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 70 | log_info("%s: io=%siB, aggrb=%siB/s, minb=%siB/s, maxb=%siB/s," |
| 71 | " mint=%llumsec, maxt=%llumsec\n", ddir_str[i], p1, p2, |
| 72 | p3, p4, rs->min_run[i], |
| 73 | rs->max_run[i]); |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 74 | |
| 75 | free(p1); |
| 76 | free(p2); |
| 77 | free(p3); |
| 78 | free(p4); |
| 79 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 80 | } |
| 81 | |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 82 | #define ts_total_io_u(ts) \ |
| 83 | ((ts)->total_io_u[0] + (ts)->total_io_u[1]) |
| 84 | |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 85 | static void stat_calc_dist(unsigned int *map, unsigned long total, |
| 86 | double *io_u_dist) |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 87 | { |
| 88 | int i; |
| 89 | |
| 90 | /* |
| 91 | * Do depth distribution calculations |
| 92 | */ |
| 93 | for (i = 0; i < FIO_IO_U_MAP_NR; i++) { |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 94 | if (total) { |
| 95 | io_u_dist[i] = (double) map[i] / (double) total; |
| 96 | io_u_dist[i] *= 100.0; |
| 97 | if (io_u_dist[i] < 0.1 && map[i]) |
| 98 | io_u_dist[i] = 0.1; |
| 99 | } else |
| 100 | io_u_dist[i] = 0.0; |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 101 | } |
| 102 | } |
| 103 | |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 104 | static void stat_calc_lat(struct thread_stat *ts, double *dst, |
| 105 | unsigned int *src, int nr) |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 106 | { |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 107 | unsigned long total = ts_total_io_u(ts); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 108 | int i; |
| 109 | |
| 110 | /* |
| 111 | * Do latency distribution calculations |
| 112 | */ |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 113 | for (i = 0; i < nr; i++) { |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 114 | if (total) { |
| 115 | dst[i] = (double) src[i] / (double) total; |
| 116 | dst[i] *= 100.0; |
| 117 | if (dst[i] < 0.01 && src[i]) |
| 118 | dst[i] = 0.01; |
| 119 | } else |
| 120 | dst[i] = 0.0; |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 124 | static void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat) |
| 125 | { |
| 126 | stat_calc_lat(ts, io_u_lat, ts->io_u_lat_u, FIO_IO_U_LAT_U_NR); |
| 127 | } |
| 128 | |
| 129 | static void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat) |
| 130 | { |
| 131 | stat_calc_lat(ts, io_u_lat, ts->io_u_lat_m, FIO_IO_U_LAT_M_NR); |
| 132 | } |
| 133 | |
Jens Axboe | ea2accc | 2007-06-19 09:48:44 +0200 | [diff] [blame] | 134 | static int usec_to_msec(unsigned long *min, unsigned long *max, double *mean, |
| 135 | double *dev) |
| 136 | { |
| 137 | if (*min > 1000 && *max > 1000 && *mean > 1000.0 && *dev > 1000.0) { |
| 138 | *min /= 1000; |
| 139 | *max /= 1000; |
| 140 | *mean /= 1000.0; |
| 141 | *dev /= 1000.0; |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | return 1; |
| 146 | } |
| 147 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 148 | static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts, |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 149 | int ddir) |
| 150 | { |
Jens Axboe | 3c9b60c | 2006-11-07 08:36:14 +0100 | [diff] [blame] | 151 | const char *ddir_str[] = { "read ", "write" }; |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 152 | unsigned long min, max, runt; |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 153 | unsigned long long bw, iops; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 154 | double mean, dev; |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 155 | char *io_p, *bw_p, *iops_p; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 156 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 157 | if (!ts->runtime[ddir]) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 158 | return; |
| 159 | |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 160 | runt = ts->runtime[ddir]; |
| 161 | |
| 162 | bw = (1000 * ts->io_bytes[ddir]) / runt; |
| 163 | io_p = num2str(ts->io_bytes[ddir] >> 10, 6, 1024, 1); |
| 164 | bw_p = num2str(bw >> 10, 6, 1024, 1); |
| 165 | |
| 166 | iops = (1000 * ts->total_io_u[ddir]) / runt; |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 167 | iops_p = num2str(iops, 6, 1, 0); |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 168 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 169 | log_info(" %s: io=%siB, bw=%siB/s, iops=%s, runt=%6lumsec\n", |
| 170 | ddir_str[ddir], io_p, bw_p, iops_p, |
| 171 | ts->runtime[ddir]); |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 172 | |
| 173 | free(io_p); |
| 174 | free(bw_p); |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 175 | free(iops_p); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 176 | |
Jens Axboe | d85f511 | 2007-06-18 09:41:23 +0200 | [diff] [blame] | 177 | if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) { |
| 178 | const char *base = "(usec)"; |
Jens Axboe | d9309cb | 2007-08-16 13:07:46 +0200 | [diff] [blame] | 179 | char *minp, *maxp; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 180 | |
Jens Axboe | ea2accc | 2007-06-19 09:48:44 +0200 | [diff] [blame] | 181 | if (!usec_to_msec(&min, &max, &mean, &dev)) |
Jens Axboe | d85f511 | 2007-06-18 09:41:23 +0200 | [diff] [blame] | 182 | base = "(msec)"; |
Jens Axboe | ea2accc | 2007-06-19 09:48:44 +0200 | [diff] [blame] | 183 | |
Jens Axboe | d9309cb | 2007-08-16 13:07:46 +0200 | [diff] [blame] | 184 | minp = num2str(min, 6, 1, 0); |
| 185 | maxp = num2str(max, 6, 1, 0); |
| 186 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 187 | log_info(" slat %s: min=%s, max=%s, avg=%5.02f," |
| 188 | " stdev=%5.02f\n", base, minp, maxp, mean, dev); |
Jens Axboe | d9309cb | 2007-08-16 13:07:46 +0200 | [diff] [blame] | 189 | |
| 190 | free(minp); |
| 191 | free(maxp); |
Jens Axboe | d85f511 | 2007-06-18 09:41:23 +0200 | [diff] [blame] | 192 | } |
| 193 | if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) { |
| 194 | const char *base = "(usec)"; |
Jens Axboe | d9309cb | 2007-08-16 13:07:46 +0200 | [diff] [blame] | 195 | char *minp, *maxp; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 196 | |
Jens Axboe | ea2accc | 2007-06-19 09:48:44 +0200 | [diff] [blame] | 197 | if (!usec_to_msec(&min, &max, &mean, &dev)) |
| 198 | base = "(msec)"; |
| 199 | |
Jens Axboe | d9309cb | 2007-08-16 13:07:46 +0200 | [diff] [blame] | 200 | minp = num2str(min, 6, 1, 0); |
| 201 | maxp = num2str(max, 6, 1, 0); |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 202 | |
| 203 | log_info(" clat %s: min=%s, max=%s, avg=%5.02f," |
| 204 | " stdev=%5.02f\n", base, minp, maxp, mean, dev); |
Jens Axboe | d9309cb | 2007-08-16 13:07:46 +0200 | [diff] [blame] | 205 | |
| 206 | free(minp); |
| 207 | free(maxp); |
Jens Axboe | d85f511 | 2007-06-18 09:41:23 +0200 | [diff] [blame] | 208 | } |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 209 | if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 210 | double p_of_agg; |
| 211 | |
| 212 | p_of_agg = mean * 100 / (double) rs->agg[ddir]; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 213 | log_info(" bw (KiB/s) : min=%5lu, max=%5lu, per=%3.2f%%," |
| 214 | " avg=%5.02f, stdev=%5.02f\n", min, max, p_of_agg, |
| 215 | mean, dev); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 219 | static void show_lat(double *io_u_lat, int nr, const char **ranges, |
| 220 | const char *msg) |
| 221 | { |
| 222 | int new_line = 1, i, line = 0; |
| 223 | |
| 224 | for (i = 0; i < nr; i++) { |
| 225 | if (io_u_lat[i] <= 0.0) |
| 226 | continue; |
| 227 | if (new_line) { |
Jens Axboe | 4539ed7 | 2007-07-23 14:21:17 +0200 | [diff] [blame] | 228 | if (line) |
| 229 | log_info("\n"); |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 230 | log_info(" lat (%s): ", msg); |
| 231 | new_line = 0; |
| 232 | line = 0; |
| 233 | } |
| 234 | if (line) |
| 235 | log_info(", "); |
| 236 | log_info("%s%3.2f%%", ranges[i], io_u_lat[i]); |
| 237 | line++; |
| 238 | if (line == 5) |
| 239 | new_line = 1; |
| 240 | } |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | static void show_lat_u(double *io_u_lat_u) |
| 244 | { |
| 245 | const char *ranges[] = { "2=", "4=", "10=", "20=", "50=", "100=", |
| 246 | "250=", "500=", "750=", "1000=", }; |
| 247 | |
| 248 | show_lat(io_u_lat_u, FIO_IO_U_LAT_U_NR, ranges, "usec"); |
| 249 | } |
| 250 | |
| 251 | static void show_lat_m(double *io_u_lat_m) |
| 252 | { |
| 253 | const char *ranges[] = { "2=", "4=", "10=", "20=", "50=", "100=", |
| 254 | "250=", "500=", "750=", "1000=", "2000=", |
| 255 | ">=2000=", }; |
| 256 | |
| 257 | show_lat(io_u_lat_m, FIO_IO_U_LAT_M_NR, ranges, "msec"); |
| 258 | } |
| 259 | |
| 260 | static void show_latencies(double *io_u_lat_u, double *io_u_lat_m) |
| 261 | { |
| 262 | show_lat_u(io_u_lat_u); |
Jens Axboe | 4539ed7 | 2007-07-23 14:21:17 +0200 | [diff] [blame] | 263 | log_info("\n"); |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 264 | show_lat_m(io_u_lat_m); |
| 265 | log_info("\n"); |
| 266 | } |
| 267 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 268 | static void show_thread_status(struct thread_stat *ts, |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 269 | struct group_run_stats *rs) |
| 270 | { |
| 271 | double usr_cpu, sys_cpu; |
Jens Axboe | 6900899 | 2006-11-24 13:12:56 +0100 | [diff] [blame] | 272 | unsigned long runtime; |
Jens Axboe | 71619dc | 2007-01-13 23:56:33 +0100 | [diff] [blame] | 273 | double io_u_dist[FIO_IO_U_MAP_NR]; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 274 | double io_u_lat_u[FIO_IO_U_LAT_U_NR]; |
| 275 | double io_u_lat_m[FIO_IO_U_LAT_M_NR]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 276 | |
Jens Axboe | b4c5e1a | 2007-10-25 18:44:45 +0200 | [diff] [blame] | 277 | if (!(ts->io_bytes[0] + ts->io_bytes[1]) && |
| 278 | !(ts->total_io_u[0] + ts->total_io_u[1])) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 279 | return; |
| 280 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 281 | if (!ts->error) { |
| 282 | log_info("%s: (groupid=%d, jobs=%d): err=%2d: pid=%d\n", |
| 283 | ts->name, ts->groupid, ts->members, |
Jens Axboe | 5921e80 | 2008-05-30 15:02:38 +0200 | [diff] [blame] | 284 | ts->error, (int) ts->pid); |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 285 | } else { |
| 286 | log_info("%s: (groupid=%d, jobs=%d): err=%2d (%s): pid=%d\n", |
| 287 | ts->name, ts->groupid, ts->members, |
Jens Axboe | 5921e80 | 2008-05-30 15:02:38 +0200 | [diff] [blame] | 288 | ts->error, ts->verror, (int) ts->pid); |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 289 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 290 | |
Jens Axboe | 7bdce1b | 2007-03-06 20:01:13 +0100 | [diff] [blame] | 291 | if (ts->description) |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 292 | log_info(" Description : [%s]\n", ts->description); |
Jens Axboe | 7bdce1b | 2007-03-06 20:01:13 +0100 | [diff] [blame] | 293 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 294 | if (ts->io_bytes[DDIR_READ]) |
| 295 | show_ddir_status(rs, ts, DDIR_READ); |
| 296 | if (ts->io_bytes[DDIR_WRITE]) |
| 297 | show_ddir_status(rs, ts, DDIR_WRITE); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 298 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 299 | runtime = ts->total_run_time; |
Jens Axboe | 6900899 | 2006-11-24 13:12:56 +0100 | [diff] [blame] | 300 | if (runtime) { |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 301 | double runt = (double) runtime; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 302 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 303 | usr_cpu = (double) ts->usr_time * 100 / runt; |
| 304 | sys_cpu = (double) ts->sys_time * 100 / runt; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 305 | } else { |
| 306 | usr_cpu = 0; |
| 307 | sys_cpu = 0; |
| 308 | } |
| 309 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 310 | log_info(" cpu : usr=%3.2f%%, sys=%3.2f%%, ctx=%lu, majf=%lu," |
| 311 | " minf=%lu\n", usr_cpu, sys_cpu, ts->ctx, ts->majf, ts->minf); |
Jens Axboe | 71619dc | 2007-01-13 23:56:33 +0100 | [diff] [blame] | 312 | |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 313 | stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist); |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 314 | log_info(" IO depths : 1=%3.1f%%, 2=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%," |
| 315 | " 16=%3.1f%%, 32=%3.1f%%, >=64=%3.1f%%\n", io_u_dist[0], |
| 316 | io_u_dist[1], io_u_dist[2], |
| 317 | io_u_dist[3], io_u_dist[4], |
| 318 | io_u_dist[5], io_u_dist[6]); |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 319 | |
| 320 | stat_calc_dist(ts->io_u_submit, ts->total_submit, io_u_dist); |
| 321 | log_info(" submit : 0=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%, 16=%3.1f%%," |
| 322 | " 32=%3.1f%%, 64=%3.1f%%, >=64=%3.1f%%\n", io_u_dist[0], |
| 323 | io_u_dist[1], io_u_dist[2], |
| 324 | io_u_dist[3], io_u_dist[4], |
| 325 | io_u_dist[5], io_u_dist[6]); |
| 326 | stat_calc_dist(ts->io_u_complete, ts->total_complete, io_u_dist); |
| 327 | log_info(" complete : 0=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%, 16=%3.1f%%," |
| 328 | " 32=%3.1f%%, 64=%3.1f%%, >=64=%3.1f%%\n", io_u_dist[0], |
| 329 | io_u_dist[1], io_u_dist[2], |
| 330 | io_u_dist[3], io_u_dist[4], |
| 331 | io_u_dist[5], io_u_dist[6]); |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 332 | log_info(" issued r/w: total=%lu/%lu, short=%lu/%lu\n", |
| 333 | ts->total_io_u[0], ts->total_io_u[1], |
| 334 | ts->short_io_u[0], ts->short_io_u[1]); |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 335 | stat_calc_lat_u(ts, io_u_lat_u); |
| 336 | stat_calc_lat_m(ts, io_u_lat_m); |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 337 | show_latencies(io_u_lat_u, io_u_lat_m); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 338 | } |
| 339 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 340 | static void show_ddir_status_terse(struct thread_stat *ts, |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 341 | struct group_run_stats *rs, int ddir) |
| 342 | { |
| 343 | unsigned long min, max; |
| 344 | unsigned long long bw; |
| 345 | double mean, dev; |
| 346 | |
| 347 | bw = 0; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 348 | if (ts->runtime[ddir]) |
| 349 | bw = ts->io_bytes[ddir] / ts->runtime[ddir]; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 350 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 351 | log_info(";%llu;%llu;%lu", ts->io_bytes[ddir] >> 10, bw, |
| 352 | ts->runtime[ddir]); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 353 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 354 | if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 355 | log_info(";%lu;%lu;%f;%f", min, max, mean, dev); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 356 | else |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 357 | log_info(";%lu;%lu;%f;%f", 0UL, 0UL, 0.0, 0.0); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 358 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 359 | if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 360 | log_info(";%lu;%lu;%f;%f", min, max, mean, dev); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 361 | else |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 362 | log_info(";%lu;%lu;%f;%f", 0UL, 0UL, 0.0, 0.0); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 363 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 364 | if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 365 | double p_of_agg; |
| 366 | |
| 367 | p_of_agg = mean * 100 / (double) rs->agg[ddir]; |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 368 | log_info(";%lu;%lu;%f%%;%f;%f", min, max, p_of_agg, mean, dev); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 369 | } else |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 370 | log_info(";%lu;%lu;%f%%;%f;%f", 0UL, 0UL, 0.0, 0.0, 0.0); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 374 | static void show_thread_status_terse(struct thread_stat *ts, |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 375 | struct group_run_stats *rs) |
| 376 | { |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 377 | double io_u_dist[FIO_IO_U_MAP_NR]; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 378 | double io_u_lat_u[FIO_IO_U_LAT_U_NR]; |
| 379 | double io_u_lat_m[FIO_IO_U_LAT_M_NR]; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 380 | double usr_cpu, sys_cpu; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 381 | int i; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 382 | |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 383 | log_info("%s;%d;%d", ts->name, ts->groupid, ts->error); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 384 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 385 | show_ddir_status_terse(ts, rs, 0); |
| 386 | show_ddir_status_terse(ts, rs, 1); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 387 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 388 | if (ts->total_run_time) { |
| 389 | double runt = (double) ts->total_run_time; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 390 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 391 | usr_cpu = (double) ts->usr_time * 100 / runt; |
| 392 | sys_cpu = (double) ts->sys_time * 100 / runt; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 393 | } else { |
| 394 | usr_cpu = 0; |
| 395 | sys_cpu = 0; |
| 396 | } |
| 397 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 398 | log_info(";%f%%;%f%%;%lu;%lu;%lu", usr_cpu, sys_cpu, ts->ctx, ts->majf, |
| 399 | ts->minf); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 400 | |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 401 | stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist); |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 402 | stat_calc_lat_u(ts, io_u_lat_u); |
| 403 | stat_calc_lat_m(ts, io_u_lat_m); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 404 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 405 | log_info(";%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%", |
| 406 | io_u_dist[0], io_u_dist[1], io_u_dist[2], io_u_dist[3], |
| 407 | io_u_dist[4], io_u_dist[5], io_u_dist[6]); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 408 | |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 409 | for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) |
| 410 | log_info(";%3.2f%%", io_u_lat_u[i]); |
| 411 | for (i = 0; i < FIO_IO_U_LAT_M_NR; i++) |
| 412 | log_info(";%3.2f%%", io_u_lat_m[i]); |
| 413 | log_info("\n"); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 414 | |
| 415 | if (ts->description) |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 416 | log_info(";%s", ts->description); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 417 | |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 418 | log_info("\n"); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 419 | } |
| 420 | |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 421 | static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr) |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 422 | { |
| 423 | double mean, S; |
| 424 | |
| 425 | dst->min_val = min(dst->min_val, src->min_val); |
| 426 | dst->max_val = max(dst->max_val, src->max_val); |
| 427 | dst->samples += src->samples; |
| 428 | |
| 429 | /* |
| 430 | * Needs a new method for calculating stddev, we cannot just |
| 431 | * average them we do below for nr > 1 |
| 432 | */ |
| 433 | if (nr == 1) { |
| 434 | mean = src->mean; |
| 435 | S = src->S; |
| 436 | } else { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 437 | mean = ((src->mean * (double) (nr - 1)) |
| 438 | + dst->mean) / ((double) nr); |
Jens Axboe | c39cced | 2007-03-06 15:37:00 +0100 | [diff] [blame] | 439 | S = ((src->S * (double) (nr - 1)) + dst->S) / ((double) nr); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | dst->mean = mean; |
| 443 | dst->S = S; |
| 444 | } |
| 445 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 446 | void show_run_stats(void) |
| 447 | { |
| 448 | struct group_run_stats *runstats, *rs; |
| 449 | struct thread_data *td; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 450 | struct thread_stat *threadstats, *ts; |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 451 | int i, j, k, l, nr_ts, last_ts, idx; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 452 | |
| 453 | runstats = malloc(sizeof(struct group_run_stats) * (groupid + 1)); |
| 454 | |
| 455 | for (i = 0; i < groupid + 1; i++) { |
| 456 | rs = &runstats[i]; |
| 457 | |
| 458 | memset(rs, 0, sizeof(*rs)); |
| 459 | rs->min_bw[0] = rs->min_run[0] = ~0UL; |
| 460 | rs->min_bw[1] = rs->min_run[1] = ~0UL; |
| 461 | } |
| 462 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 463 | /* |
| 464 | * find out how many threads stats we need. if group reporting isn't |
| 465 | * enabled, it's one-per-td. |
| 466 | */ |
| 467 | nr_ts = 0; |
| 468 | last_ts = -1; |
Jens Axboe | 34572e2 | 2006-10-20 09:33:18 +0200 | [diff] [blame] | 469 | for_each_td(td, i) { |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 470 | if (!td->o.group_reporting) { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 471 | nr_ts++; |
| 472 | continue; |
| 473 | } |
| 474 | if (last_ts == td->groupid) |
| 475 | continue; |
| 476 | |
| 477 | last_ts = td->groupid; |
| 478 | nr_ts++; |
| 479 | } |
| 480 | |
| 481 | threadstats = malloc(nr_ts * sizeof(struct thread_stat)); |
| 482 | |
| 483 | for (i = 0; i < nr_ts; i++) { |
| 484 | ts = &threadstats[i]; |
| 485 | |
| 486 | memset(ts, 0, sizeof(*ts)); |
Jens Axboe | de64df0 | 2007-03-08 19:09:49 +0100 | [diff] [blame] | 487 | for (j = 0; j <= DDIR_WRITE; j++) { |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 488 | ts->clat_stat[j].min_val = -1UL; |
| 489 | ts->slat_stat[j].min_val = -1UL; |
| 490 | ts->bw_stat[j].min_val = -1UL; |
| 491 | } |
Jens Axboe | 7abd0e3 | 2007-03-12 15:24:43 +0100 | [diff] [blame] | 492 | ts->groupid = -1; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | j = 0; |
| 496 | last_ts = -1; |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 497 | idx = 0; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 498 | for_each_td(td, i) { |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 499 | if (idx && (!td->o.group_reporting || |
| 500 | (td->o.group_reporting && last_ts != td->groupid))) { |
Jens Axboe | 7abd0e3 | 2007-03-12 15:24:43 +0100 | [diff] [blame] | 501 | idx = 0; |
| 502 | j++; |
| 503 | } |
| 504 | |
| 505 | last_ts = td->groupid; |
| 506 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 507 | ts = &threadstats[j]; |
| 508 | |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 509 | idx++; |
Jens Axboe | 6586ee8 | 2007-03-06 19:46:09 +0100 | [diff] [blame] | 510 | ts->members++; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 511 | |
Jens Axboe | 7abd0e3 | 2007-03-12 15:24:43 +0100 | [diff] [blame] | 512 | if (ts->groupid == -1) { |
Jens Axboe | 2dc84ba | 2007-03-06 15:46:33 +0100 | [diff] [blame] | 513 | /* |
| 514 | * These are per-group shared already |
| 515 | */ |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 516 | ts->name = td->o.name; |
| 517 | ts->description = td->o.description; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 518 | ts->groupid = td->groupid; |
Jens Axboe | 2dc84ba | 2007-03-06 15:46:33 +0100 | [diff] [blame] | 519 | |
| 520 | /* |
| 521 | * first pid in group, not very useful... |
| 522 | */ |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 523 | ts->pid = td->pid; |
Jens Axboe | 2dc84ba | 2007-03-06 15:46:33 +0100 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | if (td->error && !ts->error) { |
| 527 | ts->error = td->error; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 528 | ts->verror = td->verror; |
| 529 | } |
| 530 | |
Jens Axboe | de64df0 | 2007-03-08 19:09:49 +0100 | [diff] [blame] | 531 | for (l = 0; l <= DDIR_WRITE; l++) { |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 532 | sum_stat(&ts->clat_stat[l], &td->ts.clat_stat[l], idx); |
| 533 | sum_stat(&ts->slat_stat[l], &td->ts.slat_stat[l], idx); |
| 534 | sum_stat(&ts->bw_stat[l], &td->ts.bw_stat[l], idx); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 535 | |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 536 | ts->stat_io_bytes[l] += td->ts.stat_io_bytes[l]; |
| 537 | ts->io_bytes[l] += td->ts.io_bytes[l]; |
| 538 | |
| 539 | if (ts->runtime[l] < td->ts.runtime[l]) |
| 540 | ts->runtime[l] = td->ts.runtime[l]; |
| 541 | } |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 542 | |
| 543 | ts->usr_time += td->ts.usr_time; |
| 544 | ts->sys_time += td->ts.sys_time; |
| 545 | ts->ctx += td->ts.ctx; |
Jens Axboe | e7823a9 | 2007-09-07 20:33:33 +0200 | [diff] [blame] | 546 | ts->majf += td->ts.majf; |
| 547 | ts->minf += td->ts.minf; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 548 | |
| 549 | for (k = 0; k < FIO_IO_U_MAP_NR; k++) |
| 550 | ts->io_u_map[k] += td->ts.io_u_map[k]; |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 551 | for (k = 0; k < FIO_IO_U_MAP_NR; k++) |
| 552 | ts->io_u_submit[k] += td->ts.io_u_submit[k]; |
| 553 | for (k = 0; k < FIO_IO_U_MAP_NR; k++) |
| 554 | ts->io_u_complete[k] += td->ts.io_u_complete[k]; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 555 | for (k = 0; k < FIO_IO_U_LAT_U_NR; k++) |
| 556 | ts->io_u_lat_u[k] += td->ts.io_u_lat_u[k]; |
| 557 | for (k = 0; k < FIO_IO_U_LAT_M_NR; k++) |
| 558 | ts->io_u_lat_m[k] += td->ts.io_u_lat_m[k]; |
| 559 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 560 | |
Jens Axboe | 30061b9 | 2007-04-17 13:31:34 +0200 | [diff] [blame] | 561 | for (k = 0; k <= DDIR_WRITE; k++) { |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 562 | ts->total_io_u[k] += td->ts.total_io_u[k]; |
Jens Axboe | 30061b9 | 2007-04-17 13:31:34 +0200 | [diff] [blame] | 563 | ts->short_io_u[k] += td->ts.short_io_u[k]; |
| 564 | } |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 565 | |
| 566 | ts->total_run_time += td->ts.total_run_time; |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 567 | ts->total_submit += td->ts.total_submit; |
| 568 | ts->total_complete += td->ts.total_complete; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | for (i = 0; i < nr_ts; i++) { |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 572 | unsigned long long bw; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 573 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 574 | ts = &threadstats[i]; |
| 575 | rs = &runstats[ts->groupid]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 576 | |
Jens Axboe | de64df0 | 2007-03-08 19:09:49 +0100 | [diff] [blame] | 577 | for (j = 0; j <= DDIR_WRITE; j++) { |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 578 | if (!ts->runtime[j]) |
| 579 | continue; |
| 580 | if (ts->runtime[j] < rs->min_run[j] || !rs->min_run[j]) |
| 581 | rs->min_run[j] = ts->runtime[j]; |
| 582 | if (ts->runtime[j] > rs->max_run[j]) |
| 583 | rs->max_run[j] = ts->runtime[j]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 584 | |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 585 | bw = 0; |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 586 | if (ts->runtime[j]) { |
| 587 | unsigned long runt; |
| 588 | |
| 589 | runt = ts->runtime[j] * 1024 / 1000; |
| 590 | bw = ts->io_bytes[j] / runt; |
| 591 | } |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 592 | if (bw < rs->min_bw[j]) |
| 593 | rs->min_bw[j] = bw; |
| 594 | if (bw > rs->max_bw[j]) |
| 595 | rs->max_bw[j] = bw; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 596 | |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 597 | rs->io_kb[j] += ts->io_bytes[j] >> 10; |
| 598 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | for (i = 0; i < groupid + 1; i++) { |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 602 | unsigned long max_run[2]; |
| 603 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 604 | rs = &runstats[i]; |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 605 | max_run[0] = rs->max_run[0] * 1024 / 1000; |
| 606 | max_run[1] = rs->max_run[1] * 1024 / 1000; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 607 | |
| 608 | if (rs->max_run[0]) |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 609 | rs->agg[0] = (rs->io_kb[0]*1024) / max_run[0]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 610 | if (rs->max_run[1]) |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 611 | rs->agg[1] = (rs->io_kb[1]*1024) / max_run[1]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | /* |
| 615 | * don't overwrite last signal output |
| 616 | */ |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 617 | if (!terse_output) |
| 618 | printf("\n"); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 619 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 620 | for (i = 0; i < nr_ts; i++) { |
| 621 | ts = &threadstats[i]; |
| 622 | rs = &runstats[ts->groupid]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 623 | |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 624 | if (terse_output) |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 625 | show_thread_status_terse(ts, rs); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 626 | else |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 627 | show_thread_status(ts, rs); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 628 | } |
| 629 | |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 630 | if (!terse_output) { |
| 631 | for (i = 0; i < groupid + 1; i++) |
| 632 | show_group_stats(&runstats[i], i); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 633 | |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 634 | show_disk_util(); |
| 635 | } |
Jens Axboe | eecf272 | 2006-10-20 14:00:36 +0200 | [diff] [blame] | 636 | |
| 637 | free(runstats); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 638 | free(threadstats); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 639 | } |
| 640 | |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 641 | static inline void add_stat_sample(struct io_stat *is, unsigned long data) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 642 | { |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 643 | double val = data; |
Jens Axboe | 6660cc6 | 2007-03-06 15:48:38 +0100 | [diff] [blame] | 644 | double delta; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 645 | |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 646 | if (data > is->max_val) |
| 647 | is->max_val = data; |
| 648 | if (data < is->min_val) |
| 649 | is->min_val = data; |
| 650 | |
| 651 | delta = val - is->mean; |
Jens Axboe | ef11d73 | 2007-03-29 15:36:29 +0200 | [diff] [blame] | 652 | if (delta) { |
| 653 | is->mean += delta / (is->samples + 1.0); |
| 654 | is->S += delta * (val - is->mean); |
| 655 | } |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 656 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 657 | is->samples++; |
| 658 | } |
| 659 | |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 660 | static void __add_log_sample(struct io_log *iolog, unsigned long val, |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 661 | enum fio_ddir ddir, unsigned int bs, |
| 662 | unsigned long time) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 663 | { |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 664 | const int nr_samples = iolog->nr_samples; |
| 665 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 666 | if (iolog->nr_samples == iolog->max_samples) { |
| 667 | int new_size = sizeof(struct io_sample) * iolog->max_samples*2; |
| 668 | |
| 669 | iolog->log = realloc(iolog->log, new_size); |
| 670 | iolog->max_samples <<= 1; |
| 671 | } |
| 672 | |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 673 | iolog->log[nr_samples].val = val; |
| 674 | iolog->log[nr_samples].time = time; |
| 675 | iolog->log[nr_samples].ddir = ddir; |
| 676 | iolog->log[nr_samples].bs = bs; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 677 | iolog->nr_samples++; |
| 678 | } |
| 679 | |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 680 | static void add_log_sample(struct thread_data *td, struct io_log *iolog, |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 681 | unsigned long val, enum fio_ddir ddir, |
| 682 | unsigned int bs) |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 683 | { |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 684 | __add_log_sample(iolog, val, ddir, bs, mtime_since_now(&td->epoch)); |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 685 | } |
| 686 | |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 687 | void add_agg_sample(unsigned long val, enum fio_ddir ddir, unsigned int bs) |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 688 | { |
| 689 | struct io_log *iolog = agg_io_log[ddir]; |
| 690 | |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 691 | __add_log_sample(iolog, val, ddir, bs, mtime_since_genesis()); |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 692 | } |
| 693 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 694 | void add_clat_sample(struct thread_data *td, enum fio_ddir ddir, |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 695 | unsigned long usec, unsigned int bs) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 696 | { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 697 | struct thread_stat *ts = &td->ts; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 698 | |
Jens Axboe | d85f511 | 2007-06-18 09:41:23 +0200 | [diff] [blame] | 699 | add_stat_sample(&ts->clat_stat[ddir], usec); |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 700 | |
| 701 | if (ts->clat_log) |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 702 | add_log_sample(td, ts->clat_log, usec, ddir, bs); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 703 | } |
| 704 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 705 | void add_slat_sample(struct thread_data *td, enum fio_ddir ddir, |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 706 | unsigned long usec, unsigned int bs) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 707 | { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 708 | struct thread_stat *ts = &td->ts; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 709 | |
Jens Axboe | d85f511 | 2007-06-18 09:41:23 +0200 | [diff] [blame] | 710 | add_stat_sample(&ts->slat_stat[ddir], usec); |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 711 | |
| 712 | if (ts->slat_log) |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 713 | add_log_sample(td, ts->slat_log, usec, ddir, bs); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 714 | } |
| 715 | |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 716 | void add_bw_sample(struct thread_data *td, enum fio_ddir ddir, unsigned int bs, |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 717 | struct timeval *t) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 718 | { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 719 | struct thread_stat *ts = &td->ts; |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 720 | unsigned long spent = mtime_since(&ts->stat_sample_time[ddir], t); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 721 | unsigned long rate; |
| 722 | |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 723 | if (spent < td->o.bw_avg_time) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 724 | return; |
| 725 | |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 726 | rate = (td->this_io_bytes[ddir] - ts->stat_io_bytes[ddir]) * 1000 / spent / 1024; |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 727 | add_stat_sample(&ts->bw_stat[ddir], rate); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 728 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 729 | if (ts->bw_log) |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 730 | add_log_sample(td, ts->bw_log, rate, ddir, bs); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 731 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 732 | fio_gettime(&ts->stat_sample_time[ddir], NULL); |
| 733 | ts->stat_io_bytes[ddir] = td->this_io_bytes[ddir]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 734 | } |