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 | c7c6cb4 | 2011-10-13 14:12:40 +0200 | [diff] [blame] | 12 | #include "lib/ieee754.h" |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 13 | #include "json.h" |
Jens Axboe | 44404c5 | 2013-01-24 14:20:09 -0700 | [diff] [blame] | 14 | #include "lib/getrusage.h" |
Huadong Liu | f2a2ce0 | 2013-01-30 13:22:24 +0100 | [diff] [blame] | 15 | #include "idletime.h" |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 16 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 17 | void update_rusage_stat(struct thread_data *td) |
| 18 | { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 19 | struct thread_stat *ts = &td->ts; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 20 | |
Jens Axboe | 44404c5 | 2013-01-24 14:20:09 -0700 | [diff] [blame] | 21 | fio_getrusage(&td->ru_end); |
Jens Axboe | c8aaba1 | 2011-10-03 12:14:19 +0200 | [diff] [blame] | 22 | ts->usr_time += mtime_since(&td->ru_start.ru_utime, |
| 23 | &td->ru_end.ru_utime); |
| 24 | ts->sys_time += mtime_since(&td->ru_start.ru_stime, |
| 25 | &td->ru_end.ru_stime); |
| 26 | ts->ctx += td->ru_end.ru_nvcsw + td->ru_end.ru_nivcsw |
| 27 | - (td->ru_start.ru_nvcsw + td->ru_start.ru_nivcsw); |
| 28 | ts->minf += td->ru_end.ru_minflt - td->ru_start.ru_minflt; |
| 29 | ts->majf += td->ru_end.ru_majflt - td->ru_start.ru_majflt; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 30 | |
Jens Axboe | c8aaba1 | 2011-10-03 12:14:19 +0200 | [diff] [blame] | 31 | memcpy(&td->ru_start, &td->ru_end, sizeof(td->ru_end)); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 32 | } |
| 33 | |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 34 | /* |
| 35 | * Given a latency, return the index of the corresponding bucket in |
| 36 | * the structure tracking percentiles. |
| 37 | * |
| 38 | * (1) find the group (and error bits) that the value (latency) |
| 39 | * belongs to by looking at its MSB. (2) find the bucket number in the |
| 40 | * group by looking at the index bits. |
| 41 | * |
| 42 | */ |
| 43 | static unsigned int plat_val_to_idx(unsigned int val) |
| 44 | { |
| 45 | unsigned int msb, error_bits, base, offset, idx; |
| 46 | |
| 47 | /* Find MSB starting from bit 0 */ |
| 48 | if (val == 0) |
| 49 | msb = 0; |
| 50 | else |
| 51 | msb = (sizeof(val)*8) - __builtin_clz(val) - 1; |
| 52 | |
Jens Axboe | 716050f | 2011-08-16 08:43:45 +0200 | [diff] [blame] | 53 | /* |
| 54 | * MSB <= (FIO_IO_U_PLAT_BITS-1), cannot be rounded off. Use |
| 55 | * all bits of the sample as index |
| 56 | */ |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 57 | if (msb <= FIO_IO_U_PLAT_BITS) |
| 58 | return val; |
| 59 | |
| 60 | /* Compute the number of error bits to discard*/ |
| 61 | error_bits = msb - FIO_IO_U_PLAT_BITS; |
| 62 | |
| 63 | /* Compute the number of buckets before the group */ |
| 64 | base = (error_bits + 1) << FIO_IO_U_PLAT_BITS; |
| 65 | |
Jens Axboe | 716050f | 2011-08-16 08:43:45 +0200 | [diff] [blame] | 66 | /* |
| 67 | * Discard the error bits and apply the mask to find the |
Jens Axboe | 3c3ed07 | 2012-03-27 09:12:39 +0200 | [diff] [blame] | 68 | * index for the buckets in the group |
Jens Axboe | 716050f | 2011-08-16 08:43:45 +0200 | [diff] [blame] | 69 | */ |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 70 | offset = (FIO_IO_U_PLAT_VAL - 1) & (val >> error_bits); |
| 71 | |
| 72 | /* Make sure the index does not exceed (array size - 1) */ |
Jens Axboe | 3c3ed07 | 2012-03-27 09:12:39 +0200 | [diff] [blame] | 73 | idx = (base + offset) < (FIO_IO_U_PLAT_NR - 1) ? |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 74 | (base + offset) : (FIO_IO_U_PLAT_NR - 1); |
| 75 | |
| 76 | return idx; |
| 77 | } |
| 78 | |
| 79 | /* |
| 80 | * Convert the given index of the bucket array to the value |
| 81 | * represented by the bucket |
| 82 | */ |
| 83 | static unsigned int plat_idx_to_val(unsigned int idx) |
| 84 | { |
| 85 | unsigned int error_bits, k, base; |
| 86 | |
| 87 | assert(idx < FIO_IO_U_PLAT_NR); |
| 88 | |
| 89 | /* MSB <= (FIO_IO_U_PLAT_BITS-1), cannot be rounded off. Use |
| 90 | * all bits of the sample as index */ |
Jens Axboe | 3c3ed07 | 2012-03-27 09:12:39 +0200 | [diff] [blame] | 91 | if (idx < (FIO_IO_U_PLAT_VAL << 1)) |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 92 | return idx; |
| 93 | |
| 94 | /* Find the group and compute the minimum value of that group */ |
Jens Axboe | 3c3ed07 | 2012-03-27 09:12:39 +0200 | [diff] [blame] | 95 | error_bits = (idx >> FIO_IO_U_PLAT_BITS) - 1; |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 96 | base = 1 << (error_bits + FIO_IO_U_PLAT_BITS); |
| 97 | |
| 98 | /* Find its bucket number of the group */ |
| 99 | k = idx % FIO_IO_U_PLAT_VAL; |
| 100 | |
| 101 | /* Return the mean of the range of the bucket */ |
| 102 | return base + ((k + 0.5) * (1 << error_bits)); |
| 103 | } |
| 104 | |
| 105 | static int double_cmp(const void *a, const void *b) |
| 106 | { |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 107 | const fio_fp64_t fa = *(const fio_fp64_t *) a; |
| 108 | const fio_fp64_t fb = *(const fio_fp64_t *) b; |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 109 | int cmp = 0; |
| 110 | |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 111 | if (fa.u.f > fb.u.f) |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 112 | cmp = 1; |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 113 | else if (fa.u.f < fb.u.f) |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 114 | cmp = -1; |
| 115 | |
| 116 | return cmp; |
| 117 | } |
| 118 | |
Jens Axboe | a269790 | 2012-03-05 16:43:49 +0100 | [diff] [blame] | 119 | unsigned int calc_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, |
| 120 | fio_fp64_t *plist, unsigned int **output, |
| 121 | unsigned int *maxv, unsigned int *minv) |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 122 | { |
| 123 | unsigned long sum = 0; |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 124 | unsigned int len, i, j = 0; |
| 125 | unsigned int oval_len = 0; |
| 126 | unsigned int *ovals = NULL; |
| 127 | int is_last; |
| 128 | |
| 129 | *minv = -1U; |
| 130 | *maxv = 0; |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 131 | |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 132 | len = 0; |
| 133 | while (len < FIO_IO_U_LIST_MAX_LEN && plist[len].u.f != 0.0) |
| 134 | len++; |
Jens Axboe | 716050f | 2011-08-16 08:43:45 +0200 | [diff] [blame] | 135 | |
Jens Axboe | 351de8d | 2011-10-12 21:03:45 +0200 | [diff] [blame] | 136 | if (!len) |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 137 | return 0; |
Jens Axboe | 351de8d | 2011-10-12 21:03:45 +0200 | [diff] [blame] | 138 | |
Jens Axboe | 716050f | 2011-08-16 08:43:45 +0200 | [diff] [blame] | 139 | /* |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 140 | * Sort the percentile list. Note that it may already be sorted if |
| 141 | * we are using the default values, but since it's a short list this |
| 142 | * isn't a worry. Also note that this does not work for NaN values. |
Jens Axboe | 716050f | 2011-08-16 08:43:45 +0200 | [diff] [blame] | 143 | */ |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 144 | if (len > 1) |
Jens Axboe | 3c3ed07 | 2012-03-27 09:12:39 +0200 | [diff] [blame] | 145 | qsort((void *)plist, len, sizeof(plist[0]), double_cmp); |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 146 | |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 147 | /* |
| 148 | * Calculate bucket values, note down max and min values |
| 149 | */ |
Jens Axboe | 07511a6 | 2011-10-13 12:00:24 +0200 | [diff] [blame] | 150 | is_last = 0; |
| 151 | for (i = 0; i < FIO_IO_U_PLAT_NR && !is_last; i++) { |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 152 | sum += io_u_plat[i]; |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 153 | while (sum >= (plist[j].u.f / 100.0 * nr)) { |
| 154 | assert(plist[j].u.f <= 100.0); |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 155 | |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 156 | if (j == oval_len) { |
| 157 | oval_len += 100; |
| 158 | ovals = realloc(ovals, oval_len * sizeof(unsigned int)); |
| 159 | } |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 160 | |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 161 | ovals[j] = plat_idx_to_val(i); |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 162 | if (ovals[j] < *minv) |
| 163 | *minv = ovals[j]; |
| 164 | if (ovals[j] > *maxv) |
| 165 | *maxv = ovals[j]; |
Jens Axboe | 07511a6 | 2011-10-13 12:00:24 +0200 | [diff] [blame] | 166 | |
| 167 | is_last = (j == len - 1); |
| 168 | if (is_last) |
| 169 | break; |
| 170 | |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 171 | j++; |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 172 | } |
| 173 | } |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 174 | |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 175 | *output = ovals; |
| 176 | return len; |
| 177 | } |
| 178 | |
| 179 | /* |
| 180 | * Find and display the p-th percentile of clat |
| 181 | */ |
| 182 | static void show_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, |
Jens Axboe | 3dc1e5b | 2013-02-07 12:56:09 +0100 | [diff] [blame] | 183 | fio_fp64_t *plist, unsigned int precision) |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 184 | { |
| 185 | unsigned int len, j = 0, minv, maxv; |
| 186 | unsigned int *ovals; |
Jens Axboe | eef0244 | 2013-02-06 08:51:57 +0100 | [diff] [blame] | 187 | int is_last, per_line, scale_down; |
| 188 | char fmt[32]; |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 189 | |
| 190 | len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv); |
| 191 | if (!len) |
| 192 | goto out; |
| 193 | |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 194 | /* |
| 195 | * We default to usecs, but if the value range is such that we |
| 196 | * should scale down to msecs, do that. |
| 197 | */ |
| 198 | if (minv > 2000 && maxv > 99999) { |
| 199 | scale_down = 1; |
| 200 | log_info(" clat percentiles (msec):\n |"); |
| 201 | } else { |
| 202 | scale_down = 0; |
| 203 | log_info(" clat percentiles (usec):\n |"); |
| 204 | } |
| 205 | |
Jens Axboe | 3dc1e5b | 2013-02-07 12:56:09 +0100 | [diff] [blame] | 206 | snprintf(fmt, sizeof(fmt), "%%1.%uf", precision); |
Jens Axboe | eef0244 | 2013-02-06 08:51:57 +0100 | [diff] [blame] | 207 | per_line = (80 - 7) / (precision + 14); |
Jens Axboe | 619adf9 | 2013-02-06 08:46:55 +0100 | [diff] [blame] | 208 | |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 209 | for (j = 0; j < len; j++) { |
Jens Axboe | 619adf9 | 2013-02-06 08:46:55 +0100 | [diff] [blame] | 210 | char fbuf[16], *ptr = fbuf; |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 211 | |
| 212 | /* for formatting */ |
Jens Axboe | eef0244 | 2013-02-06 08:51:57 +0100 | [diff] [blame] | 213 | if (j != 0 && (j % per_line) == 0) |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 214 | log_info(" |"); |
| 215 | |
| 216 | /* end of the list */ |
| 217 | is_last = (j == len - 1); |
| 218 | |
| 219 | if (plist[j].u.f < 10.0) |
Jens Axboe | 619adf9 | 2013-02-06 08:46:55 +0100 | [diff] [blame] | 220 | ptr += sprintf(fbuf, " "); |
| 221 | |
Jens Axboe | eef0244 | 2013-02-06 08:51:57 +0100 | [diff] [blame] | 222 | snprintf(ptr, sizeof(fbuf), fmt, plist[j].u.f); |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 223 | |
| 224 | if (scale_down) |
| 225 | ovals[j] = (ovals[j] + 999) / 1000; |
| 226 | |
| 227 | log_info(" %sth=[%5u]%c", fbuf, ovals[j], is_last ? '\n' : ','); |
| 228 | |
| 229 | if (is_last) |
| 230 | break; |
| 231 | |
Jens Axboe | eef0244 | 2013-02-06 08:51:57 +0100 | [diff] [blame] | 232 | if ((j % per_line) == per_line - 1) /* for formatting */ |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 233 | log_info("\n"); |
| 234 | } |
| 235 | |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 236 | out: |
Jens Axboe | 4f6f829 | 2011-10-13 09:28:21 +0200 | [diff] [blame] | 237 | if (ovals) |
| 238 | free(ovals); |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 239 | } |
| 240 | |
Jens Axboe | b29ad56 | 2012-03-05 13:08:51 +0100 | [diff] [blame] | 241 | int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, |
| 242 | double *mean, double *dev) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 243 | { |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 244 | double n = is->samples; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 245 | |
| 246 | if (is->samples == 0) |
| 247 | return 0; |
| 248 | |
| 249 | *min = is->min_val; |
| 250 | *max = is->max_val; |
| 251 | |
| 252 | n = (double) is->samples; |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 253 | *mean = is->mean.u.f; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 254 | |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 255 | if (n > 1.0) |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 256 | *dev = sqrt(is->S.u.f / (n - 1.0)); |
Jens Axboe | ef9c5c4 | 2007-01-03 14:21:13 +0100 | [diff] [blame] | 257 | else |
Jens Axboe | 4b43f54 | 2007-07-19 21:38:35 +0200 | [diff] [blame] | 258 | *dev = 0; |
Jens Axboe | ef9c5c4 | 2007-01-03 14:21:13 +0100 | [diff] [blame] | 259 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 260 | return 1; |
| 261 | } |
| 262 | |
Jens Axboe | a64e88d | 2011-10-03 14:20:01 +0200 | [diff] [blame] | 263 | void show_group_stats(struct group_run_stats *rs) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 264 | { |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 265 | char *p1, *p2, *p3, *p4; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 266 | const char *ddir_str[] = { " READ", " WRITE" , " TRIM"}; |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 267 | int i; |
| 268 | |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 269 | log_info("\nRun status group %d (all jobs):\n", rs->groupid); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 270 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 271 | for (i = 0; i < DDIR_RWDIR_CNT; i++) { |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 272 | const int i2p = is_power_of_2(rs->kb_base); |
| 273 | |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 274 | if (!rs->max_run[i]) |
| 275 | continue; |
| 276 | |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 277 | p1 = num2str(rs->io_kb[i], 6, rs->kb_base, i2p); |
| 278 | p2 = num2str(rs->agg[i], 6, rs->kb_base, i2p); |
| 279 | p3 = num2str(rs->min_bw[i], 6, rs->kb_base, i2p); |
| 280 | p4 = num2str(rs->max_bw[i], 6, rs->kb_base, i2p); |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 281 | |
Jens Axboe | b22989b | 2009-07-17 22:29:23 +0200 | [diff] [blame] | 282 | log_info("%s: io=%sB, aggrb=%sB/s, minb=%sB/s, maxb=%sB/s," |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 283 | " mint=%llumsec, maxt=%llumsec\n", |
| 284 | rs->unified_rw_rep ? " MIXED" : ddir_str[i], |
| 285 | p1, p2, p3, p4, rs->min_run[i], rs->max_run[i]); |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 286 | |
| 287 | free(p1); |
| 288 | free(p2); |
| 289 | free(p3); |
| 290 | free(p4); |
| 291 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 292 | } |
| 293 | |
Jens Axboe | 2e33101 | 2012-03-05 22:07:54 +0100 | [diff] [blame] | 294 | void stat_calc_dist(unsigned int *map, unsigned long total, double *io_u_dist) |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 295 | { |
| 296 | int i; |
| 297 | |
| 298 | /* |
| 299 | * Do depth distribution calculations |
| 300 | */ |
| 301 | for (i = 0; i < FIO_IO_U_MAP_NR; i++) { |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 302 | if (total) { |
| 303 | io_u_dist[i] = (double) map[i] / (double) total; |
| 304 | io_u_dist[i] *= 100.0; |
| 305 | if (io_u_dist[i] < 0.1 && map[i]) |
| 306 | io_u_dist[i] = 0.1; |
| 307 | } else |
| 308 | io_u_dist[i] = 0.0; |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 312 | static void stat_calc_lat(struct thread_stat *ts, double *dst, |
| 313 | unsigned int *src, int nr) |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 314 | { |
Jens Axboe | d79db12 | 2012-09-24 08:51:24 +0200 | [diff] [blame] | 315 | unsigned long total = ddir_rw_sum(ts->total_io_u); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 316 | int i; |
| 317 | |
| 318 | /* |
| 319 | * Do latency distribution calculations |
| 320 | */ |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 321 | for (i = 0; i < nr; i++) { |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 322 | if (total) { |
| 323 | dst[i] = (double) src[i] / (double) total; |
| 324 | dst[i] *= 100.0; |
| 325 | if (dst[i] < 0.01 && src[i]) |
| 326 | dst[i] = 0.01; |
| 327 | } else |
| 328 | dst[i] = 0.0; |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | |
Jens Axboe | e5bd134 | 2012-03-05 21:38:12 +0100 | [diff] [blame] | 332 | void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat) |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 333 | { |
| 334 | stat_calc_lat(ts, io_u_lat, ts->io_u_lat_u, FIO_IO_U_LAT_U_NR); |
| 335 | } |
| 336 | |
Jens Axboe | e5bd134 | 2012-03-05 21:38:12 +0100 | [diff] [blame] | 337 | void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat) |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 338 | { |
| 339 | stat_calc_lat(ts, io_u_lat, ts->io_u_lat_m, FIO_IO_U_LAT_M_NR); |
| 340 | } |
| 341 | |
Jens Axboe | b29ad56 | 2012-03-05 13:08:51 +0100 | [diff] [blame] | 342 | static void display_lat(const char *name, unsigned long min, unsigned long max, |
| 343 | double mean, double dev) |
Jens Axboe | ea2accc | 2007-06-19 09:48:44 +0200 | [diff] [blame] | 344 | { |
Jens Axboe | b29ad56 | 2012-03-05 13:08:51 +0100 | [diff] [blame] | 345 | const char *base = "(usec)"; |
| 346 | char *minp, *maxp; |
Jens Axboe | ea2accc | 2007-06-19 09:48:44 +0200 | [diff] [blame] | 347 | |
Jens Axboe | b29ad56 | 2012-03-05 13:08:51 +0100 | [diff] [blame] | 348 | if (!usec_to_msec(&min, &max, &mean, &dev)) |
| 349 | base = "(msec)"; |
| 350 | |
| 351 | minp = num2str(min, 6, 1, 0); |
| 352 | maxp = num2str(max, 6, 1, 0); |
| 353 | |
| 354 | log_info(" %s %s: min=%s, max=%s, avg=%5.02f," |
| 355 | " stdev=%5.02f\n", name, base, minp, maxp, mean, dev); |
| 356 | |
| 357 | free(minp); |
| 358 | free(maxp); |
Jens Axboe | ea2accc | 2007-06-19 09:48:44 +0200 | [diff] [blame] | 359 | } |
| 360 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 361 | 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] | 362 | int ddir) |
| 363 | { |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 364 | const char *ddir_str[] = { "read ", "write", "trim" }; |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 365 | unsigned long min, max, runt; |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 366 | unsigned long long bw, iops; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 367 | double mean, dev; |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 368 | char *io_p, *bw_p, *iops_p; |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 369 | int i2p; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 370 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 371 | assert(ddir_rw(ddir)); |
| 372 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 373 | if (!ts->runtime[ddir]) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 374 | return; |
| 375 | |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 376 | i2p = is_power_of_2(rs->kb_base); |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 377 | runt = ts->runtime[ddir]; |
| 378 | |
| 379 | bw = (1000 * ts->io_bytes[ddir]) / runt; |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 380 | io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p); |
| 381 | bw_p = num2str(bw, 6, 1, i2p); |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 382 | |
Bruce Cran | 0aacc50 | 2011-07-09 08:19:53 +0200 | [diff] [blame] | 383 | iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt; |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 384 | iops_p = num2str(iops, 6, 1, 0); |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 385 | |
Signed-off-by Steven Pratt | cda99fa | 2010-12-14 08:31:36 +0100 | [diff] [blame] | 386 | log_info(" %s: io=%sB, bw=%sB/s, iops=%s, runt=%6llumsec\n", |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 387 | rs->unified_rw_rep ? "mixed" : ddir_str[ddir], |
| 388 | io_p, bw_p, iops_p, ts->runtime[ddir]); |
Jens Axboe | dbe1125 | 2007-02-11 00:19:51 +0100 | [diff] [blame] | 389 | |
| 390 | free(io_p); |
| 391 | free(bw_p); |
Jens Axboe | b360506 | 2007-03-12 14:19:47 +0100 | [diff] [blame] | 392 | free(iops_p); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 393 | |
Jens Axboe | b29ad56 | 2012-03-05 13:08:51 +0100 | [diff] [blame] | 394 | if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) |
| 395 | display_lat("slat", min, max, mean, dev); |
| 396 | if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) |
| 397 | display_lat("clat", min, max, mean, dev); |
| 398 | if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) |
| 399 | display_lat(" lat", min, max, mean, dev); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 400 | |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 401 | if (ts->clat_percentiles) { |
| 402 | show_clat_percentiles(ts->io_u_plat[ddir], |
| 403 | ts->clat_stat[ddir].samples, |
Vincent Kang Fu | 435d195 | 2013-02-06 08:43:40 +0100 | [diff] [blame] | 404 | ts->percentile_list, |
| 405 | ts->percentile_precision); |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 406 | } |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 407 | if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { |
Jens Axboe | 19d3e96 | 2012-02-07 12:27:28 +0100 | [diff] [blame] | 408 | double p_of_agg = 100.0; |
Jens Axboe | b7017e3 | 2011-10-14 09:30:01 +0200 | [diff] [blame] | 409 | const char *bw_str = "KB"; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 410 | |
Jens Axboe | 2f2c692 | 2012-02-07 16:42:43 +0100 | [diff] [blame] | 411 | if (rs->agg[ddir]) { |
Jens Axboe | 19d3e96 | 2012-02-07 12:27:28 +0100 | [diff] [blame] | 412 | p_of_agg = mean * 100 / (double) rs->agg[ddir]; |
| 413 | if (p_of_agg > 100.0) |
| 414 | p_of_agg = 100.0; |
| 415 | } |
Jens Axboe | b7017e3 | 2011-10-14 09:30:01 +0200 | [diff] [blame] | 416 | |
| 417 | if (mean > 999999.9) { |
| 418 | min /= 1000.0; |
| 419 | max /= 1000.0; |
| 420 | mean /= 1000.0; |
| 421 | dev /= 1000.0; |
| 422 | bw_str = "MB"; |
| 423 | } |
| 424 | |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 425 | log_info(" bw (%s/s) : min=%5lu, max=%5lu, per=%3.2f%%," |
Jens Axboe | b7017e3 | 2011-10-14 09:30:01 +0200 | [diff] [blame] | 426 | " avg=%5.02f, stdev=%5.02f\n", bw_str, min, max, |
| 427 | p_of_agg, mean, dev); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 428 | } |
| 429 | } |
| 430 | |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 431 | static int show_lat(double *io_u_lat, int nr, const char **ranges, |
| 432 | const char *msg) |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 433 | { |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 434 | int new_line = 1, i, line = 0, shown = 0; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 435 | |
| 436 | for (i = 0; i < nr; i++) { |
| 437 | if (io_u_lat[i] <= 0.0) |
| 438 | continue; |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 439 | shown = 1; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 440 | if (new_line) { |
Jens Axboe | 4539ed7 | 2007-07-23 14:21:17 +0200 | [diff] [blame] | 441 | if (line) |
| 442 | log_info("\n"); |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 443 | log_info(" lat (%s) : ", msg); |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 444 | new_line = 0; |
| 445 | line = 0; |
| 446 | } |
| 447 | if (line) |
| 448 | log_info(", "); |
| 449 | log_info("%s%3.2f%%", ranges[i], io_u_lat[i]); |
| 450 | line++; |
| 451 | if (line == 5) |
| 452 | new_line = 1; |
| 453 | } |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 454 | |
| 455 | if (shown) |
| 456 | log_info("\n"); |
| 457 | |
| 458 | return shown; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | static void show_lat_u(double *io_u_lat_u) |
| 462 | { |
| 463 | const char *ranges[] = { "2=", "4=", "10=", "20=", "50=", "100=", |
| 464 | "250=", "500=", "750=", "1000=", }; |
| 465 | |
| 466 | show_lat(io_u_lat_u, FIO_IO_U_LAT_U_NR, ranges, "usec"); |
| 467 | } |
| 468 | |
| 469 | static void show_lat_m(double *io_u_lat_m) |
| 470 | { |
| 471 | const char *ranges[] = { "2=", "4=", "10=", "20=", "50=", "100=", |
| 472 | "250=", "500=", "750=", "1000=", "2000=", |
| 473 | ">=2000=", }; |
| 474 | |
| 475 | show_lat(io_u_lat_m, FIO_IO_U_LAT_M_NR, ranges, "msec"); |
| 476 | } |
| 477 | |
Jens Axboe | c551f65 | 2012-03-05 20:49:10 +0100 | [diff] [blame] | 478 | static void show_latencies(struct thread_stat *ts) |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 479 | { |
Jens Axboe | c551f65 | 2012-03-05 20:49:10 +0100 | [diff] [blame] | 480 | double io_u_lat_u[FIO_IO_U_LAT_U_NR]; |
| 481 | double io_u_lat_m[FIO_IO_U_LAT_M_NR]; |
| 482 | |
Jens Axboe | 5a18988 | 2012-03-05 14:08:34 +0100 | [diff] [blame] | 483 | stat_calc_lat_u(ts, io_u_lat_u); |
| 484 | stat_calc_lat_m(ts, io_u_lat_m); |
| 485 | |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 486 | show_lat_u(io_u_lat_u); |
| 487 | show_lat_m(io_u_lat_m); |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 488 | } |
| 489 | |
Jens Axboe | a64e88d | 2011-10-03 14:20:01 +0200 | [diff] [blame] | 490 | void show_thread_status(struct thread_stat *ts, struct group_run_stats *rs) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 491 | { |
| 492 | double usr_cpu, sys_cpu; |
Jens Axboe | 6900899 | 2006-11-24 13:12:56 +0100 | [diff] [blame] | 493 | unsigned long runtime; |
Jens Axboe | 71619dc | 2007-01-13 23:56:33 +0100 | [diff] [blame] | 494 | double io_u_dist[FIO_IO_U_MAP_NR]; |
Jens Axboe | 57a6432 | 2012-06-14 15:11:15 +0200 | [diff] [blame] | 495 | time_t time_p; |
| 496 | char time_buf[64]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 497 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 498 | if (!(ts->io_bytes[DDIR_READ] + ts->io_bytes[DDIR_WRITE] + |
| 499 | ts->io_bytes[DDIR_TRIM]) && !(ts->total_io_u[DDIR_READ] + |
| 500 | ts->total_io_u[DDIR_WRITE] + ts->total_io_u[DDIR_TRIM])) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 501 | return; |
| 502 | |
Jens Axboe | 57a6432 | 2012-06-14 15:11:15 +0200 | [diff] [blame] | 503 | time(&time_p); |
Saurabh De | 45054cb | 2012-10-09 14:46:24 -0600 | [diff] [blame] | 504 | os_ctime_r((const time_t *) &time_p, time_buf, sizeof(time_buf)); |
Jens Axboe | 57a6432 | 2012-06-14 15:11:15 +0200 | [diff] [blame] | 505 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 506 | if (!ts->error) { |
Jens Axboe | 57a6432 | 2012-06-14 15:11:15 +0200 | [diff] [blame] | 507 | log_info("%s: (groupid=%d, jobs=%d): err=%2d: pid=%d: %s", |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 508 | ts->name, ts->groupid, ts->members, |
Jens Axboe | 57a6432 | 2012-06-14 15:11:15 +0200 | [diff] [blame] | 509 | ts->error, (int) ts->pid, time_buf); |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 510 | } else { |
Jens Axboe | 57a6432 | 2012-06-14 15:11:15 +0200 | [diff] [blame] | 511 | log_info("%s: (groupid=%d, jobs=%d): err=%2d (%s): pid=%d: %s", |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 512 | ts->name, ts->groupid, ts->members, |
Jens Axboe | 57a6432 | 2012-06-14 15:11:15 +0200 | [diff] [blame] | 513 | ts->error, ts->verror, (int) ts->pid, |
| 514 | time_buf); |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 515 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 516 | |
Jens Axboe | 259e47d | 2011-10-13 21:05:59 +0200 | [diff] [blame] | 517 | if (strlen(ts->description)) |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 518 | log_info(" Description : [%s]\n", ts->description); |
Jens Axboe | 7bdce1b | 2007-03-06 20:01:13 +0100 | [diff] [blame] | 519 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 520 | if (ts->io_bytes[DDIR_READ]) |
| 521 | show_ddir_status(rs, ts, DDIR_READ); |
| 522 | if (ts->io_bytes[DDIR_WRITE]) |
| 523 | show_ddir_status(rs, ts, DDIR_WRITE); |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 524 | if (ts->io_bytes[DDIR_TRIM]) |
| 525 | show_ddir_status(rs, ts, DDIR_TRIM); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 526 | |
Jens Axboe | c551f65 | 2012-03-05 20:49:10 +0100 | [diff] [blame] | 527 | show_latencies(ts); |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 528 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 529 | runtime = ts->total_run_time; |
Jens Axboe | 6900899 | 2006-11-24 13:12:56 +0100 | [diff] [blame] | 530 | if (runtime) { |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 531 | double runt = (double) runtime; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 532 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 533 | usr_cpu = (double) ts->usr_time * 100 / runt; |
| 534 | sys_cpu = (double) ts->sys_time * 100 / runt; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 535 | } else { |
| 536 | usr_cpu = 0; |
| 537 | sys_cpu = 0; |
| 538 | } |
| 539 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 540 | log_info(" cpu : usr=%3.2f%%, sys=%3.2f%%, ctx=%lu, majf=%lu," |
| 541 | " 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] | 542 | |
Jens Axboe | d79db12 | 2012-09-24 08:51:24 +0200 | [diff] [blame] | 543 | stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist); |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 544 | log_info(" IO depths : 1=%3.1f%%, 2=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%," |
| 545 | " 16=%3.1f%%, 32=%3.1f%%, >=64=%3.1f%%\n", io_u_dist[0], |
| 546 | io_u_dist[1], io_u_dist[2], |
| 547 | io_u_dist[3], io_u_dist[4], |
| 548 | io_u_dist[5], io_u_dist[6]); |
Jens Axboe | 838bc70 | 2008-05-22 13:08:23 +0200 | [diff] [blame] | 549 | |
| 550 | stat_calc_dist(ts->io_u_submit, ts->total_submit, io_u_dist); |
| 551 | log_info(" submit : 0=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%, 16=%3.1f%%," |
| 552 | " 32=%3.1f%%, 64=%3.1f%%, >=64=%3.1f%%\n", io_u_dist[0], |
| 553 | io_u_dist[1], io_u_dist[2], |
| 554 | io_u_dist[3], io_u_dist[4], |
| 555 | io_u_dist[5], io_u_dist[6]); |
| 556 | stat_calc_dist(ts->io_u_complete, ts->total_complete, io_u_dist); |
| 557 | log_info(" complete : 0=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%, 16=%3.1f%%," |
| 558 | " 32=%3.1f%%, 64=%3.1f%%, >=64=%3.1f%%\n", io_u_dist[0], |
| 559 | io_u_dist[1], io_u_dist[2], |
| 560 | io_u_dist[3], io_u_dist[4], |
| 561 | io_u_dist[5], io_u_dist[6]); |
Jens Axboe | 7e1773b | 2011-10-14 12:47:56 +0200 | [diff] [blame] | 562 | log_info(" issued : total=r=%lu/w=%lu/d=%lu," |
| 563 | " short=r=%lu/w=%lu/d=%lu\n", |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 564 | ts->total_io_u[0], ts->total_io_u[1], |
Jens Axboe | 0d29de8 | 2010-09-01 13:54:15 +0200 | [diff] [blame] | 565 | ts->total_io_u[2], |
| 566 | ts->short_io_u[0], ts->short_io_u[1], |
| 567 | ts->short_io_u[2]); |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 568 | if (ts->continue_on_error) { |
Jens Axboe | 1ec99ee | 2009-06-15 12:37:30 +0200 | [diff] [blame] | 569 | log_info(" errors : total=%lu, first_error=%d/<%s>\n", |
| 570 | ts->total_err_count, |
| 571 | ts->first_error, |
| 572 | strerror(ts->first_error)); |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 573 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 574 | } |
| 575 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 576 | static void show_ddir_status_terse(struct thread_stat *ts, |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 577 | struct group_run_stats *rs, int ddir) |
| 578 | { |
| 579 | unsigned long min, max; |
Jens Axboe | 312b4af | 2011-10-13 13:11:42 +0200 | [diff] [blame] | 580 | unsigned long long bw, iops; |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 581 | unsigned int *ovals = NULL; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 582 | double mean, dev; |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 583 | unsigned int len, minv, maxv; |
| 584 | int i; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 585 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 586 | assert(ddir_rw(ddir)); |
| 587 | |
Jens Axboe | 312b4af | 2011-10-13 13:11:42 +0200 | [diff] [blame] | 588 | iops = bw = 0; |
| 589 | if (ts->runtime[ddir]) { |
| 590 | uint64_t runt = ts->runtime[ddir]; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 591 | |
Jens Axboe | 033bbb5 | 2012-05-07 09:46:40 +0200 | [diff] [blame] | 592 | bw = ((1000 * ts->io_bytes[ddir]) / runt) / 1024; |
Jens Axboe | 312b4af | 2011-10-13 13:11:42 +0200 | [diff] [blame] | 593 | iops = (1000 * (uint64_t) ts->total_io_u[ddir]) / runt; |
| 594 | } |
| 595 | |
| 596 | log_info(";%llu;%llu;%llu;%llu", ts->io_bytes[ddir] >> 10, bw, iops, |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 597 | ts->runtime[ddir]); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 598 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 599 | if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 600 | log_info(";%lu;%lu;%f;%f", min, max, mean, dev); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 601 | else |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 602 | log_info(";%lu;%lu;%f;%f", 0UL, 0UL, 0.0, 0.0); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 603 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 604 | if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 605 | log_info(";%lu;%lu;%f;%f", min, max, mean, dev); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 606 | else |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 607 | log_info(";%lu;%lu;%f;%f", 0UL, 0UL, 0.0, 0.0); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 608 | |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 609 | if (ts->clat_percentiles) { |
| 610 | len = calc_clat_percentiles(ts->io_u_plat[ddir], |
| 611 | ts->clat_stat[ddir].samples, |
| 612 | ts->percentile_list, &ovals, &maxv, |
| 613 | &minv); |
| 614 | } else |
| 615 | len = 0; |
| 616 | |
| 617 | for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++) { |
| 618 | if (i >= len) { |
| 619 | log_info(";0%%=0"); |
| 620 | continue; |
| 621 | } |
Vincent Kang Fu | 435d195 | 2013-02-06 08:43:40 +0100 | [diff] [blame] | 622 | log_info(";%f%%=%u", ts->percentile_list[i].u.f, ovals[i]); |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 623 | } |
Keplar kramer | 2341a37 | 2011-10-19 21:31:27 +0200 | [diff] [blame] | 624 | |
| 625 | if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) |
| 626 | log_info(";%lu;%lu;%f;%f", min, max, mean, dev); |
| 627 | else |
| 628 | log_info(";%lu;%lu;%f;%f", 0UL, 0UL, 0.0, 0.0); |
| 629 | |
Jens Axboe | 1db92cb | 2011-10-13 13:43:36 +0200 | [diff] [blame] | 630 | if (ovals) |
| 631 | free(ovals); |
| 632 | |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 633 | if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { |
Jens Axboe | 19d3e96 | 2012-02-07 12:27:28 +0100 | [diff] [blame] | 634 | double p_of_agg = 100.0; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 635 | |
Jens Axboe | 19d3e96 | 2012-02-07 12:27:28 +0100 | [diff] [blame] | 636 | if (rs->agg[ddir]) { |
| 637 | p_of_agg = mean * 100 / (double) rs->agg[ddir]; |
| 638 | if (p_of_agg > 100.0) |
| 639 | p_of_agg = 100.0; |
| 640 | } |
| 641 | |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 642 | 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] | 643 | } else |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 644 | 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] | 645 | } |
| 646 | |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 647 | static void add_ddir_status_json(struct thread_stat *ts, |
| 648 | struct group_run_stats *rs, int ddir, struct json_object *parent) |
| 649 | { |
| 650 | unsigned long min, max; |
| 651 | unsigned long long bw, iops; |
| 652 | unsigned int *ovals = NULL; |
| 653 | double mean, dev; |
| 654 | unsigned int len, minv, maxv; |
| 655 | int i; |
| 656 | const char *ddirname[] = {"read", "write", "trim"}; |
| 657 | struct json_object *dir_object, *tmp_object, *percentile_object; |
| 658 | char buf[120]; |
| 659 | double p_of_agg = 100.0; |
| 660 | |
| 661 | assert(ddir_rw(ddir)); |
| 662 | |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 663 | if (ts->unified_rw_rep && ddir != DDIR_READ) |
| 664 | return; |
| 665 | |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 666 | dir_object = json_create_object(); |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 667 | json_object_add_value_object(parent, |
| 668 | ts->unified_rw_rep ? "mixed" : ddirname[ddir], dir_object); |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 669 | |
| 670 | iops = bw = 0; |
| 671 | if (ts->runtime[ddir]) { |
| 672 | uint64_t runt = ts->runtime[ddir]; |
| 673 | |
| 674 | bw = ((1000 * ts->io_bytes[ddir]) / runt) / 1024; |
| 675 | iops = (1000 * (uint64_t) ts->total_io_u[ddir]) / runt; |
| 676 | } |
| 677 | |
| 678 | json_object_add_value_int(dir_object, "io_bytes", ts->io_bytes[ddir] >> 10); |
| 679 | json_object_add_value_int(dir_object, "bw", bw); |
| 680 | json_object_add_value_int(dir_object, "iops", iops); |
| 681 | json_object_add_value_int(dir_object, "runtime", ts->runtime[ddir]); |
| 682 | |
| 683 | if (!calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) { |
| 684 | min = max = 0; |
| 685 | mean = dev = 0.0; |
| 686 | } |
| 687 | tmp_object = json_create_object(); |
| 688 | json_object_add_value_object(dir_object, "slat", tmp_object); |
| 689 | json_object_add_value_int(tmp_object, "min", min); |
| 690 | json_object_add_value_int(tmp_object, "max", max); |
| 691 | json_object_add_value_float(tmp_object, "mean", mean); |
| 692 | json_object_add_value_float(tmp_object, "stddev", dev); |
| 693 | |
| 694 | if (!calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) { |
| 695 | min = max = 0; |
| 696 | mean = dev = 0.0; |
| 697 | } |
| 698 | tmp_object = json_create_object(); |
| 699 | json_object_add_value_object(dir_object, "clat", tmp_object); |
| 700 | json_object_add_value_int(tmp_object, "min", min); |
| 701 | json_object_add_value_int(tmp_object, "max", max); |
| 702 | json_object_add_value_float(tmp_object, "mean", mean); |
| 703 | json_object_add_value_float(tmp_object, "stddev", dev); |
| 704 | |
| 705 | if (ts->clat_percentiles) { |
| 706 | len = calc_clat_percentiles(ts->io_u_plat[ddir], |
| 707 | ts->clat_stat[ddir].samples, |
| 708 | ts->percentile_list, &ovals, &maxv, |
| 709 | &minv); |
| 710 | } else |
| 711 | len = 0; |
| 712 | |
| 713 | percentile_object = json_create_object(); |
| 714 | json_object_add_value_object(tmp_object, "percentile", percentile_object); |
| 715 | for (i = 0; i < FIO_IO_U_LIST_MAX_LEN; i++) { |
| 716 | if (i >= len) { |
| 717 | json_object_add_value_int(percentile_object, "0.00", 0); |
| 718 | continue; |
| 719 | } |
Vincent Kang Fu | 435d195 | 2013-02-06 08:43:40 +0100 | [diff] [blame] | 720 | snprintf(buf, sizeof(buf), "%f", ts->percentile_list[i].u.f); |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 721 | json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]); |
| 722 | } |
| 723 | |
| 724 | if (!calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) { |
| 725 | min = max = 0; |
| 726 | mean = dev = 0.0; |
| 727 | } |
| 728 | tmp_object = json_create_object(); |
| 729 | json_object_add_value_object(dir_object, "lat", tmp_object); |
| 730 | json_object_add_value_int(tmp_object, "min", min); |
| 731 | json_object_add_value_int(tmp_object, "max", max); |
| 732 | json_object_add_value_float(tmp_object, "mean", mean); |
| 733 | json_object_add_value_float(tmp_object, "stddev", dev); |
| 734 | if (ovals) |
| 735 | free(ovals); |
| 736 | |
| 737 | if (!calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) { |
| 738 | if (rs->agg[ddir]) { |
| 739 | p_of_agg = mean * 100 / (double) rs->agg[ddir]; |
| 740 | if (p_of_agg > 100.0) |
| 741 | p_of_agg = 100.0; |
| 742 | } |
| 743 | } else { |
| 744 | min = max = 0; |
| 745 | p_of_agg = mean = dev = 0.0; |
| 746 | } |
| 747 | json_object_add_value_int(dir_object, "bw_min", min); |
| 748 | json_object_add_value_int(dir_object, "bw_max", max); |
| 749 | json_object_add_value_float(dir_object, "bw_agg", mean); |
| 750 | json_object_add_value_float(dir_object, "bw_mean", mean); |
| 751 | json_object_add_value_float(dir_object, "bw_dev", dev); |
| 752 | } |
| 753 | |
Jens Axboe | 4d65865 | 2011-10-17 15:05:47 +0200 | [diff] [blame] | 754 | static void show_thread_status_terse_v2(struct thread_stat *ts, |
Jens Axboe | 3c3ed07 | 2012-03-27 09:12:39 +0200 | [diff] [blame] | 755 | struct group_run_stats *rs) |
Jens Axboe | 4d65865 | 2011-10-17 15:05:47 +0200 | [diff] [blame] | 756 | { |
| 757 | double io_u_dist[FIO_IO_U_MAP_NR]; |
| 758 | double io_u_lat_u[FIO_IO_U_LAT_U_NR]; |
| 759 | double io_u_lat_m[FIO_IO_U_LAT_M_NR]; |
| 760 | double usr_cpu, sys_cpu; |
| 761 | int i; |
| 762 | |
| 763 | /* General Info */ |
| 764 | log_info("2;%s;%d;%d", ts->name, ts->groupid, ts->error); |
| 765 | /* Log Read Status */ |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 766 | show_ddir_status_terse(ts, rs, DDIR_READ); |
Jens Axboe | 4d65865 | 2011-10-17 15:05:47 +0200 | [diff] [blame] | 767 | /* Log Write Status */ |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 768 | show_ddir_status_terse(ts, rs, DDIR_WRITE); |
| 769 | /* Log Trim Status */ |
| 770 | show_ddir_status_terse(ts, rs, DDIR_TRIM); |
Jens Axboe | 4d65865 | 2011-10-17 15:05:47 +0200 | [diff] [blame] | 771 | |
| 772 | /* CPU Usage */ |
| 773 | if (ts->total_run_time) { |
| 774 | double runt = (double) ts->total_run_time; |
| 775 | |
| 776 | usr_cpu = (double) ts->usr_time * 100 / runt; |
| 777 | sys_cpu = (double) ts->sys_time * 100 / runt; |
| 778 | } else { |
| 779 | usr_cpu = 0; |
| 780 | sys_cpu = 0; |
| 781 | } |
| 782 | |
| 783 | log_info(";%f%%;%f%%;%lu;%lu;%lu", usr_cpu, sys_cpu, ts->ctx, ts->majf, |
| 784 | ts->minf); |
| 785 | |
| 786 | /* Calc % distribution of IO depths, usecond, msecond latency */ |
Jens Axboe | d79db12 | 2012-09-24 08:51:24 +0200 | [diff] [blame] | 787 | stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist); |
Jens Axboe | 4d65865 | 2011-10-17 15:05:47 +0200 | [diff] [blame] | 788 | stat_calc_lat_u(ts, io_u_lat_u); |
| 789 | stat_calc_lat_m(ts, io_u_lat_m); |
| 790 | |
| 791 | /* Only show fixed 7 I/O depth levels*/ |
| 792 | log_info(";%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%", |
| 793 | io_u_dist[0], io_u_dist[1], io_u_dist[2], io_u_dist[3], |
| 794 | io_u_dist[4], io_u_dist[5], io_u_dist[6]); |
| 795 | |
| 796 | /* Microsecond latency */ |
| 797 | for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) |
| 798 | log_info(";%3.2f%%", io_u_lat_u[i]); |
| 799 | /* Millisecond latency */ |
| 800 | for (i = 0; i < FIO_IO_U_LAT_M_NR; i++) |
| 801 | log_info(";%3.2f%%", io_u_lat_m[i]); |
| 802 | /* Additional output if continue_on_error set - default off*/ |
| 803 | if (ts->continue_on_error) |
| 804 | log_info(";%lu;%d", ts->total_err_count, ts->first_error); |
| 805 | log_info("\n"); |
| 806 | |
| 807 | /* Additional output if description is set */ |
| 808 | if (ts->description) |
| 809 | log_info(";%s", ts->description); |
| 810 | |
| 811 | log_info("\n"); |
| 812 | } |
| 813 | |
Jens Axboe | 3449ab8 | 2012-09-14 23:35:08 +0200 | [diff] [blame] | 814 | static void show_thread_status_terse_v3_v4(struct thread_stat *ts, |
| 815 | struct group_run_stats *rs, int ver) |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 816 | { |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 817 | double io_u_dist[FIO_IO_U_MAP_NR]; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 818 | double io_u_lat_u[FIO_IO_U_LAT_U_NR]; |
| 819 | double io_u_lat_m[FIO_IO_U_LAT_M_NR]; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 820 | double usr_cpu, sys_cpu; |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 821 | int i; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 822 | |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 823 | /* General Info */ |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 824 | log_info("%d;%s;%s;%d;%d", ver, fio_version_string, |
Jens Axboe | 5e726d0 | 2011-10-14 08:08:10 +0200 | [diff] [blame] | 825 | ts->name, ts->groupid, ts->error); |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 826 | /* Log Read Status */ |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 827 | show_ddir_status_terse(ts, rs, DDIR_READ); |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 828 | /* Log Write Status */ |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 829 | show_ddir_status_terse(ts, rs, DDIR_WRITE); |
| 830 | /* Log Trim Status */ |
Jens Axboe | 3449ab8 | 2012-09-14 23:35:08 +0200 | [diff] [blame] | 831 | if (ver == 4) |
| 832 | show_ddir_status_terse(ts, rs, DDIR_TRIM); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 833 | |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 834 | /* CPU Usage */ |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 835 | if (ts->total_run_time) { |
| 836 | double runt = (double) ts->total_run_time; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 837 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 838 | usr_cpu = (double) ts->usr_time * 100 / runt; |
| 839 | sys_cpu = (double) ts->sys_time * 100 / runt; |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 840 | } else { |
| 841 | usr_cpu = 0; |
| 842 | sys_cpu = 0; |
| 843 | } |
| 844 | |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 845 | log_info(";%f%%;%f%%;%lu;%lu;%lu", usr_cpu, sys_cpu, ts->ctx, ts->majf, |
| 846 | ts->minf); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 847 | |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 848 | /* Calc % distribution of IO depths, usecond, msecond latency */ |
Jens Axboe | d79db12 | 2012-09-24 08:51:24 +0200 | [diff] [blame] | 849 | stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist); |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 850 | stat_calc_lat_u(ts, io_u_lat_u); |
| 851 | stat_calc_lat_m(ts, io_u_lat_m); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 852 | |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 853 | /* Only show fixed 7 I/O depth levels*/ |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 854 | log_info(";%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%;%3.1f%%", |
| 855 | io_u_dist[0], io_u_dist[1], io_u_dist[2], io_u_dist[3], |
| 856 | io_u_dist[4], io_u_dist[5], io_u_dist[6]); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 857 | |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 858 | /* Microsecond latency */ |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 859 | for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) |
| 860 | log_info(";%3.2f%%", io_u_lat_u[i]); |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 861 | /* Millisecond latency */ |
Jens Axboe | 04a0fea | 2007-06-19 12:48:41 +0200 | [diff] [blame] | 862 | for (i = 0; i < FIO_IO_U_LAT_M_NR; i++) |
| 863 | log_info(";%3.2f%%", io_u_lat_m[i]); |
Jens Axboe | f2f788d | 2011-10-13 14:03:52 +0200 | [diff] [blame] | 864 | |
| 865 | /* disk util stats, if any */ |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 866 | show_disk_util(1, NULL); |
Jens Axboe | f2f788d | 2011-10-13 14:03:52 +0200 | [diff] [blame] | 867 | |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 868 | /* Additional output if continue_on_error set - default off*/ |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 869 | if (ts->continue_on_error) |
| 870 | log_info(";%lu;%d", ts->total_err_count, ts->first_error); |
Jens Axboe | 2270890 | 2007-03-06 17:05:32 +0100 | [diff] [blame] | 871 | |
David Nellans | 562c2d2 | 2010-09-23 08:38:17 +0200 | [diff] [blame] | 872 | /* Additional output if description is set */ |
Jens Axboe | 4b0f225 | 2011-10-13 15:03:25 +0200 | [diff] [blame] | 873 | if (strlen(ts->description)) |
Jens Axboe | 6d86144 | 2007-03-15 09:22:23 +0100 | [diff] [blame] | 874 | log_info(";%s", ts->description); |
Jens Axboe | 946e427 | 2012-03-23 19:22:21 +0100 | [diff] [blame] | 875 | |
| 876 | log_info("\n"); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 877 | } |
| 878 | |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 879 | static struct json_object *show_thread_status_json(struct thread_stat *ts, |
| 880 | struct group_run_stats *rs) |
| 881 | { |
| 882 | struct json_object *root, *tmp; |
| 883 | double io_u_dist[FIO_IO_U_MAP_NR]; |
| 884 | double io_u_lat_u[FIO_IO_U_LAT_U_NR]; |
| 885 | double io_u_lat_m[FIO_IO_U_LAT_M_NR]; |
| 886 | double usr_cpu, sys_cpu; |
| 887 | int i; |
| 888 | |
| 889 | root = json_create_object(); |
| 890 | json_object_add_value_string(root, "jobname", ts->name); |
| 891 | json_object_add_value_int(root, "groupid", ts->groupid); |
| 892 | json_object_add_value_int(root, "error", ts->error); |
| 893 | |
| 894 | add_ddir_status_json(ts, rs, DDIR_READ, root); |
| 895 | add_ddir_status_json(ts, rs, DDIR_WRITE, root); |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 896 | add_ddir_status_json(ts, rs, DDIR_TRIM, root); |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 897 | |
| 898 | /* CPU Usage */ |
| 899 | if (ts->total_run_time) { |
| 900 | double runt = (double) ts->total_run_time; |
| 901 | |
| 902 | usr_cpu = (double) ts->usr_time * 100 / runt; |
| 903 | sys_cpu = (double) ts->sys_time * 100 / runt; |
| 904 | } else { |
| 905 | usr_cpu = 0; |
| 906 | sys_cpu = 0; |
| 907 | } |
| 908 | json_object_add_value_float(root, "usr_cpu", usr_cpu); |
| 909 | json_object_add_value_float(root, "sys_cpu", sys_cpu); |
| 910 | json_object_add_value_int(root, "ctx", ts->ctx); |
| 911 | json_object_add_value_int(root, "majf", ts->majf); |
| 912 | json_object_add_value_int(root, "minf", ts->minf); |
| 913 | |
| 914 | |
| 915 | /* Calc % distribution of IO depths, usecond, msecond latency */ |
Jens Axboe | d79db12 | 2012-09-24 08:51:24 +0200 | [diff] [blame] | 916 | stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist); |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 917 | stat_calc_lat_u(ts, io_u_lat_u); |
| 918 | stat_calc_lat_m(ts, io_u_lat_m); |
| 919 | |
| 920 | tmp = json_create_object(); |
| 921 | json_object_add_value_object(root, "iodepth_level", tmp); |
| 922 | /* Only show fixed 7 I/O depth levels*/ |
| 923 | for (i = 0; i < 7; i++) { |
| 924 | char name[20]; |
| 925 | if (i < 6) |
Ken Raeburn | 98ffb8f | 2013-01-30 22:31:09 +0100 | [diff] [blame] | 926 | snprintf(name, 20, "%d", 1 << i); |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 927 | else |
Ken Raeburn | 98ffb8f | 2013-01-30 22:31:09 +0100 | [diff] [blame] | 928 | snprintf(name, 20, ">=%d", 1 << i); |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 929 | json_object_add_value_float(tmp, (const char *)name, io_u_dist[i]); |
| 930 | } |
| 931 | |
| 932 | tmp = json_create_object(); |
| 933 | json_object_add_value_object(root, "latency_us", tmp); |
| 934 | /* Microsecond latency */ |
| 935 | for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) { |
| 936 | const char *ranges[] = { "2", "4", "10", "20", "50", "100", |
| 937 | "250", "500", "750", "1000", }; |
| 938 | json_object_add_value_float(tmp, ranges[i], io_u_lat_u[i]); |
| 939 | } |
| 940 | /* Millisecond latency */ |
| 941 | tmp = json_create_object(); |
| 942 | json_object_add_value_object(root, "latency_ms", tmp); |
| 943 | for (i = 0; i < FIO_IO_U_LAT_M_NR; i++) { |
| 944 | const char *ranges[] = { "2", "4", "10", "20", "50", "100", |
| 945 | "250", "500", "750", "1000", "2000", |
| 946 | ">=2000", }; |
| 947 | json_object_add_value_float(tmp, ranges[i], io_u_lat_m[i]); |
| 948 | } |
| 949 | |
| 950 | /* Additional output if continue_on_error set - default off*/ |
| 951 | if (ts->continue_on_error) { |
| 952 | json_object_add_value_int(root, "total_err", ts->total_err_count); |
| 953 | json_object_add_value_int(root, "total_err", ts->first_error); |
| 954 | } |
| 955 | |
| 956 | /* Additional output if description is set */ |
| 957 | if (strlen(ts->description)) |
| 958 | json_object_add_value_string(root, "desc", ts->description); |
| 959 | |
| 960 | return root; |
| 961 | } |
| 962 | |
Jens Axboe | 4d65865 | 2011-10-17 15:05:47 +0200 | [diff] [blame] | 963 | static void show_thread_status_terse(struct thread_stat *ts, |
| 964 | struct group_run_stats *rs) |
| 965 | { |
| 966 | if (terse_version == 2) |
| 967 | show_thread_status_terse_v2(ts, rs); |
Jens Axboe | 3449ab8 | 2012-09-14 23:35:08 +0200 | [diff] [blame] | 968 | else if (terse_version == 3 || terse_version == 4) |
| 969 | show_thread_status_terse_v3_v4(ts, rs, terse_version); |
Jens Axboe | 4d65865 | 2011-10-17 15:05:47 +0200 | [diff] [blame] | 970 | else |
| 971 | log_err("fio: bad terse version!? %d\n", terse_version); |
| 972 | } |
| 973 | |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 974 | 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] | 975 | { |
| 976 | double mean, S; |
| 977 | |
Zheng Liu | e09231c | 2011-09-16 08:20:12 +0200 | [diff] [blame] | 978 | if (src->samples == 0) |
| 979 | return; |
| 980 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 981 | dst->min_val = min(dst->min_val, src->min_val); |
| 982 | dst->max_val = max(dst->max_val, src->max_val); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 983 | |
| 984 | /* |
Yu-ju Hong | cdcac5c | 2011-07-30 09:18:13 +0200 | [diff] [blame] | 985 | * Compute new mean and S after the merge |
| 986 | * <http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance |
| 987 | * #Parallel_algorithm> |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 988 | */ |
| 989 | if (nr == 1) { |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 990 | mean = src->mean.u.f; |
| 991 | S = src->S.u.f; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 992 | } else { |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 993 | double delta = src->mean.u.f - dst->mean.u.f; |
Yu-ju Hong | cdcac5c | 2011-07-30 09:18:13 +0200 | [diff] [blame] | 994 | |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 995 | mean = ((src->mean.u.f * src->samples) + |
| 996 | (dst->mean.u.f * dst->samples)) / |
Yu-ju Hong | cdcac5c | 2011-07-30 09:18:13 +0200 | [diff] [blame] | 997 | (dst->samples + src->samples); |
| 998 | |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 999 | S = src->S.u.f + dst->S.u.f + pow(delta, 2.0) * |
Yu-ju Hong | cdcac5c | 2011-07-30 09:18:13 +0200 | [diff] [blame] | 1000 | (dst->samples * src->samples) / |
| 1001 | (dst->samples + src->samples); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1002 | } |
| 1003 | |
Yu-ju Hong | cdcac5c | 2011-07-30 09:18:13 +0200 | [diff] [blame] | 1004 | dst->samples += src->samples; |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 1005 | dst->mean.u.f = mean; |
| 1006 | dst->S.u.f = S; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1007 | } |
| 1008 | |
Jens Axboe | 37f0c1a | 2011-10-11 14:08:33 +0200 | [diff] [blame] | 1009 | void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src) |
| 1010 | { |
| 1011 | int i; |
| 1012 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1013 | for (i = 0; i < DDIR_RWDIR_CNT; i++) { |
Jens Axboe | 37f0c1a | 2011-10-11 14:08:33 +0200 | [diff] [blame] | 1014 | if (dst->max_run[i] < src->max_run[i]) |
| 1015 | dst->max_run[i] = src->max_run[i]; |
| 1016 | if (dst->min_run[i] && dst->min_run[i] > src->min_run[i]) |
| 1017 | dst->min_run[i] = src->min_run[i]; |
| 1018 | if (dst->max_bw[i] < src->max_bw[i]) |
| 1019 | dst->max_bw[i] = src->max_bw[i]; |
| 1020 | if (dst->min_bw[i] && dst->min_bw[i] > src->min_bw[i]) |
| 1021 | dst->min_bw[i] = src->min_bw[i]; |
| 1022 | |
| 1023 | dst->io_kb[i] += src->io_kb[i]; |
| 1024 | dst->agg[i] += src->agg[i]; |
| 1025 | } |
| 1026 | |
| 1027 | } |
| 1028 | |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1029 | void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr) |
| 1030 | { |
| 1031 | int l, k; |
| 1032 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1033 | for (l = 0; l < DDIR_RWDIR_CNT; l++) { |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 1034 | if (!dst->unified_rw_rep) { |
| 1035 | sum_stat(&dst->clat_stat[l], &src->clat_stat[l], nr); |
| 1036 | sum_stat(&dst->slat_stat[l], &src->slat_stat[l], nr); |
| 1037 | sum_stat(&dst->lat_stat[l], &src->lat_stat[l], nr); |
| 1038 | sum_stat(&dst->bw_stat[l], &src->bw_stat[l], nr); |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1039 | |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 1040 | dst->io_bytes[l] += src->io_bytes[l]; |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1041 | |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 1042 | if (dst->runtime[l] < src->runtime[l]) |
| 1043 | dst->runtime[l] = src->runtime[l]; |
| 1044 | } else { |
| 1045 | sum_stat(&dst->clat_stat[0], &src->clat_stat[l], nr); |
| 1046 | sum_stat(&dst->slat_stat[0], &src->slat_stat[l], nr); |
| 1047 | sum_stat(&dst->lat_stat[0], &src->lat_stat[l], nr); |
| 1048 | sum_stat(&dst->bw_stat[0], &src->bw_stat[l], nr); |
| 1049 | |
| 1050 | dst->io_bytes[0] += src->io_bytes[l]; |
| 1051 | |
| 1052 | if (dst->runtime[0] < src->runtime[l]) |
| 1053 | dst->runtime[0] = src->runtime[l]; |
| 1054 | } |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1055 | } |
| 1056 | |
| 1057 | dst->usr_time += src->usr_time; |
| 1058 | dst->sys_time += src->sys_time; |
| 1059 | dst->ctx += src->ctx; |
| 1060 | dst->majf += src->majf; |
| 1061 | dst->minf += src->minf; |
| 1062 | |
| 1063 | for (k = 0; k < FIO_IO_U_MAP_NR; k++) |
| 1064 | dst->io_u_map[k] += src->io_u_map[k]; |
| 1065 | for (k = 0; k < FIO_IO_U_MAP_NR; k++) |
| 1066 | dst->io_u_submit[k] += src->io_u_submit[k]; |
| 1067 | for (k = 0; k < FIO_IO_U_MAP_NR; k++) |
| 1068 | dst->io_u_complete[k] += src->io_u_complete[k]; |
| 1069 | for (k = 0; k < FIO_IO_U_LAT_U_NR; k++) |
| 1070 | dst->io_u_lat_u[k] += src->io_u_lat_u[k]; |
| 1071 | for (k = 0; k < FIO_IO_U_LAT_M_NR; k++) |
| 1072 | dst->io_u_lat_m[k] += src->io_u_lat_m[k]; |
| 1073 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1074 | for (k = 0; k < DDIR_RWDIR_CNT; k++) { |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 1075 | if (!dst->unified_rw_rep) { |
| 1076 | dst->total_io_u[k] += src->total_io_u[k]; |
| 1077 | dst->short_io_u[k] += src->short_io_u[k]; |
| 1078 | } else { |
| 1079 | dst->total_io_u[0] += src->total_io_u[k]; |
| 1080 | dst->short_io_u[0] += src->short_io_u[k]; |
| 1081 | } |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1082 | } |
| 1083 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1084 | for (k = 0; k < DDIR_RWDIR_CNT; k++) { |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1085 | int m; |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 1086 | |
| 1087 | for (m = 0; m < FIO_IO_U_PLAT_NR; m++) { |
| 1088 | if (!dst->unified_rw_rep) |
| 1089 | dst->io_u_plat[k][m] += src->io_u_plat[k][m]; |
| 1090 | else |
| 1091 | dst->io_u_plat[0][m] += src->io_u_plat[k][m]; |
| 1092 | } |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | dst->total_run_time += src->total_run_time; |
| 1096 | dst->total_submit += src->total_submit; |
| 1097 | dst->total_complete += src->total_complete; |
| 1098 | } |
| 1099 | |
Jens Axboe | 37f0c1a | 2011-10-11 14:08:33 +0200 | [diff] [blame] | 1100 | void init_group_run_stat(struct group_run_stats *gs) |
| 1101 | { |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1102 | int i; |
Jens Axboe | 37f0c1a | 2011-10-11 14:08:33 +0200 | [diff] [blame] | 1103 | memset(gs, 0, sizeof(*gs)); |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1104 | |
| 1105 | for (i = 0; i < DDIR_RWDIR_CNT; i++) |
| 1106 | gs->min_bw[i] = gs->min_run[i] = ~0UL; |
Jens Axboe | 37f0c1a | 2011-10-11 14:08:33 +0200 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | void init_thread_stat(struct thread_stat *ts) |
| 1110 | { |
| 1111 | int j; |
| 1112 | |
| 1113 | memset(ts, 0, sizeof(*ts)); |
| 1114 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1115 | for (j = 0; j < DDIR_RWDIR_CNT; j++) { |
Jens Axboe | 37f0c1a | 2011-10-11 14:08:33 +0200 | [diff] [blame] | 1116 | ts->lat_stat[j].min_val = -1UL; |
| 1117 | ts->clat_stat[j].min_val = -1UL; |
| 1118 | ts->slat_stat[j].min_val = -1UL; |
| 1119 | ts->bw_stat[j].min_val = -1UL; |
| 1120 | } |
| 1121 | ts->groupid = -1; |
| 1122 | } |
| 1123 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1124 | void show_run_stats(void) |
| 1125 | { |
| 1126 | struct group_run_stats *runstats, *rs; |
| 1127 | struct thread_data *td; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1128 | struct thread_stat *threadstats, *ts; |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1129 | int i, j, nr_ts, last_ts, idx; |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 1130 | int kb_base_warned = 0; |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 1131 | struct json_object *root = NULL; |
| 1132 | struct json_array *array = NULL; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1133 | |
| 1134 | runstats = malloc(sizeof(struct group_run_stats) * (groupid + 1)); |
| 1135 | |
Jens Axboe | 37f0c1a | 2011-10-11 14:08:33 +0200 | [diff] [blame] | 1136 | for (i = 0; i < groupid + 1; i++) |
| 1137 | init_group_run_stat(&runstats[i]); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1138 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1139 | /* |
| 1140 | * find out how many threads stats we need. if group reporting isn't |
| 1141 | * enabled, it's one-per-td. |
| 1142 | */ |
| 1143 | nr_ts = 0; |
| 1144 | last_ts = -1; |
Jens Axboe | 34572e2 | 2006-10-20 09:33:18 +0200 | [diff] [blame] | 1145 | for_each_td(td, i) { |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 1146 | if (!td->o.group_reporting) { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1147 | nr_ts++; |
| 1148 | continue; |
| 1149 | } |
| 1150 | if (last_ts == td->groupid) |
| 1151 | continue; |
| 1152 | |
| 1153 | last_ts = td->groupid; |
| 1154 | nr_ts++; |
| 1155 | } |
| 1156 | |
| 1157 | threadstats = malloc(nr_ts * sizeof(struct thread_stat)); |
| 1158 | |
Jens Axboe | 37f0c1a | 2011-10-11 14:08:33 +0200 | [diff] [blame] | 1159 | for (i = 0; i < nr_ts; i++) |
| 1160 | init_thread_stat(&threadstats[i]); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1161 | |
| 1162 | j = 0; |
| 1163 | last_ts = -1; |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 1164 | idx = 0; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1165 | for_each_td(td, i) { |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 1166 | if (idx && (!td->o.group_reporting || |
| 1167 | (td->o.group_reporting && last_ts != td->groupid))) { |
Jens Axboe | 7abd0e3 | 2007-03-12 15:24:43 +0100 | [diff] [blame] | 1168 | idx = 0; |
| 1169 | j++; |
| 1170 | } |
| 1171 | |
| 1172 | last_ts = td->groupid; |
| 1173 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1174 | ts = &threadstats[j]; |
| 1175 | |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 1176 | ts->clat_percentiles = td->o.clat_percentiles; |
Vincent Kang Fu | 435d195 | 2013-02-06 08:43:40 +0100 | [diff] [blame] | 1177 | ts->percentile_precision = td->o.percentile_precision; |
Vincent Kang Fu | fd112d3 | 2013-02-02 09:28:55 +0100 | [diff] [blame] | 1178 | memcpy(ts->percentile_list, td->o.percentile_list, sizeof(td->o.percentile_list)); |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 1179 | |
Jens Axboe | 197574e | 2007-03-08 15:35:11 +0100 | [diff] [blame] | 1180 | idx++; |
Jens Axboe | 6586ee8 | 2007-03-06 19:46:09 +0100 | [diff] [blame] | 1181 | ts->members++; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1182 | |
Jens Axboe | 7abd0e3 | 2007-03-12 15:24:43 +0100 | [diff] [blame] | 1183 | if (ts->groupid == -1) { |
Jens Axboe | 2dc84ba | 2007-03-06 15:46:33 +0100 | [diff] [blame] | 1184 | /* |
| 1185 | * These are per-group shared already |
| 1186 | */ |
Jens Axboe | f6bb5b8 | 2011-10-03 12:21:25 +0200 | [diff] [blame] | 1187 | strncpy(ts->name, td->o.name, FIO_JOBNAME_SIZE); |
Jens Axboe | a64e88d | 2011-10-03 14:20:01 +0200 | [diff] [blame] | 1188 | if (td->o.description) |
| 1189 | strncpy(ts->description, td->o.description, |
| 1190 | FIO_JOBNAME_SIZE); |
| 1191 | else |
| 1192 | memset(ts->description, 0, FIO_JOBNAME_SIZE); |
| 1193 | |
Jens Axboe | 2f122b1 | 2012-03-15 13:10:19 +0100 | [diff] [blame] | 1194 | /* |
| 1195 | * If multiple entries in this group, this is |
| 1196 | * the first member. |
| 1197 | */ |
| 1198 | ts->thread_number = td->thread_number; |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1199 | ts->groupid = td->groupid; |
Jens Axboe | 2dc84ba | 2007-03-06 15:46:33 +0100 | [diff] [blame] | 1200 | |
| 1201 | /* |
| 1202 | * first pid in group, not very useful... |
| 1203 | */ |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1204 | ts->pid = td->pid; |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 1205 | |
| 1206 | ts->kb_base = td->o.kb_base; |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 1207 | ts->unified_rw_rep = td->o.unified_rw_rep; |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 1208 | } else if (ts->kb_base != td->o.kb_base && !kb_base_warned) { |
| 1209 | log_info("fio: kb_base differs for jobs in group, using" |
| 1210 | " %u as the base\n", ts->kb_base); |
| 1211 | kb_base_warned = 1; |
Jens Axboe | 2dc84ba | 2007-03-06 15:46:33 +0100 | [diff] [blame] | 1212 | } |
| 1213 | |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 1214 | ts->continue_on_error = td->o.continue_on_error; |
| 1215 | ts->total_err_count += td->total_err_count; |
| 1216 | ts->first_error = td->first_error; |
| 1217 | if (!ts->error) { |
| 1218 | if (!td->error && td->o.continue_on_error && |
| 1219 | td->first_error) { |
| 1220 | ts->error = td->first_error; |
Jens Axboe | f6bb5b8 | 2011-10-03 12:21:25 +0200 | [diff] [blame] | 1221 | strcpy(ts->verror, td->verror); |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 1222 | } else if (td->error) { |
| 1223 | ts->error = td->error; |
Jens Axboe | f6bb5b8 | 2011-10-03 12:21:25 +0200 | [diff] [blame] | 1224 | strcpy(ts->verror, td->verror); |
Radha Ramachandran | f2bba18 | 2009-06-15 08:40:16 +0200 | [diff] [blame] | 1225 | } |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1226 | } |
| 1227 | |
Jens Axboe | 5b9babb | 2011-10-10 12:14:30 +0200 | [diff] [blame] | 1228 | sum_thread_stats(ts, &td->ts, idx); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1229 | } |
| 1230 | |
| 1231 | for (i = 0; i < nr_ts; i++) { |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 1232 | unsigned long long bw; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1233 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1234 | ts = &threadstats[i]; |
| 1235 | rs = &runstats[ts->groupid]; |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 1236 | rs->kb_base = ts->kb_base; |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 1237 | rs->unified_rw_rep += ts->unified_rw_rep; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1238 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1239 | for (j = 0; j < DDIR_RWDIR_CNT; j++) { |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 1240 | if (!ts->runtime[j]) |
| 1241 | continue; |
| 1242 | if (ts->runtime[j] < rs->min_run[j] || !rs->min_run[j]) |
| 1243 | rs->min_run[j] = ts->runtime[j]; |
| 1244 | if (ts->runtime[j] > rs->max_run[j]) |
| 1245 | rs->max_run[j] = ts->runtime[j]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1246 | |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 1247 | bw = 0; |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 1248 | if (ts->runtime[j]) { |
Jens Axboe | c857cfe | 2012-04-05 08:42:11 -0600 | [diff] [blame] | 1249 | unsigned long runt = ts->runtime[j]; |
| 1250 | unsigned long long kb; |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 1251 | |
Jens Axboe | c857cfe | 2012-04-05 08:42:11 -0600 | [diff] [blame] | 1252 | kb = ts->io_bytes[j] / rs->kb_base; |
| 1253 | bw = kb * 1000 / runt; |
Jens Axboe | 8879fd1 | 2009-04-20 10:06:02 +0200 | [diff] [blame] | 1254 | } |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 1255 | if (bw < rs->min_bw[j]) |
| 1256 | rs->min_bw[j] = bw; |
| 1257 | if (bw > rs->max_bw[j]) |
| 1258 | rs->max_bw[j] = bw; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1259 | |
Jens Axboe | 90fef2d | 2009-07-17 22:33:32 +0200 | [diff] [blame] | 1260 | rs->io_kb[j] += ts->io_bytes[j] / rs->kb_base; |
Jens Axboe | 94370ac | 2007-03-08 15:28:10 +0100 | [diff] [blame] | 1261 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1262 | } |
| 1263 | |
| 1264 | for (i = 0; i < groupid + 1; i++) { |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1265 | int ddir; |
| 1266 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1267 | rs = &runstats[i]; |
| 1268 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1269 | for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) { |
| 1270 | if (rs->max_run[ddir]) |
| 1271 | rs->agg[ddir] = (rs->io_kb[ddir] * 1000) / |
| 1272 | rs->max_run[ddir]; |
| 1273 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1274 | } |
| 1275 | |
| 1276 | /* |
| 1277 | * don't overwrite last signal output |
| 1278 | */ |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 1279 | if (output_format == FIO_OUTPUT_NORMAL) |
Jens Axboe | 4ceb30d | 2010-02-24 09:19:14 +0100 | [diff] [blame] | 1280 | log_info("\n"); |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 1281 | else if (output_format == FIO_OUTPUT_JSON) { |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 1282 | root = json_create_object(); |
| 1283 | json_object_add_value_string(root, "fio version", fio_version_string); |
| 1284 | array = json_create_array(); |
| 1285 | json_object_add_value_array(root, "jobs", array); |
| 1286 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1287 | |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1288 | for (i = 0; i < nr_ts; i++) { |
| 1289 | ts = &threadstats[i]; |
| 1290 | rs = &runstats[ts->groupid]; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1291 | |
Jens Axboe | a64e88d | 2011-10-03 14:20:01 +0200 | [diff] [blame] | 1292 | if (is_backend) |
| 1293 | fio_server_send_ts(ts, rs); |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 1294 | else if (output_format == FIO_OUTPUT_TERSE) |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1295 | show_thread_status_terse(ts, rs); |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 1296 | else if (output_format == FIO_OUTPUT_JSON) { |
| 1297 | struct json_object *tmp = show_thread_status_json(ts, rs); |
| 1298 | json_array_add_value_object(array, tmp); |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 1299 | } else |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1300 | show_thread_status(ts, rs); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1301 | } |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 1302 | if (output_format == FIO_OUTPUT_JSON) { |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 1303 | /* disk util stats, if any */ |
| 1304 | show_disk_util(1, root); |
| 1305 | |
Huadong Liu | f2a2ce0 | 2013-01-30 13:22:24 +0100 | [diff] [blame] | 1306 | show_idle_prof_stats(FIO_OUTPUT_JSON, root); |
| 1307 | |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 1308 | json_print_object(root); |
| 1309 | log_info("\n"); |
| 1310 | json_free_object(root); |
| 1311 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1312 | |
Jens Axboe | 72c27ff | 2011-10-16 11:50:31 +0200 | [diff] [blame] | 1313 | for (i = 0; i < groupid + 1; i++) { |
| 1314 | rs = &runstats[i]; |
Jens Axboe | a64e88d | 2011-10-03 14:20:01 +0200 | [diff] [blame] | 1315 | |
Jens Axboe | 72c27ff | 2011-10-16 11:50:31 +0200 | [diff] [blame] | 1316 | rs->groupid = i; |
Jens Axboe | d09a64a | 2011-10-13 11:38:56 +0200 | [diff] [blame] | 1317 | if (is_backend) |
Jens Axboe | 72c27ff | 2011-10-16 11:50:31 +0200 | [diff] [blame] | 1318 | fio_server_send_gs(rs); |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 1319 | else if (output_format == FIO_OUTPUT_NORMAL) |
Jens Axboe | 72c27ff | 2011-10-16 11:50:31 +0200 | [diff] [blame] | 1320 | show_group_stats(rs); |
Jens Axboe | c6ae0a5 | 2006-06-12 11:04:44 +0200 | [diff] [blame] | 1321 | } |
Jens Axboe | eecf272 | 2006-10-20 14:00:36 +0200 | [diff] [blame] | 1322 | |
Jens Axboe | 72c27ff | 2011-10-16 11:50:31 +0200 | [diff] [blame] | 1323 | if (is_backend) |
| 1324 | fio_server_send_du(); |
Huadong Liu | 6090400 | 2013-02-21 10:24:20 +0100 | [diff] [blame^] | 1325 | else if (output_format == FIO_OUTPUT_NORMAL) { |
Shaohua Li | cc372b1 | 2012-09-17 09:12:18 +0200 | [diff] [blame] | 1326 | show_disk_util(0, NULL); |
Huadong Liu | 6090400 | 2013-02-21 10:24:20 +0100 | [diff] [blame^] | 1327 | show_idle_prof_stats(FIO_OUTPUT_NORMAL, NULL); |
| 1328 | } |
Huadong Liu | f2a2ce0 | 2013-01-30 13:22:24 +0100 | [diff] [blame] | 1329 | |
Jens Axboe | eecf272 | 2006-10-20 14:00:36 +0200 | [diff] [blame] | 1330 | free(runstats); |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1331 | free(threadstats); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1332 | } |
| 1333 | |
Jens Axboe | b852e7c | 2012-03-30 10:30:35 +0200 | [diff] [blame] | 1334 | static void *__show_running_run_stats(void *arg) |
| 1335 | { |
| 1336 | struct thread_data *td; |
| 1337 | unsigned long long *rt; |
| 1338 | struct timeval tv; |
| 1339 | int i; |
| 1340 | |
| 1341 | rt = malloc(thread_number * sizeof(unsigned long long)); |
| 1342 | fio_gettime(&tv, NULL); |
| 1343 | |
| 1344 | for_each_td(td, i) { |
| 1345 | rt[i] = mtime_since(&td->start, &tv); |
| 1346 | if (td_read(td) && td->io_bytes[DDIR_READ]) |
| 1347 | td->ts.runtime[DDIR_READ] += rt[i]; |
| 1348 | if (td_write(td) && td->io_bytes[DDIR_WRITE]) |
| 1349 | td->ts.runtime[DDIR_WRITE] += rt[i]; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1350 | if (td_trim(td) && td->io_bytes[DDIR_TRIM]) |
| 1351 | td->ts.runtime[DDIR_TRIM] += rt[i]; |
Jens Axboe | b852e7c | 2012-03-30 10:30:35 +0200 | [diff] [blame] | 1352 | |
| 1353 | update_rusage_stat(td); |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1354 | td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ]; |
| 1355 | td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE]; |
| 1356 | td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM]; |
Jens Axboe | b852e7c | 2012-03-30 10:30:35 +0200 | [diff] [blame] | 1357 | td->ts.total_run_time = mtime_since(&td->epoch, &tv); |
| 1358 | } |
| 1359 | |
| 1360 | show_run_stats(); |
| 1361 | |
| 1362 | for_each_td(td, i) { |
| 1363 | if (td_read(td) && td->io_bytes[DDIR_READ]) |
| 1364 | td->ts.runtime[DDIR_READ] -= rt[i]; |
| 1365 | if (td_write(td) && td->io_bytes[DDIR_WRITE]) |
| 1366 | td->ts.runtime[DDIR_WRITE] -= rt[i]; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1367 | if (td_trim(td) && td->io_bytes[DDIR_TRIM]) |
| 1368 | td->ts.runtime[DDIR_TRIM] -= rt[i]; |
Jens Axboe | b852e7c | 2012-03-30 10:30:35 +0200 | [diff] [blame] | 1369 | } |
| 1370 | |
| 1371 | free(rt); |
| 1372 | return NULL; |
| 1373 | } |
| 1374 | |
| 1375 | /* |
| 1376 | * Called from signal handler. It _should_ be safe to just run this inline |
| 1377 | * in the sig handler, but we should be disturbing the system less by just |
| 1378 | * creating a thread to do it. |
| 1379 | */ |
| 1380 | void show_running_run_stats(void) |
| 1381 | { |
| 1382 | pthread_t thread; |
| 1383 | |
| 1384 | pthread_create(&thread, NULL, __show_running_run_stats, NULL); |
| 1385 | pthread_detach(thread); |
| 1386 | } |
| 1387 | |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 1388 | 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] | 1389 | { |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 1390 | double val = data; |
Jens Axboe | 6660cc6 | 2007-03-06 15:48:38 +0100 | [diff] [blame] | 1391 | double delta; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1392 | |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 1393 | if (data > is->max_val) |
| 1394 | is->max_val = data; |
| 1395 | if (data < is->min_val) |
| 1396 | is->min_val = data; |
| 1397 | |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 1398 | delta = val - is->mean.u.f; |
Jens Axboe | ef11d73 | 2007-03-29 15:36:29 +0200 | [diff] [blame] | 1399 | if (delta) { |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 1400 | is->mean.u.f += delta / (is->samples + 1.0); |
| 1401 | is->S.u.f += delta * (val - is->mean.u.f); |
Jens Axboe | ef11d73 | 2007-03-29 15:36:29 +0200 | [diff] [blame] | 1402 | } |
Jens Axboe | 6870408 | 2007-01-10 19:56:37 +0100 | [diff] [blame] | 1403 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1404 | is->samples++; |
| 1405 | } |
| 1406 | |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 1407 | static void __add_log_sample(struct io_log *iolog, unsigned long val, |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1408 | enum fio_ddir ddir, unsigned int bs, |
Jens Axboe | 2b13e71 | 2011-01-19 14:04:16 -0700 | [diff] [blame] | 1409 | unsigned long t) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1410 | { |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1411 | const int nr_samples = iolog->nr_samples; |
| 1412 | |
Jens Axboe | b8bc8cb | 2011-12-01 09:04:31 +0100 | [diff] [blame] | 1413 | if (!iolog->nr_samples) |
| 1414 | iolog->avg_last = t; |
| 1415 | |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1416 | if (iolog->nr_samples == iolog->max_samples) { |
| 1417 | int new_size = sizeof(struct io_sample) * iolog->max_samples*2; |
| 1418 | |
| 1419 | iolog->log = realloc(iolog->log, new_size); |
| 1420 | iolog->max_samples <<= 1; |
| 1421 | } |
| 1422 | |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1423 | iolog->log[nr_samples].val = val; |
Jens Axboe | 2b13e71 | 2011-01-19 14:04:16 -0700 | [diff] [blame] | 1424 | iolog->log[nr_samples].time = t; |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1425 | iolog->log[nr_samples].ddir = ddir; |
| 1426 | iolog->log[nr_samples].bs = bs; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1427 | iolog->nr_samples++; |
| 1428 | } |
| 1429 | |
Jens Axboe | 7fb28d3 | 2011-12-01 15:17:24 +0100 | [diff] [blame] | 1430 | static inline void reset_io_stat(struct io_stat *ios) |
| 1431 | { |
| 1432 | ios->max_val = ios->min_val = ios->samples = 0; |
| 1433 | ios->mean.u.f = ios->S.u.f = 0; |
| 1434 | } |
| 1435 | |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 1436 | 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] | 1437 | unsigned long val, enum fio_ddir ddir, |
| 1438 | unsigned int bs) |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 1439 | { |
Jens Axboe | 7fb28d3 | 2011-12-01 15:17:24 +0100 | [diff] [blame] | 1440 | unsigned long elapsed, this_window; |
Jens Axboe | b8bc8cb | 2011-12-01 09:04:31 +0100 | [diff] [blame] | 1441 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 1442 | if (!ddir_rw(ddir)) |
| 1443 | return; |
| 1444 | |
Jens Axboe | b8bc8cb | 2011-12-01 09:04:31 +0100 | [diff] [blame] | 1445 | elapsed = mtime_since_now(&td->epoch); |
| 1446 | |
| 1447 | /* |
| 1448 | * If no time averaging, just add the log sample. |
| 1449 | */ |
| 1450 | if (!iolog->avg_msec) { |
| 1451 | __add_log_sample(iolog, val, ddir, bs, elapsed); |
| 1452 | return; |
| 1453 | } |
| 1454 | |
| 1455 | /* |
| 1456 | * Add the sample. If the time period has passed, then |
| 1457 | * add that entry to the log and clear. |
| 1458 | */ |
| 1459 | add_stat_sample(&iolog->avg_window[ddir], val); |
| 1460 | |
Jens Axboe | 7fb28d3 | 2011-12-01 15:17:24 +0100 | [diff] [blame] | 1461 | /* |
| 1462 | * If period hasn't passed, adding the above sample is all we |
| 1463 | * need to do. |
| 1464 | */ |
Jens Axboe | b8bc8cb | 2011-12-01 09:04:31 +0100 | [diff] [blame] | 1465 | this_window = elapsed - iolog->avg_last; |
| 1466 | if (this_window < iolog->avg_msec) |
| 1467 | return; |
| 1468 | |
Jens Axboe | 7fb28d3 | 2011-12-01 15:17:24 +0100 | [diff] [blame] | 1469 | /* |
| 1470 | * Note an entry in the log. Use the mean from the logged samples, |
| 1471 | * making sure to properly round up. Only write a log entry if we |
| 1472 | * had actual samples done. |
| 1473 | */ |
| 1474 | if (iolog->avg_window[DDIR_READ].samples) { |
| 1475 | unsigned long mr; |
Jens Axboe | b8bc8cb | 2011-12-01 09:04:31 +0100 | [diff] [blame] | 1476 | |
Jens Axboe | 7fb28d3 | 2011-12-01 15:17:24 +0100 | [diff] [blame] | 1477 | mr = iolog->avg_window[DDIR_READ].mean.u.f + 0.50; |
Jens Axboe | b8bc8cb | 2011-12-01 09:04:31 +0100 | [diff] [blame] | 1478 | __add_log_sample(iolog, mr, DDIR_READ, 0, elapsed); |
Jens Axboe | 7fb28d3 | 2011-12-01 15:17:24 +0100 | [diff] [blame] | 1479 | } |
| 1480 | if (iolog->avg_window[DDIR_WRITE].samples) { |
| 1481 | unsigned long mw; |
Jens Axboe | b8bc8cb | 2011-12-01 09:04:31 +0100 | [diff] [blame] | 1482 | |
Jens Axboe | 7fb28d3 | 2011-12-01 15:17:24 +0100 | [diff] [blame] | 1483 | mw = iolog->avg_window[DDIR_WRITE].mean.u.f + 0.50; |
| 1484 | __add_log_sample(iolog, mw, DDIR_WRITE, 0, elapsed); |
| 1485 | } |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1486 | if (iolog->avg_window[DDIR_TRIM].samples) { |
| 1487 | unsigned long mw; |
| 1488 | |
| 1489 | mw = iolog->avg_window[DDIR_TRIM].mean.u.f + 0.50; |
| 1490 | __add_log_sample(iolog, mw, DDIR_TRIM, 0, elapsed); |
| 1491 | } |
| 1492 | |
Jens Axboe | 7fb28d3 | 2011-12-01 15:17:24 +0100 | [diff] [blame] | 1493 | |
| 1494 | reset_io_stat(&iolog->avg_window[DDIR_READ]); |
| 1495 | reset_io_stat(&iolog->avg_window[DDIR_WRITE]); |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1496 | reset_io_stat(&iolog->avg_window[DDIR_TRIM]); |
Jens Axboe | b8bc8cb | 2011-12-01 09:04:31 +0100 | [diff] [blame] | 1497 | iolog->avg_last = elapsed; |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 1498 | } |
| 1499 | |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1500 | 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] | 1501 | { |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 1502 | struct io_log *iolog; |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 1503 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 1504 | if (!ddir_rw(ddir)) |
| 1505 | return; |
| 1506 | |
| 1507 | iolog = agg_io_log[ddir]; |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1508 | __add_log_sample(iolog, val, ddir, bs, mtime_since_genesis()); |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 1509 | } |
| 1510 | |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 1511 | static void add_clat_percentile_sample(struct thread_stat *ts, |
| 1512 | unsigned long usec, enum fio_ddir ddir) |
| 1513 | { |
| 1514 | unsigned int idx = plat_val_to_idx(usec); |
| 1515 | assert(idx < FIO_IO_U_PLAT_NR); |
| 1516 | |
| 1517 | ts->io_u_plat[ddir][idx]++; |
| 1518 | } |
| 1519 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 1520 | void add_clat_sample(struct thread_data *td, enum fio_ddir ddir, |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1521 | unsigned long usec, unsigned int bs) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1522 | { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1523 | struct thread_stat *ts = &td->ts; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1524 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 1525 | if (!ddir_rw(ddir)) |
| 1526 | return; |
| 1527 | |
Jens Axboe | d85f511 | 2007-06-18 09:41:23 +0200 | [diff] [blame] | 1528 | add_stat_sample(&ts->clat_stat[ddir], usec); |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 1529 | |
Jens Axboe | 7b9f733 | 2011-10-03 10:06:44 +0200 | [diff] [blame] | 1530 | if (td->clat_log) |
| 1531 | add_log_sample(td, td->clat_log, usec, ddir, bs); |
Yu-ju Hong | 8334919 | 2011-08-13 00:53:44 +0200 | [diff] [blame] | 1532 | |
| 1533 | if (ts->clat_percentiles) |
| 1534 | add_clat_percentile_sample(ts, usec, ddir); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1535 | } |
| 1536 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 1537 | void add_slat_sample(struct thread_data *td, enum fio_ddir ddir, |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1538 | unsigned long usec, unsigned int bs) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1539 | { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1540 | struct thread_stat *ts = &td->ts; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1541 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 1542 | if (!ddir_rw(ddir)) |
| 1543 | return; |
| 1544 | |
Jens Axboe | d85f511 | 2007-06-18 09:41:23 +0200 | [diff] [blame] | 1545 | add_stat_sample(&ts->slat_stat[ddir], usec); |
Jens Axboe | 079ad09 | 2007-02-20 13:58:20 +0100 | [diff] [blame] | 1546 | |
Jens Axboe | 7b9f733 | 2011-10-03 10:06:44 +0200 | [diff] [blame] | 1547 | if (td->slat_log) |
| 1548 | add_log_sample(td, td->slat_log, usec, ddir, bs); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1549 | } |
| 1550 | |
Jens Axboe | 02af098 | 2010-06-24 09:59:34 +0200 | [diff] [blame] | 1551 | void add_lat_sample(struct thread_data *td, enum fio_ddir ddir, |
| 1552 | unsigned long usec, unsigned int bs) |
| 1553 | { |
| 1554 | struct thread_stat *ts = &td->ts; |
| 1555 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 1556 | if (!ddir_rw(ddir)) |
| 1557 | return; |
| 1558 | |
Jens Axboe | 02af098 | 2010-06-24 09:59:34 +0200 | [diff] [blame] | 1559 | add_stat_sample(&ts->lat_stat[ddir], usec); |
| 1560 | |
Jens Axboe | 7b9f733 | 2011-10-03 10:06:44 +0200 | [diff] [blame] | 1561 | if (td->lat_log) |
| 1562 | add_log_sample(td, td->lat_log, usec, ddir, bs); |
Jens Axboe | 02af098 | 2010-06-24 09:59:34 +0200 | [diff] [blame] | 1563 | } |
| 1564 | |
Jens Axboe | 306ddc9 | 2009-05-18 13:08:12 +0200 | [diff] [blame] | 1565 | 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] | 1566 | struct timeval *t) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1567 | { |
Jens Axboe | 756867b | 2007-03-06 15:19:24 +0100 | [diff] [blame] | 1568 | struct thread_stat *ts = &td->ts; |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 1569 | unsigned long spent, rate; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1570 | |
Jens Axboe | ff58fce | 2010-08-25 12:02:08 +0200 | [diff] [blame] | 1571 | if (!ddir_rw(ddir)) |
| 1572 | return; |
| 1573 | |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1574 | spent = mtime_since(&td->bw_sample_time, t); |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 1575 | if (spent < td->o.bw_avg_time) |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1576 | return; |
Jens Axboe | 9602d8d | 2012-02-20 20:19:28 +0100 | [diff] [blame] | 1577 | |
| 1578 | /* |
Josh Carter | 5daa4eb | 2012-02-20 10:12:22 +0100 | [diff] [blame] | 1579 | * Compute both read and write rates for the interval. |
| 1580 | */ |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1581 | for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) { |
Josh Carter | 5daa4eb | 2012-02-20 10:12:22 +0100 | [diff] [blame] | 1582 | uint64_t delta; |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1583 | |
Josh Carter | 5daa4eb | 2012-02-20 10:12:22 +0100 | [diff] [blame] | 1584 | delta = td->this_io_bytes[ddir] - td->stat_io_bytes[ddir]; |
| 1585 | if (!delta) |
| 1586 | continue; /* No entries for interval */ |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1587 | |
Josh Carter | 5daa4eb | 2012-02-20 10:12:22 +0100 | [diff] [blame] | 1588 | rate = delta * 1000 / spent / 1024; |
| 1589 | add_stat_sample(&ts->bw_stat[ddir], rate); |
| 1590 | |
| 1591 | if (td->bw_log) |
| 1592 | add_log_sample(td, td->bw_log, rate, ddir, bs); |
| 1593 | |
| 1594 | td->stat_io_bytes[ddir] = td->this_io_bytes[ddir]; |
| 1595 | } |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1596 | |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1597 | fio_gettime(&td->bw_sample_time, NULL); |
Jens Axboe | 3c39a37 | 2006-06-06 20:56:12 +0200 | [diff] [blame] | 1598 | } |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1599 | |
| 1600 | void add_iops_sample(struct thread_data *td, enum fio_ddir ddir, |
| 1601 | struct timeval *t) |
| 1602 | { |
| 1603 | struct thread_stat *ts = &td->ts; |
| 1604 | unsigned long spent, iops; |
| 1605 | |
| 1606 | if (!ddir_rw(ddir)) |
| 1607 | return; |
| 1608 | |
| 1609 | spent = mtime_since(&td->iops_sample_time, t); |
| 1610 | if (spent < td->o.iops_avg_time) |
| 1611 | return; |
| 1612 | |
Jens Axboe | 9602d8d | 2012-02-20 20:19:28 +0100 | [diff] [blame] | 1613 | /* |
| 1614 | * Compute both read and write rates for the interval. |
| 1615 | */ |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 1616 | for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) { |
Jens Axboe | 9602d8d | 2012-02-20 20:19:28 +0100 | [diff] [blame] | 1617 | uint64_t delta; |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1618 | |
Jens Axboe | 9602d8d | 2012-02-20 20:19:28 +0100 | [diff] [blame] | 1619 | delta = td->this_io_blocks[ddir] - td->stat_io_blocks[ddir]; |
| 1620 | if (!delta) |
| 1621 | continue; /* No entries for interval */ |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1622 | |
Jens Axboe | 9602d8d | 2012-02-20 20:19:28 +0100 | [diff] [blame] | 1623 | iops = (delta * 1000) / spent; |
| 1624 | add_stat_sample(&ts->iops_stat[ddir], iops); |
| 1625 | |
| 1626 | if (td->iops_log) |
| 1627 | add_log_sample(td, td->iops_log, iops, ddir, 0); |
| 1628 | |
Jens Axboe | 421f4a8 | 2012-02-28 08:20:26 +0100 | [diff] [blame] | 1629 | td->stat_io_blocks[ddir] = td->this_io_blocks[ddir]; |
Jens Axboe | 9602d8d | 2012-02-20 20:19:28 +0100 | [diff] [blame] | 1630 | } |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1631 | |
| 1632 | fio_gettime(&td->iops_sample_time, NULL); |
Jens Axboe | c8eeb9d | 2011-10-05 14:02:22 +0200 | [diff] [blame] | 1633 | } |