X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=eta.c;h=3c1aeeee98cbd0cb0d3dcbe35f7c1287d7a39450;hp=db045cb230338096c90d7ea2bb93fb13014f37cd;hb=b678fac65b13dabd0f78ceb338547b9acb5a4f2d;hpb=95c2f38e08f135571a86f46d14291a4e0ff1c1d7 diff --git a/eta.c b/eta.c index db045cb2..3c1aeeee 100644 --- a/eta.c +++ b/eta.c @@ -250,7 +250,7 @@ static unsigned long thread_eta(struct thread_data *td) t_eta = __timeout + start_delay + ramp_time; t_eta /= 1000000ULL; - if (in_ramp_time(td)) { + if ((td->runstate == TD_RAMP) && in_ramp_time(td)) { unsigned long ramp_left; ramp_left = mtime_since_now(&td->epoch); @@ -337,7 +337,7 @@ static void calc_iops(int unified_rw_rep, unsigned long mtime, * Print status of the jobs we know about. This includes rate estimates, * ETA, thread state, etc. */ -int calc_thread_status(struct jobs_eta *je, int force) +bool calc_thread_status(struct jobs_eta *je, int force) { struct thread_data *td; int i, unified_rw_rep; @@ -352,14 +352,14 @@ int calc_thread_status(struct jobs_eta *je, int force) static struct timeval rate_prev_time, disp_prev_time; if (!force) { - if (output_format != FIO_OUTPUT_NORMAL && + if (!(output_format & FIO_OUTPUT_NORMAL) && f_out == stdout) - return 0; + return false; if (temp_stall_ts || eta_print == FIO_ETA_NEVER) - return 0; + return false; if (!isatty(STDOUT_FILENO) && (eta_print != FIO_ETA_ALWAYS)) - return 0; + return false; } if (!ddir_rw_sum(rate_io_bytes)) @@ -438,19 +438,25 @@ int calc_thread_status(struct jobs_eta *je, int force) } } - if (exitall_on_terminate) + if (exitall_on_terminate) { je->eta_sec = INT_MAX; - else - je->eta_sec = 0; - - for_each_td(td, i) { - if (exitall_on_terminate) { + for_each_td(td, i) { if (eta_secs[i] < je->eta_sec) je->eta_sec = eta_secs[i]; - } else { - if (eta_secs[i] > je->eta_sec) - je->eta_sec = eta_secs[i]; } + } else { + unsigned long eta_stone = 0; + + je->eta_sec = 0; + for_each_td(td, i) { + if ((td->runstate == TD_NOT_CREATED) && td->o.stonewall) + eta_stone += eta_secs[i]; + else { + if (eta_secs[i] > je->eta_sec) + je->eta_sec = eta_secs[i]; + } + } + je->eta_sec += eta_stone; } free(eta_secs); @@ -473,7 +479,7 @@ int calc_thread_status(struct jobs_eta *je, int force) * Allow a little slack, the target is to print it every 1000 msecs */ if (!force && disp_time < 900) - return 0; + return false; calc_rate(unified_rw_rep, disp_time, io_bytes, disp_io_bytes, je->rate); calc_iops(unified_rw_rep, disp_time, io_iops, disp_io_iops, je->iops); @@ -481,12 +487,12 @@ int calc_thread_status(struct jobs_eta *je, int force) memcpy(&disp_prev_time, &now, sizeof(now)); if (!force && !je->nr_running && !je->nr_pending) - return 0; + return false; je->nr_threads = thread_number; update_condensed_str(__run_str, run_str); memcpy(je->run_str, run_str, strlen(run_str)); - return 1; + return true; } void display_thread_status(struct jobs_eta *je) @@ -583,14 +589,14 @@ void display_thread_status(struct jobs_eta *je) fflush(stdout); } -struct jobs_eta *get_jobs_eta(int force, size_t *size) +struct jobs_eta *get_jobs_eta(bool force, size_t *size) { struct jobs_eta *je; if (!thread_number) return NULL; - *size = sizeof(*je) + THREAD_RUNSTR_SZ; + *size = sizeof(*je) + THREAD_RUNSTR_SZ + 8; je = malloc(*size); if (!je) return NULL; @@ -610,7 +616,7 @@ void print_thread_status(void) struct jobs_eta *je; size_t size; - je = get_jobs_eta(0, &size); + je = get_jobs_eta(false, &size); if (je) display_thread_status(je);