steadystate: cleanups
[fio.git] / init.c
diff --git a/init.c b/init.c
index a1a008797d4a9eead366f304388e665eeb98a4ca..9113865027528f56b1d546c2f29a031c011943db 100644 (file)
--- a/init.c
+++ b/init.c
@@ -25,6 +25,7 @@
 #include "server.h"
 #include "idletime.h"
 #include "filelock.h"
+#include "steadystate.h"
 
 #include "oslib/getopt.h"
 #include "oslib/strcasestr.h"
@@ -1577,6 +1578,46 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                        log_info("...\n");
        }
 
+       if (o->ss_dur) {
+               steadystate = true;
+               o->ss_dur /= 1000000L;
+
+               /* put all steady state info in one place */
+               td->ss.dur = o->ss_dur;
+               td->ss.limit = o->ss_limit.u.f;
+               td->ss.ramp_time = o->ss_ramp_time;
+               td->ss.pct = o->ss_pct;
+
+               if (steadystate_check_slope(o))
+                       td->ss.check_slope = true;
+               else
+                       td->ss.check_slope = false;
+
+               if (o->ss == FIO_STEADYSTATE_IOPS || o->ss == FIO_STEADYSTATE_IOPS_SLOPE)
+                       td->ss.check_iops = true;
+               else
+                       td->ss.check_iops = false;
+
+               td->ss.bw_data = NULL;
+               td->ss.iops_data = NULL;
+               td->ss.ramp_time_over = (td->ss.ramp_time == 0);
+               td->ss.attained = 0;
+               td->ss.last_in_group = 0;
+               td->ss.head = 0;
+               td->ss.tail = 0;
+               td->ss.sum_x = o->ss_dur * (o->ss_dur - 1) / 2;
+               td->ss.sum_x_sq = (o->ss_dur - 1) * (o->ss_dur) * (2*o->ss_dur - 1) / 6;
+               td->ss.prev_bytes = 0;
+               td->ss.prev_iops = 0;
+               td->ss.sum_y = 0;
+               td->ss.oldest_y = 0;
+               td->ss.criterion = 0.0;
+               td->ss.slope = 0.0;
+               td->ss.deviation = 0.0;
+               td->ts.ss = &td->ss;
+       } else
+               td->ts.ss = NULL;
+
        /*
         * recurse add identical jobs, clear numjobs and stonewall options
         * as they don't apply to sub-jobs
@@ -1592,6 +1633,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                td_new->o.stonewall = 0;
                td_new->o.new_group = 0;
                td_new->subjob_number = numjobs;
+               td_new->o.ss_dur = o->ss_dur * 1000000l;
+               td_new->o.ss_limit = o->ss_limit;
 
                if (file_alloced) {
                        if (td_new->files) {
@@ -2134,6 +2177,14 @@ struct debug_level debug_levels[] = {
          .help = "Log compression logging",
          .shift = FD_COMPRESS,
        },
+       { .name = "steadystate",
+         .help = "Steady state detection logging",
+         .shift = FD_STEADYSTATE,
+       },
+       { .name = "helperthread",
+         .help = "Helper thread logging",
+         .shift = FD_HELPERTHREAD,
+       },
        { .name = NULL, },
 };