X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=steadystate.c;h=ee1c0e5b637d0512302ea96fb4e7f9263a4c5799;hb=5fff95436922873dd9ded8b21af7222689e2ec5d;hp=05ce029924170cce0bd594fdfd94811d888fccad;hpb=c8caba48e826fbc5f4e6ea62f67dceec6269b307;p=fio.git diff --git a/steadystate.c b/steadystate.c index 05ce0299..ee1c0e5b 100644 --- a/steadystate.c +++ b/steadystate.c @@ -2,10 +2,17 @@ #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)); @@ -16,8 +23,8 @@ static void steadystate_alloc(struct thread_data *td) void steadystate_setup(void) { - int i, prev_groupid; struct thread_data *td, *prev_td; + int i, prev_groupid; if (!steadystate_enabled) return; @@ -39,17 +46,15 @@ void steadystate_setup(void) } 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, @@ -345,6 +350,9 @@ uint64_t steadystate_bw_mean(struct thread_stat *ts) 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]; @@ -356,6 +364,9 @@ uint64_t steadystate_iops_mean(struct thread_stat *ts) 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];