#include "fio.h"
#include "steadystate.h"
-#include "helper_thread.h"
bool steadystate_enabled = false;
+void steadystate_free(struct thread_data *td)
+{
+ free(td->ss.iops_data);
+ free(td->ss.bw_data);
+ td->ss.iops_data = NULL;
+ td->ss.bw_data = NULL;
+}
+
static void steadystate_alloc(struct thread_data *td)
{
td->ss.bw_data = calloc(td->ss.dur, sizeof(uint64_t));
void steadystate_setup(void)
{
- int i, prev_groupid;
struct thread_data *td, *prev_td;
+ int i, prev_groupid;
if (!steadystate_enabled)
return;
}
if (prev_groupid != td->groupid) {
- if (prev_td != NULL) {
+ if (prev_td)
steadystate_alloc(prev_td);
- }
prev_groupid = td->groupid;
}
prev_td = td;
}
- if (prev_td != NULL && prev_td->o.group_reporting) {
+ if (prev_td && prev_td->o.group_reporting)
steadystate_alloc(prev_td);
- }
}
static bool steadystate_slope(uint64_t iops, uint64_t bw,
return false;
}
-void steadystate_check(void)
+int steadystate_check(void)
{
int i, j, ddir, prev_groupid, group_ramp_time_over = 0;
unsigned long rate_time;
prev_groupid = -1;
for_each_td(td, i) {
+ const bool needs_lock = td_async_processing(td);
struct steadystate_data *ss = &td->ss;
if (!ss->dur || td->runstate <= TD_SETTING_UP ||
ss->state |= FIO_SS_RAMP_OVER;
}
- td_io_u_lock(td);
+ if (needs_lock)
+ __td_io_u_lock(td);
+
for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) {
td_iops += td->io_blocks[ddir];
td_bytes += td->io_bytes[ddir];
}
- td_io_u_unlock(td);
+
+ if (needs_lock)
+ __td_io_u_unlock(td);
rate_time = mtime_since(&ss->prev_time, &now);
memcpy(&ss->prev_time, &now, sizeof(now));
}
}
}
+ return 0;
}
int td_steadystate_init(struct thread_data *td)
int i;
uint64_t sum;
+ if (!ts->ss_dur)
+ return 0;
+
for (i = 0, sum = 0; i < ts->ss_dur; i++)
sum += ts->ss_bw_data[i];
int i;
uint64_t sum;
+ if (!ts->ss_dur)
+ return 0;
+
for (i = 0, sum = 0; i < ts->ss_dur; i++)
sum += ts->ss_iops_data[i];