Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Status and ETA code |
| 3 | */ |
| 4 | #include <unistd.h> |
| 5 | #include <fcntl.h> |
| 6 | #include <string.h> |
| 7 | |
| 8 | #include "fio.h" |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 9 | |
Jens Axboe | f9ce7c0 | 2014-06-16 14:42:05 -0600 | [diff] [blame] | 10 | static char __run_str[REAL_MAX_JOBS + 1]; |
| 11 | |
| 12 | /* |
| 13 | * Worst level condensing would be 1:4, so allow enough room for that |
| 14 | */ |
| 15 | static char run_str[(4 * REAL_MAX_JOBS) + 1]; |
| 16 | |
| 17 | static void update_condensed_str(char *run_str, char *run_str_condensed) |
| 18 | { |
| 19 | int i, ci, last, nr; |
| 20 | size_t len; |
| 21 | |
| 22 | len = strlen(run_str); |
| 23 | if (!len) |
| 24 | return; |
| 25 | |
| 26 | last = 0; |
| 27 | nr = 0; |
| 28 | ci = 0; |
| 29 | for (i = 0; i < len; i++) { |
| 30 | if (!last) { |
| 31 | new: |
| 32 | run_str_condensed[ci] = run_str[i]; |
| 33 | last = run_str[i]; |
| 34 | nr = 1; |
| 35 | ci++; |
| 36 | } else if (last == run_str[i]) { |
| 37 | nr++; |
| 38 | } else { |
Jens Axboe | cdd2bfa | 2014-06-17 09:22:34 -0600 | [diff] [blame] | 39 | ci += sprintf(&run_str_condensed[ci], "(%u),", nr); |
Jens Axboe | f9ce7c0 | 2014-06-16 14:42:05 -0600 | [diff] [blame] | 40 | goto new; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | if (nr) |
Jens Axboe | cdd2bfa | 2014-06-17 09:22:34 -0600 | [diff] [blame] | 45 | ci += sprintf(&run_str_condensed[ci], "(%u)", nr); |
Jens Axboe | f9ce7c0 | 2014-06-16 14:42:05 -0600 | [diff] [blame] | 46 | |
Jens Axboe | cdd2bfa | 2014-06-17 09:22:34 -0600 | [diff] [blame] | 47 | run_str_condensed[ci + 1] = '\0'; |
| 48 | } |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * Sets the status of the 'td' in the printed status map. |
| 52 | */ |
| 53 | static void check_str_update(struct thread_data *td) |
| 54 | { |
Jens Axboe | f9ce7c0 | 2014-06-16 14:42:05 -0600 | [diff] [blame] | 55 | char c = __run_str[td->thread_number - 1]; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 56 | |
| 57 | switch (td->runstate) { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 58 | case TD_REAPED: |
Jens Axboe | 4f7e57a | 2012-03-30 21:21:20 +0200 | [diff] [blame] | 59 | if (td->error) |
| 60 | c = 'X'; |
Jens Axboe | a5e371a | 2012-04-02 09:47:09 -0700 | [diff] [blame] | 61 | else if (td->sig) |
| 62 | c = 'K'; |
Jens Axboe | 4f7e57a | 2012-03-30 21:21:20 +0200 | [diff] [blame] | 63 | else |
| 64 | c = '_'; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 65 | break; |
| 66 | case TD_EXITED: |
| 67 | c = 'E'; |
| 68 | break; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 69 | case TD_RAMP: |
| 70 | c = '/'; |
| 71 | break; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 72 | case TD_RUNNING: |
| 73 | if (td_rw(td)) { |
Jens Axboe | e3b3f81 | 2011-09-01 09:58:11 -0600 | [diff] [blame] | 74 | if (td_random(td)) { |
| 75 | if (td->o.rwmix[DDIR_READ] == 100) |
| 76 | c = 'r'; |
| 77 | else if (td->o.rwmix[DDIR_WRITE] == 100) |
| 78 | c = 'w'; |
| 79 | else |
| 80 | c = 'm'; |
| 81 | } else { |
| 82 | if (td->o.rwmix[DDIR_READ] == 100) |
| 83 | c = 'R'; |
| 84 | else if (td->o.rwmix[DDIR_WRITE] == 100) |
| 85 | c = 'W'; |
| 86 | else |
| 87 | c = 'M'; |
| 88 | } |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 89 | } else if (td_read(td)) { |
| 90 | if (td_random(td)) |
| 91 | c = 'r'; |
| 92 | else |
| 93 | c = 'R'; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 94 | } else if (td_write(td)) { |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 95 | if (td_random(td)) |
| 96 | c = 'w'; |
| 97 | else |
| 98 | c = 'W'; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 99 | } else { |
| 100 | if (td_random(td)) |
| 101 | c = 'd'; |
| 102 | else |
| 103 | c = 'D'; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 104 | } |
| 105 | break; |
Jens Axboe | b0f6586 | 2009-05-20 11:52:15 +0200 | [diff] [blame] | 106 | case TD_PRE_READING: |
| 107 | c = 'p'; |
| 108 | break; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 109 | case TD_VERIFYING: |
| 110 | c = 'V'; |
| 111 | break; |
| 112 | case TD_FSYNCING: |
| 113 | c = 'F'; |
| 114 | break; |
Jens Axboe | 3d43405 | 2014-04-02 15:46:22 -0600 | [diff] [blame] | 115 | case TD_FINISHING: |
| 116 | c = 'f'; |
| 117 | break; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 118 | case TD_CREATED: |
| 119 | c = 'C'; |
| 120 | break; |
| 121 | case TD_INITIALIZED: |
Jens Axboe | 9c6f631 | 2012-11-07 09:15:45 +0100 | [diff] [blame] | 122 | case TD_SETTING_UP: |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 123 | c = 'I'; |
| 124 | break; |
| 125 | case TD_NOT_CREATED: |
| 126 | c = 'P'; |
| 127 | break; |
| 128 | default: |
| 129 | log_err("state %d\n", td->runstate); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 130 | } |
| 131 | |
Jens Axboe | f9ce7c0 | 2014-06-16 14:42:05 -0600 | [diff] [blame] | 132 | __run_str[td->thread_number - 1] = c; |
| 133 | update_condensed_str(__run_str, run_str); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* |
| 137 | * Convert seconds to a printable string. |
| 138 | */ |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 139 | void eta_to_str(char *str, unsigned long eta_sec) |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 140 | { |
| 141 | unsigned int d, h, m, s; |
Jens Axboe | 165faf1 | 2007-02-07 11:30:37 +0100 | [diff] [blame] | 142 | int disp_hour = 0; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 143 | |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 144 | s = eta_sec % 60; |
| 145 | eta_sec /= 60; |
| 146 | m = eta_sec % 60; |
| 147 | eta_sec /= 60; |
| 148 | h = eta_sec % 24; |
| 149 | eta_sec /= 24; |
| 150 | d = eta_sec; |
| 151 | |
Jens Axboe | 165faf1 | 2007-02-07 11:30:37 +0100 | [diff] [blame] | 152 | if (d) { |
| 153 | disp_hour = 1; |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 154 | str += sprintf(str, "%02ud:", d); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 155 | } |
Jens Axboe | 165faf1 | 2007-02-07 11:30:37 +0100 | [diff] [blame] | 156 | |
| 157 | if (h || disp_hour) |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 158 | str += sprintf(str, "%02uh:", h); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 159 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 160 | str += sprintf(str, "%02um:", m); |
| 161 | str += sprintf(str, "%02us", s); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | /* |
| 165 | * Best effort calculation of the estimated pending runtime of a job. |
| 166 | */ |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 167 | static int thread_eta(struct thread_data *td) |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 168 | { |
| 169 | unsigned long long bytes_total, bytes_done; |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 170 | unsigned long eta_sec = 0; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 171 | unsigned long elapsed; |
Jens Axboe | 0de5b26 | 2014-02-21 15:26:01 -0800 | [diff] [blame] | 172 | uint64_t timeout; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 173 | |
| 174 | elapsed = (mtime_since_now(&td->epoch) + 999) / 1000; |
Jens Axboe | 0de5b26 | 2014-02-21 15:26:01 -0800 | [diff] [blame] | 175 | timeout = td->o.timeout / 1000000UL; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 176 | |
| 177 | bytes_total = td->total_io_size; |
| 178 | |
Jens Axboe | 2e3bd4c | 2010-05-17 12:29:57 +0200 | [diff] [blame] | 179 | if (td->o.fill_device && td->o.size == -1ULL) { |
| 180 | if (!td->fill_device_size || td->fill_device_size == -1ULL) |
| 181 | return 0; |
| 182 | |
| 183 | bytes_total = td->fill_device_size; |
| 184 | } |
| 185 | |
Jens Axboe | 0d73a2f | 2013-02-07 12:54:10 +0100 | [diff] [blame] | 186 | if (td->o.zone_size && td->o.zone_skip && bytes_total) { |
| 187 | unsigned int nr_zones; |
| 188 | uint64_t zone_bytes; |
| 189 | |
| 190 | zone_bytes = bytes_total + td->o.zone_size + td->o.zone_skip; |
| 191 | nr_zones = (zone_bytes - 1) / (td->o.zone_size + td->o.zone_skip); |
| 192 | bytes_total -= nr_zones * td->o.zone_skip; |
| 193 | } |
| 194 | |
Jens Axboe | 74939e3 | 2006-10-19 20:37:12 +0200 | [diff] [blame] | 195 | /* |
Jens Axboe | 165eb05 | 2013-01-23 08:40:11 -0700 | [diff] [blame] | 196 | * if writing and verifying afterwards, bytes_total will be twice the |
| 197 | * size. In a mixed workload, verify phase will be the size of the |
| 198 | * first stage writes. |
Jens Axboe | 74939e3 | 2006-10-19 20:37:12 +0200 | [diff] [blame] | 199 | */ |
Jens Axboe | 0dd8377 | 2007-09-04 12:38:28 +0200 | [diff] [blame] | 200 | if (td->o.do_verify && td->o.verify && td_write(td)) { |
Jens Axboe | 165eb05 | 2013-01-23 08:40:11 -0700 | [diff] [blame] | 201 | if (td_rw(td)) { |
| 202 | unsigned int perc = 50; |
| 203 | |
| 204 | if (td->o.rwmix[DDIR_WRITE]) |
| 205 | perc = td->o.rwmix[DDIR_WRITE]; |
| 206 | |
| 207 | bytes_total += (bytes_total * perc) / 100; |
| 208 | } else |
Jens Axboe | 74939e3 | 2006-10-19 20:37:12 +0200 | [diff] [blame] | 209 | bytes_total <<= 1; |
| 210 | } |
| 211 | |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 212 | if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) { |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 213 | double perc, perc_t; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 214 | |
Jens Axboe | 342f4be | 2012-09-14 08:59:20 +0200 | [diff] [blame] | 215 | bytes_done = ddir_rw_sum(td->io_bytes); |
Jens Axboe | 476882d | 2014-04-14 09:45:19 -0600 | [diff] [blame] | 216 | |
| 217 | if (bytes_total) { |
| 218 | perc = (double) bytes_done / (double) bytes_total; |
| 219 | if (perc > 1.0) |
| 220 | perc = 1.0; |
| 221 | } else |
| 222 | perc = 0.0; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 223 | |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 224 | if (td->o.time_based) { |
Jens Axboe | 476882d | 2014-04-14 09:45:19 -0600 | [diff] [blame] | 225 | if (timeout) { |
| 226 | perc_t = (double) elapsed / (double) timeout; |
| 227 | if (perc_t < perc) |
| 228 | perc = perc_t; |
| 229 | } else { |
| 230 | /* |
| 231 | * Will never hit, we can't have time_based |
| 232 | * without a timeout set. |
| 233 | */ |
| 234 | perc = 0.0; |
| 235 | } |
Jens Axboe | cf4464c | 2007-04-17 20:14:42 +0200 | [diff] [blame] | 236 | } |
| 237 | |
Jens Axboe | 1e97cce | 2006-12-05 11:44:16 +0100 | [diff] [blame] | 238 | eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 239 | |
Jens Axboe | d3eeeab | 2008-04-06 12:19:05 +0200 | [diff] [blame] | 240 | if (td->o.timeout && |
Jens Axboe | 0de5b26 | 2014-02-21 15:26:01 -0800 | [diff] [blame] | 241 | eta_sec > (timeout + done_secs - elapsed)) |
| 242 | eta_sec = timeout + done_secs - elapsed; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 243 | } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 244 | || td->runstate == TD_INITIALIZED |
Jens Axboe | 714e85f | 2013-04-15 10:21:56 +0200 | [diff] [blame] | 245 | || td->runstate == TD_SETTING_UP |
Jens Axboe | b0f6586 | 2009-05-20 11:52:15 +0200 | [diff] [blame] | 246 | || td->runstate == TD_RAMP |
| 247 | || td->runstate == TD_PRE_READING) { |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 248 | int t_eta = 0, r_eta = 0; |
Jens Axboe | 342f4be | 2012-09-14 08:59:20 +0200 | [diff] [blame] | 249 | unsigned long long rate_bytes; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 250 | |
| 251 | /* |
| 252 | * We can only guess - assume it'll run the full timeout |
| 253 | * if given, otherwise assume it'll run at the specified rate. |
| 254 | */ |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 255 | if (td->o.timeout) { |
Jens Axboe | 0de5b26 | 2014-02-21 15:26:01 -0800 | [diff] [blame] | 256 | uint64_t timeout = td->o.timeout; |
| 257 | uint64_t start_delay = td->o.start_delay; |
| 258 | uint64_t ramp_time = td->o.ramp_time; |
| 259 | |
| 260 | t_eta = timeout + start_delay + ramp_time; |
| 261 | t_eta /= 1000000ULL; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 262 | |
| 263 | if (in_ramp_time(td)) { |
| 264 | unsigned long ramp_left; |
| 265 | |
Signed-off-by Steven Pratt | cda99fa | 2010-12-14 08:31:36 +0100 | [diff] [blame] | 266 | ramp_left = mtime_since_now(&td->epoch); |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 267 | ramp_left = (ramp_left + 999) / 1000; |
| 268 | if (ramp_left <= t_eta) |
| 269 | t_eta -= ramp_left; |
| 270 | } |
| 271 | } |
Jens Axboe | 342f4be | 2012-09-14 08:59:20 +0200 | [diff] [blame] | 272 | rate_bytes = ddir_rw_sum(td->o.rate); |
| 273 | if (rate_bytes) { |
| 274 | r_eta = (bytes_total / 1024) / rate_bytes; |
Jens Axboe | 0de5b26 | 2014-02-21 15:26:01 -0800 | [diff] [blame] | 275 | r_eta += (td->o.start_delay / 1000000ULL); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | if (r_eta && t_eta) |
| 279 | eta_sec = min(r_eta, t_eta); |
| 280 | else if (r_eta) |
| 281 | eta_sec = r_eta; |
| 282 | else if (t_eta) |
| 283 | eta_sec = t_eta; |
| 284 | else |
| 285 | eta_sec = 0; |
| 286 | } else { |
| 287 | /* |
| 288 | * thread is already done or waiting for fsync |
| 289 | */ |
| 290 | eta_sec = 0; |
| 291 | } |
| 292 | |
| 293 | return eta_sec; |
| 294 | } |
| 295 | |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 296 | static void calc_rate(int unified_rw_rep, unsigned long mtime, |
| 297 | unsigned long long *io_bytes, |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 298 | unsigned long long *prev_io_bytes, unsigned int *rate) |
| 299 | { |
Jens Axboe | b7f05eb | 2012-05-11 20:33:02 +0200 | [diff] [blame] | 300 | int i; |
| 301 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 302 | for (i = 0; i < DDIR_RWDIR_CNT; i++) { |
Jens Axboe | b7f05eb | 2012-05-11 20:33:02 +0200 | [diff] [blame] | 303 | unsigned long long diff; |
| 304 | |
| 305 | diff = io_bytes[i] - prev_io_bytes[i]; |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 306 | if (unified_rw_rep) { |
| 307 | rate[i] = 0; |
| 308 | rate[0] += ((1000 * diff) / mtime) / 1024; |
| 309 | } else |
| 310 | rate[i] = ((1000 * diff) / mtime) / 1024; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 311 | |
| 312 | prev_io_bytes[i] = io_bytes[i]; |
Jens Axboe | b7f05eb | 2012-05-11 20:33:02 +0200 | [diff] [blame] | 313 | } |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 314 | } |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 315 | |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 316 | static void calc_iops(int unified_rw_rep, unsigned long mtime, |
| 317 | unsigned long long *io_iops, |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 318 | unsigned long long *prev_io_iops, unsigned int *iops) |
| 319 | { |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 320 | int i; |
| 321 | |
| 322 | for (i = 0; i < DDIR_RWDIR_CNT; i++) { |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 323 | unsigned long long diff; |
| 324 | |
| 325 | diff = io_iops[i] - prev_io_iops[i]; |
| 326 | if (unified_rw_rep) { |
| 327 | iops[i] = 0; |
| 328 | iops[0] += (diff * 1000) / mtime; |
| 329 | } else |
| 330 | iops[i] = (diff * 1000) / mtime; |
| 331 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 332 | prev_io_iops[i] = io_iops[i]; |
| 333 | } |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 334 | } |
| 335 | |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 336 | /* |
| 337 | * Print status of the jobs we know about. This includes rate estimates, |
| 338 | * ETA, thread state, etc. |
| 339 | */ |
Jens Axboe | af9c9fb | 2011-10-09 21:54:10 +0200 | [diff] [blame] | 340 | int calc_thread_status(struct jobs_eta *je, int force) |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 341 | { |
Jens Axboe | 34572e2 | 2006-10-20 09:33:18 +0200 | [diff] [blame] | 342 | struct thread_data *td; |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 343 | int i, unified_rw_rep; |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 344 | unsigned long rate_time, disp_time, bw_avg_time, *eta_secs; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 345 | unsigned long long io_bytes[DDIR_RWDIR_CNT]; |
| 346 | unsigned long long io_iops[DDIR_RWDIR_CNT]; |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 347 | struct timeval now; |
| 348 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 349 | static unsigned long long rate_io_bytes[DDIR_RWDIR_CNT]; |
| 350 | static unsigned long long disp_io_bytes[DDIR_RWDIR_CNT]; |
| 351 | static unsigned long long disp_io_iops[DDIR_RWDIR_CNT]; |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 352 | static struct timeval rate_prev_time, disp_prev_time; |
Jens Axboe | 6043c57 | 2006-11-03 11:37:47 +0100 | [diff] [blame] | 353 | |
Jens Axboe | af9c9fb | 2011-10-09 21:54:10 +0200 | [diff] [blame] | 354 | if (!force) { |
Jens Axboe | fc47559 | 2013-01-31 15:24:34 +0100 | [diff] [blame] | 355 | if (output_format != FIO_OUTPUT_NORMAL && |
| 356 | f_out == stdout) |
Jens Axboe | f3afa57 | 2012-09-17 13:34:16 +0200 | [diff] [blame] | 357 | return 0; |
| 358 | if (temp_stall_ts || eta_print == FIO_ETA_NEVER) |
Jens Axboe | af9c9fb | 2011-10-09 21:54:10 +0200 | [diff] [blame] | 359 | return 0; |
Aaron Carroll | e592a06 | 2007-09-14 09:49:41 +0200 | [diff] [blame] | 360 | |
Jens Axboe | af9c9fb | 2011-10-09 21:54:10 +0200 | [diff] [blame] | 361 | if (!isatty(STDOUT_FILENO) && (eta_print != FIO_ETA_ALWAYS)) |
| 362 | return 0; |
| 363 | } |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 364 | |
Jens Axboe | 342f4be | 2012-09-14 08:59:20 +0200 | [diff] [blame] | 365 | if (!ddir_rw_sum(rate_io_bytes)) |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 366 | fill_start_time(&rate_prev_time); |
Jens Axboe | 342f4be | 2012-09-14 08:59:20 +0200 | [diff] [blame] | 367 | if (!ddir_rw_sum(disp_io_bytes)) |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 368 | fill_start_time(&disp_prev_time); |
Jens Axboe | 6043c57 | 2006-11-03 11:37:47 +0100 | [diff] [blame] | 369 | |
Jens Axboe | d3eeeab | 2008-04-06 12:19:05 +0200 | [diff] [blame] | 370 | eta_secs = malloc(thread_number * sizeof(unsigned long)); |
| 371 | memset(eta_secs, 0, thread_number * sizeof(unsigned long)); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 372 | |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 373 | je->elapsed_sec = (mtime_since_genesis() + 999) / 1000; |
| 374 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 375 | io_bytes[DDIR_READ] = io_bytes[DDIR_WRITE] = io_bytes[DDIR_TRIM] = 0; |
| 376 | io_iops[DDIR_READ] = io_iops[DDIR_WRITE] = io_iops[DDIR_TRIM] = 0; |
Jens Axboe | bb3884d | 2007-01-17 17:23:11 +1100 | [diff] [blame] | 377 | bw_avg_time = ULONG_MAX; |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 378 | unified_rw_rep = 0; |
Jens Axboe | 34572e2 | 2006-10-20 09:33:18 +0200 | [diff] [blame] | 379 | for_each_td(td, i) { |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 380 | unified_rw_rep += td->o.unified_rw_rep; |
Jens Axboe | b7f05eb | 2012-05-11 20:33:02 +0200 | [diff] [blame] | 381 | if (is_power_of_2(td->o.kb_base)) |
| 382 | je->is_pow2 = 1; |
Steven Noonan | ad705bc | 2013-04-08 15:05:25 -0700 | [diff] [blame] | 383 | je->unit_base = td->o.unit_base; |
Jens Axboe | 2dc1bbe | 2007-03-15 15:01:33 +0100 | [diff] [blame] | 384 | if (td->o.bw_avg_time < bw_avg_time) |
| 385 | bw_avg_time = td->o.bw_avg_time; |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 386 | if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING |
Jens Axboe | b0f6586 | 2009-05-20 11:52:15 +0200 | [diff] [blame] | 387 | || td->runstate == TD_FSYNCING |
Jens Axboe | 3d43405 | 2014-04-02 15:46:22 -0600 | [diff] [blame] | 388 | || td->runstate == TD_PRE_READING |
| 389 | || td->runstate == TD_FINISHING) { |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 390 | je->nr_running++; |
Jens Axboe | 242c38d | 2012-08-20 14:44:22 +0200 | [diff] [blame] | 391 | if (td_read(td)) { |
Jens Axboe | c2e9cc4 | 2012-08-21 15:34:13 +0200 | [diff] [blame] | 392 | je->t_rate[0] += td->o.rate[DDIR_READ]; |
| 393 | je->t_iops[0] += td->o.rate_iops[DDIR_READ]; |
| 394 | je->m_rate[0] += td->o.ratemin[DDIR_READ]; |
| 395 | je->m_iops[0] += td->o.rate_iops_min[DDIR_READ]; |
Jens Axboe | 242c38d | 2012-08-20 14:44:22 +0200 | [diff] [blame] | 396 | } |
| 397 | if (td_write(td)) { |
Jens Axboe | c2e9cc4 | 2012-08-21 15:34:13 +0200 | [diff] [blame] | 398 | je->t_rate[1] += td->o.rate[DDIR_WRITE]; |
| 399 | je->t_iops[1] += td->o.rate_iops[DDIR_WRITE]; |
| 400 | je->m_rate[1] += td->o.ratemin[DDIR_WRITE]; |
| 401 | je->m_iops[1] += td->o.rate_iops_min[DDIR_WRITE]; |
Jens Axboe | 242c38d | 2012-08-20 14:44:22 +0200 | [diff] [blame] | 402 | } |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 403 | if (td_trim(td)) { |
Jens Axboe | d79db12 | 2012-09-24 08:51:24 +0200 | [diff] [blame] | 404 | je->t_rate[2] += td->o.rate[DDIR_TRIM]; |
| 405 | je->t_iops[2] += td->o.rate_iops[DDIR_TRIM]; |
| 406 | je->m_rate[2] += td->o.ratemin[DDIR_TRIM]; |
| 407 | je->m_iops[2] += td->o.rate_iops_min[DDIR_TRIM]; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 408 | } |
| 409 | |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 410 | je->files_open += td->nr_open_files; |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 411 | } else if (td->runstate == TD_RAMP) { |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 412 | je->nr_running++; |
| 413 | je->nr_ramp++; |
Jens Axboe | 714e85f | 2013-04-15 10:21:56 +0200 | [diff] [blame] | 414 | } else if (td->runstate == TD_SETTING_UP) { |
Jens Axboe | 9c6f631 | 2012-11-07 09:15:45 +0100 | [diff] [blame] | 415 | je->nr_running++; |
Jens Axboe | 714e85f | 2013-04-15 10:21:56 +0200 | [diff] [blame] | 416 | je->nr_setting_up++; |
| 417 | } else if (td->runstate < TD_RUNNING) |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 418 | je->nr_pending++; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 419 | |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 420 | if (je->elapsed_sec >= 3) |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 421 | eta_secs[i] = thread_eta(td); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 422 | else |
| 423 | eta_secs[i] = INT_MAX; |
| 424 | |
| 425 | check_str_update(td); |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 426 | |
Jens Axboe | 714e85f | 2013-04-15 10:21:56 +0200 | [diff] [blame] | 427 | if (td->runstate > TD_SETTING_UP) { |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 428 | int ddir; |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 429 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 430 | for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) { |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 431 | if (unified_rw_rep) { |
| 432 | io_bytes[0] += td->io_bytes[ddir]; |
| 433 | io_iops[0] += td->io_blocks[ddir]; |
| 434 | } else { |
| 435 | io_bytes[ddir] += td->io_bytes[ddir]; |
| 436 | io_iops[ddir] += td->io_blocks[ddir]; |
| 437 | } |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 438 | } |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 439 | } |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | if (exitall_on_terminate) |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 443 | je->eta_sec = INT_MAX; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 444 | else |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 445 | je->eta_sec = 0; |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 446 | |
Jens Axboe | 34572e2 | 2006-10-20 09:33:18 +0200 | [diff] [blame] | 447 | for_each_td(td, i) { |
Shaozhi Shawn Ye | 9c5a385 | 2008-09-10 09:09:37 +0200 | [diff] [blame] | 448 | if (exitall_on_terminate) { |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 449 | if (eta_secs[i] < je->eta_sec) |
| 450 | je->eta_sec = eta_secs[i]; |
Shaozhi Shawn Ye | 9c5a385 | 2008-09-10 09:09:37 +0200 | [diff] [blame] | 451 | } else { |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 452 | if (eta_secs[i] > je->eta_sec) |
| 453 | je->eta_sec = eta_secs[i]; |
Shaozhi Shawn Ye | 9c5a385 | 2008-09-10 09:09:37 +0200 | [diff] [blame] | 454 | } |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 455 | } |
| 456 | |
Jens Axboe | eecf272 | 2006-10-20 14:00:36 +0200 | [diff] [blame] | 457 | free(eta_secs); |
| 458 | |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 459 | fio_gettime(&now, NULL); |
| 460 | rate_time = mtime_since(&rate_prev_time, &now); |
| 461 | |
Jens Axboe | b29ee5b | 2008-09-11 10:17:26 +0200 | [diff] [blame] | 462 | if (write_bw_log && rate_time > bw_avg_time && !in_ramp_time(td)) { |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 463 | calc_rate(unified_rw_rep, rate_time, io_bytes, rate_io_bytes, |
| 464 | je->rate); |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 465 | memcpy(&rate_prev_time, &now, sizeof(now)); |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 466 | add_agg_sample(je->rate[DDIR_READ], DDIR_READ, 0); |
| 467 | add_agg_sample(je->rate[DDIR_WRITE], DDIR_WRITE, 0); |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 468 | add_agg_sample(je->rate[DDIR_TRIM], DDIR_TRIM, 0); |
Jens Axboe | 6043c57 | 2006-11-03 11:37:47 +0100 | [diff] [blame] | 469 | } |
| 470 | |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 471 | disp_time = mtime_since(&disp_prev_time, &now); |
Jens Axboe | a5b01f1 | 2010-11-11 09:19:49 +0100 | [diff] [blame] | 472 | |
| 473 | /* |
| 474 | * Allow a little slack, the target is to print it every 1000 msecs |
| 475 | */ |
Jens Axboe | af9c9fb | 2011-10-09 21:54:10 +0200 | [diff] [blame] | 476 | if (!force && disp_time < 900) |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 477 | return 0; |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 478 | |
Jens Axboe | 771e58b | 2013-01-30 12:56:23 +0100 | [diff] [blame] | 479 | calc_rate(unified_rw_rep, disp_time, io_bytes, disp_io_bytes, je->rate); |
| 480 | calc_iops(unified_rw_rep, disp_time, io_iops, disp_io_iops, je->iops); |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 481 | |
Jens Axboe | 46fda8d | 2007-02-11 00:49:30 +0100 | [diff] [blame] | 482 | memcpy(&disp_prev_time, &now, sizeof(now)); |
| 483 | |
Jens Axboe | af9c9fb | 2011-10-09 21:54:10 +0200 | [diff] [blame] | 484 | if (!force && !je->nr_running && !je->nr_pending) |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 485 | return 0; |
| 486 | |
Jens Axboe | 1d1f45a | 2011-10-03 19:44:41 +0200 | [diff] [blame] | 487 | je->nr_threads = thread_number; |
Jens Axboe | cdd2bfa | 2014-06-17 09:22:34 -0600 | [diff] [blame] | 488 | update_condensed_str(__run_str, run_str); |
| 489 | memcpy(je->run_str, run_str, strlen(run_str)); |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 490 | return 1; |
| 491 | } |
| 492 | |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 493 | void display_thread_status(struct jobs_eta *je) |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 494 | { |
Jens Axboe | e382e66 | 2013-02-22 20:48:56 +0100 | [diff] [blame] | 495 | static struct timeval disp_eta_new_line; |
| 496 | static int eta_new_line_init, eta_new_line_pending; |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 497 | static int linelen_last; |
| 498 | static int eta_good; |
Jens Axboe | 79074e7 | 2012-04-18 20:39:48 +0200 | [diff] [blame] | 499 | char output[REAL_MAX_JOBS + 512], *p = output; |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 500 | char eta_str[128]; |
| 501 | double perc = 0.0; |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 502 | |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 503 | if (je->eta_sec != INT_MAX && je->elapsed_sec) { |
| 504 | perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec); |
| 505 | eta_to_str(eta_str, je->eta_sec); |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 506 | } |
| 507 | |
Jens Axboe | e382e66 | 2013-02-22 20:48:56 +0100 | [diff] [blame] | 508 | if (eta_new_line_pending) { |
| 509 | eta_new_line_pending = 0; |
| 510 | p += sprintf(p, "\n"); |
| 511 | } |
| 512 | |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 513 | p += sprintf(p, "Jobs: %d (f=%d)", je->nr_running, je->files_open); |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 514 | if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) { |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 515 | char *tr, *mr; |
| 516 | |
Jens Axboe | 22f8045 | 2013-04-09 20:29:16 +0200 | [diff] [blame] | 517 | mr = num2str(je->m_rate[0] + je->m_rate[1], 4, 0, je->is_pow2, 8); |
| 518 | tr = num2str(je->t_rate[0] + je->t_rate[1], 4, 0, je->is_pow2, 8); |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 519 | p += sprintf(p, ", CR=%s/%s KB/s", tr, mr); |
Jens Axboe | 581e714 | 2009-06-09 12:47:16 +0200 | [diff] [blame] | 520 | free(tr); |
| 521 | free(mr); |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 522 | } else if (je->m_iops[0] || je->m_iops[1] || je->t_iops[0] || je->t_iops[1]) { |
| 523 | p += sprintf(p, ", CR=%d/%d IOPS", |
| 524 | je->t_iops[0] + je->t_iops[1], |
Jens Axboe | 88e4bea | 2012-08-21 15:34:36 +0200 | [diff] [blame] | 525 | je->m_iops[0] + je->m_iops[1]); |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 526 | } |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 527 | if (je->eta_sec != INT_MAX && je->nr_running) { |
Jens Axboe | 0721d11 | 2008-06-05 09:03:05 +0200 | [diff] [blame] | 528 | char perc_str[32]; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 529 | char *iops_str[DDIR_RWDIR_CNT]; |
| 530 | char *rate_str[DDIR_RWDIR_CNT]; |
Jens Axboe | 79074e7 | 2012-04-18 20:39:48 +0200 | [diff] [blame] | 531 | size_t left; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 532 | int l; |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 533 | int ddir; |
Jens Axboe | 5ec10ea | 2008-03-06 15:42:00 +0100 | [diff] [blame] | 534 | |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 535 | if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running) |
Jens Axboe | cac58fd | 2008-06-06 01:17:03 +0200 | [diff] [blame] | 536 | strcpy(perc_str, "-.-% done"); |
| 537 | else { |
Jens Axboe | 714e85f | 2013-04-15 10:21:56 +0200 | [diff] [blame] | 538 | double mult = 100.0; |
| 539 | |
| 540 | if (je->nr_setting_up && je->nr_running) |
| 541 | mult *= (1.0 - (double) je->nr_setting_up / (double) je->nr_running); |
| 542 | |
Jens Axboe | cac58fd | 2008-06-06 01:17:03 +0200 | [diff] [blame] | 543 | eta_good = 1; |
Jens Axboe | 714e85f | 2013-04-15 10:21:56 +0200 | [diff] [blame] | 544 | perc *= mult; |
Jens Axboe | 0721d11 | 2008-06-05 09:03:05 +0200 | [diff] [blame] | 545 | sprintf(perc_str, "%3.1f%% done", perc); |
Jens Axboe | cac58fd | 2008-06-06 01:17:03 +0200 | [diff] [blame] | 546 | } |
Jens Axboe | 0721d11 | 2008-06-05 09:03:05 +0200 | [diff] [blame] | 547 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 548 | for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) { |
| 549 | rate_str[ddir] = num2str(je->rate[ddir], 5, |
Steven Noonan | ad705bc | 2013-04-08 15:05:25 -0700 | [diff] [blame] | 550 | 1024, je->is_pow2, je->unit_base); |
Steven Noonan | 73798eb | 2013-04-05 16:57:38 -0700 | [diff] [blame] | 551 | iops_str[ddir] = num2str(je->iops[ddir], 4, 1, 0, 0); |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 552 | } |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 553 | |
Jens Axboe | 79074e7 | 2012-04-18 20:39:48 +0200 | [diff] [blame] | 554 | left = sizeof(output) - (p - output) - 1; |
| 555 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 556 | l = snprintf(p, left, ": [%s] [%s] [%s/%s/%s /s] [%s/%s/%s iops] [eta %s]", |
| 557 | je->run_str, perc_str, rate_str[DDIR_READ], |
| 558 | rate_str[DDIR_WRITE], rate_str[DDIR_TRIM], |
| 559 | iops_str[DDIR_READ], iops_str[DDIR_WRITE], |
| 560 | iops_str[DDIR_TRIM], eta_str); |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 561 | p += l; |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 562 | if (l >= 0 && l < linelen_last) |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 563 | p += sprintf(p, "%*s", linelen_last - l, ""); |
Jens Axboe | adb02ba | 2009-06-03 10:47:44 +0200 | [diff] [blame] | 564 | linelen_last = l; |
Jens Axboe | d1bd721 | 2009-06-03 10:53:45 +0200 | [diff] [blame] | 565 | |
Shaohua Li | 6eaf09d | 2012-09-14 08:49:43 +0200 | [diff] [blame] | 566 | for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) { |
| 567 | free(rate_str[ddir]); |
| 568 | free(iops_str[ddir]); |
| 569 | } |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 570 | } |
Jens Axboe | 37db14f | 2011-09-30 17:00:42 -0600 | [diff] [blame] | 571 | p += sprintf(p, "\r"); |
| 572 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 573 | printf("%s", output); |
Jens Axboe | e382e66 | 2013-02-22 20:48:56 +0100 | [diff] [blame] | 574 | |
| 575 | if (!eta_new_line_init) { |
| 576 | fio_gettime(&disp_eta_new_line, NULL); |
| 577 | eta_new_line_init = 1; |
| 578 | } else if (eta_new_line && |
| 579 | mtime_since_now(&disp_eta_new_line) > eta_new_line * 1000) { |
| 580 | fio_gettime(&disp_eta_new_line, NULL); |
| 581 | eta_new_line_pending = 1; |
| 582 | } |
| 583 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 584 | fflush(stdout); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 585 | } |
| 586 | |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 587 | void print_thread_status(void) |
| 588 | { |
Jens Axboe | 1d1f45a | 2011-10-03 19:44:41 +0200 | [diff] [blame] | 589 | struct jobs_eta *je; |
Jens Axboe | b814fb2 | 2011-10-12 09:20:34 +0200 | [diff] [blame] | 590 | size_t size; |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 591 | |
Jens Axboe | b814fb2 | 2011-10-12 09:20:34 +0200 | [diff] [blame] | 592 | if (!thread_number) |
| 593 | return; |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 594 | |
Jens Axboe | b814fb2 | 2011-10-12 09:20:34 +0200 | [diff] [blame] | 595 | size = sizeof(*je) + thread_number * sizeof(char) + 1; |
| 596 | je = malloc(size); |
| 597 | memset(je, 0, size); |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 598 | |
Jens Axboe | af9c9fb | 2011-10-09 21:54:10 +0200 | [diff] [blame] | 599 | if (calc_thread_status(je, 0)) |
Jens Axboe | 1d1f45a | 2011-10-03 19:44:41 +0200 | [diff] [blame] | 600 | display_thread_status(je); |
| 601 | |
| 602 | free(je); |
Jens Axboe | cf451d1 | 2011-10-03 16:48:30 +0200 | [diff] [blame] | 603 | } |
Jens Axboe | b75a394 | 2011-10-03 16:03:43 +0200 | [diff] [blame] | 604 | |
Jens Axboe | 2b13e71 | 2011-01-19 14:04:16 -0700 | [diff] [blame] | 605 | void print_status_init(int thr_number) |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 606 | { |
Jens Axboe | f9ce7c0 | 2014-06-16 14:42:05 -0600 | [diff] [blame] | 607 | __run_str[thr_number] = 'P'; |
| 608 | update_condensed_str(__run_str, run_str); |
Jens Axboe | 263e529 | 2006-10-18 15:37:01 +0200 | [diff] [blame] | 609 | } |