steadystate: make flags conform to usual fio standard
authorJens Axboe <axboe@kernel.dk>
Thu, 30 Nov 2017 23:43:18 +0000 (16:43 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 30 Nov 2017 23:43:18 +0000 (16:43 -0700)
__VAL are usually bit shift values, with VAL being the proper
mask. For some reason, the steadystate code uses both as
masks, fix that up.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
options.c
server.c
stat.c
steadystate.c
steadystate.h

index 5466265..3b54bfd 100644 (file)
--- a/client.c
+++ b/client.c
@@ -961,7 +961,7 @@ static void convert_ts(struct thread_stat *dst, struct thread_stat *src)
        dst->ss_deviation.u.f   = fio_uint64_to_double(le64_to_cpu(src->ss_deviation.u.i));
        dst->ss_criterion.u.f   = fio_uint64_to_double(le64_to_cpu(src->ss_criterion.u.i));
 
-       if (dst->ss_state & __FIO_SS_DATA) {
+       if (dst->ss_state & FIO_SS_DATA) {
                for (i = 0; i < dst->ss_dur; i++ ) {
                        dst->ss_iops_data[i] = le64_to_cpu(src->ss_iops_data[i]);
                        dst->ss_bw_data[i] = le64_to_cpu(src->ss_bw_data[i]);
@@ -1691,7 +1691,7 @@ int fio_handle_client(struct fio_client *client)
                struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
 
                dprint(FD_NET, "client: ts->ss_state = %u\n", (unsigned int) le32_to_cpu(p->ts.ss_state));
-               if (le32_to_cpu(p->ts.ss_state) & __FIO_SS_DATA) {
+               if (le32_to_cpu(p->ts.ss_state) & FIO_SS_DATA) {
                        dprint(FD_NET, "client: received steadystate ring buffers\n");
 
                        size = le64_to_cpu(p->ts.ss_dur);
index a224e7b..9e3e960 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1127,9 +1127,9 @@ static int str_steadystate_cb(void *data, const char *str)
                if (parse_dryrun())
                        return 0;
 
-               td->o.ss_state |= __FIO_SS_PCT;
+               td->o.ss_state |= FIO_SS_PCT;
                td->o.ss_limit.u.f = val;
-       } else if (td->o.ss_state & __FIO_SS_IOPS) {
+       } else if (td->o.ss_state & FIO_SS_IOPS) {
                if (!str_to_float(nr, &val, 0)) {
                        log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
                        free(nr);
index 0323125..76d662d 100644 (file)
--- a/server.c
+++ b/server.c
@@ -1556,7 +1556,7 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs)
        convert_gs(&p.rs, rs);
 
        dprint(FD_NET, "ts->ss_state = %d\n", ts->ss_state);
-       if (ts->ss_state & __FIO_SS_DATA) {
+       if (ts->ss_state & FIO_SS_DATA) {
                dprint(FD_NET, "server sending steadystate ring buffers\n");
 
                ss_buf = malloc(sizeof(p) + 2*ts->ss_dur*sizeof(uint64_t));
diff --git a/stat.c b/stat.c
index 48d8e7d..863aa45 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -743,12 +743,12 @@ static void show_ss_normal(struct thread_stat *ts, struct buf_output *out)
        p2 = num2str(iops_mean, ts->sig_figs, 1, 0, N2S_NONE);
 
        log_buf(out, "  steadystate  : attained=%s, bw=%s (%s), iops=%s, %s%s=%.3f%s\n",
-               ts->ss_state & __FIO_SS_ATTAINED ? "yes" : "no",
+               ts->ss_state & FIO_SS_ATTAINED ? "yes" : "no",
                p1, p1alt, p2,
-               ts->ss_state & __FIO_SS_IOPS ? "iops" : "bw",
-               ts->ss_state & __FIO_SS_SLOPE ? " slope": " mean dev",
+               ts->ss_state & FIO_SS_IOPS ? "iops" : "bw",
+               ts->ss_state & FIO_SS_SLOPE ? " slope": " mean dev",
                ts->ss_criterion.u.f,
-               ts->ss_state & __FIO_SS_PCT ? "%" : "");
+               ts->ss_state & FIO_SS_PCT ? "%" : "");
 
        free(p1);
        free(p1alt);
@@ -1353,19 +1353,19 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts,
                char ss_buf[64];
 
                snprintf(ss_buf, sizeof(ss_buf), "%s%s:%f%s",
-                       ts->ss_state & __FIO_SS_IOPS ? "iops" : "bw",
-                       ts->ss_state & __FIO_SS_SLOPE ? "_slope" : "",
+                       ts->ss_state & FIO_SS_IOPS ? "iops" : "bw",
+                       ts->ss_state & FIO_SS_SLOPE ? "_slope" : "",
                        (float) ts->ss_limit.u.f,
-                       ts->ss_state & __FIO_SS_PCT ? "%" : "");
+                       ts->ss_state & FIO_SS_PCT ? "%" : "");
 
                tmp = json_create_object();
                json_object_add_value_object(root, "steadystate", tmp);
                json_object_add_value_string(tmp, "ss", ss_buf);
                json_object_add_value_int(tmp, "duration", (int)ts->ss_dur);
-               json_object_add_value_int(tmp, "attained", (ts->ss_state & __FIO_SS_ATTAINED) > 0);
+               json_object_add_value_int(tmp, "attained", (ts->ss_state & FIO_SS_ATTAINED) > 0);
 
                snprintf(ss_buf, sizeof(ss_buf), "%f%s", (float) ts->ss_criterion.u.f,
-                       ts->ss_state & __FIO_SS_PCT ? "%" : "");
+                       ts->ss_state & FIO_SS_PCT ? "%" : "");
                json_object_add_value_string(tmp, "criterion", ss_buf);
                json_object_add_value_float(tmp, "max_deviation", ts->ss_deviation.u.f);
                json_object_add_value_float(tmp, "slope", ts->ss_slope.u.f);
@@ -1381,7 +1381,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts,
                ** otherwise it actually points to the second element
                ** in the list
                */
-               if ((ts->ss_state & __FIO_SS_ATTAINED) || !(ts->ss_state & __FIO_SS_BUFFER_FULL))
+               if ((ts->ss_state & FIO_SS_ATTAINED) || !(ts->ss_state & FIO_SS_BUFFER_FULL))
                        j = ts->ss_head;
                else
                        j = ts->ss_head == 0 ? ts->ss_dur - 1 : ts->ss_head - 1;
index 45d4f5d..05ce029 100644 (file)
@@ -11,7 +11,7 @@ static void steadystate_alloc(struct thread_data *td)
        td->ss.bw_data = calloc(td->ss.dur, sizeof(uint64_t));
        td->ss.iops_data = calloc(td->ss.dur, sizeof(uint64_t));
 
-       td->ss.state |= __FIO_SS_DATA;
+       td->ss.state |= FIO_SS_DATA;
 }
 
 void steadystate_setup(void)
@@ -63,33 +63,33 @@ static bool steadystate_slope(uint64_t iops, uint64_t bw,
        ss->bw_data[ss->tail] = bw;
        ss->iops_data[ss->tail] = iops;
 
-       if (ss->state & __FIO_SS_IOPS)
+       if (ss->state & FIO_SS_IOPS)
                new_val = iops;
        else
                new_val = bw;
 
-       if (ss->state & __FIO_SS_BUFFER_FULL || ss->tail - ss->head == ss->dur - 1) {
-               if (!(ss->state & __FIO_SS_BUFFER_FULL)) {
+       if (ss->state & FIO_SS_BUFFER_FULL || ss->tail - ss->head == ss->dur - 1) {
+               if (!(ss->state & FIO_SS_BUFFER_FULL)) {
                        /* first time through */
                        for(i = 0, ss->sum_y = 0; i < ss->dur; i++) {
-                               if (ss->state & __FIO_SS_IOPS)
+                               if (ss->state & FIO_SS_IOPS)
                                        ss->sum_y += ss->iops_data[i];
                                else
                                        ss->sum_y += ss->bw_data[i];
                                j = (ss->head + i) % ss->dur;
-                               if (ss->state & __FIO_SS_IOPS)
+                               if (ss->state & FIO_SS_IOPS)
                                        ss->sum_xy += i * ss->iops_data[j];
                                else
                                        ss->sum_xy += i * ss->bw_data[j];
                        }
-                       ss->state |= __FIO_SS_BUFFER_FULL;
+                       ss->state |= FIO_SS_BUFFER_FULL;
                } else {                /* easy to update the sums */
                        ss->sum_y -= ss->oldest_y;
                        ss->sum_y += new_val;
                        ss->sum_xy = ss->sum_xy - ss->sum_y + ss->dur * new_val;
                }
 
-               if (ss->state & __FIO_SS_IOPS)
+               if (ss->state & FIO_SS_IOPS)
                        ss->oldest_y = ss->iops_data[ss->head];
                else
                        ss->oldest_y = ss->bw_data[ss->head];
@@ -102,7 +102,7 @@ static bool steadystate_slope(uint64_t iops, uint64_t bw,
                 */
                ss->slope = (ss->sum_xy - (double) ss->sum_x * ss->sum_y / ss->dur) /
                                (ss->sum_x_sq - (double) ss->sum_x * ss->sum_x / ss->dur);
-               if (ss->state & __FIO_SS_PCT)
+               if (ss->state & FIO_SS_PCT)
                        ss->criterion = 100.0 * ss->slope / (ss->sum_y / ss->dur);
                else
                        ss->criterion = ss->slope;
@@ -137,24 +137,24 @@ static bool steadystate_deviation(uint64_t iops, uint64_t bw,
        ss->bw_data[ss->tail] = bw;
        ss->iops_data[ss->tail] = iops;
 
-       if (ss->state & __FIO_SS_BUFFER_FULL || ss->tail - ss->head == ss->dur - 1) {
-               if (!(ss->state & __FIO_SS_BUFFER_FULL)) {
+       if (ss->state & FIO_SS_BUFFER_FULL || ss->tail - ss->head == ss->dur - 1) {
+               if (!(ss->state & FIO_SS_BUFFER_FULL)) {
                        /* first time through */
                        for(i = 0, ss->sum_y = 0; i < ss->dur; i++)
-                               if (ss->state & __FIO_SS_IOPS)
+                               if (ss->state & FIO_SS_IOPS)
                                        ss->sum_y += ss->iops_data[i];
                                else
                                        ss->sum_y += ss->bw_data[i];
-                       ss->state |= __FIO_SS_BUFFER_FULL;
+                       ss->state |= FIO_SS_BUFFER_FULL;
                } else {                /* easy to update the sum */
                        ss->sum_y -= ss->oldest_y;
-                       if (ss->state & __FIO_SS_IOPS)
+                       if (ss->state & FIO_SS_IOPS)
                                ss->sum_y += ss->iops_data[ss->tail];
                        else
                                ss->sum_y += ss->bw_data[ss->tail];
                }
 
-               if (ss->state & __FIO_SS_IOPS)
+               if (ss->state & FIO_SS_IOPS)
                        ss->oldest_y = ss->iops_data[ss->head];
                else
                        ss->oldest_y = ss->bw_data[ss->head];
@@ -163,14 +163,14 @@ static bool steadystate_deviation(uint64_t iops, uint64_t bw,
                ss->deviation = 0.0;
 
                for (i = 0; i < ss->dur; i++) {
-                       if (ss->state & __FIO_SS_IOPS)
+                       if (ss->state & FIO_SS_IOPS)
                                diff = ss->iops_data[i] - mean;
                        else
                                diff = ss->bw_data[i] - mean;
                        ss->deviation = max(ss->deviation, diff * (diff < 0.0 ? -1.0 : 1.0));
                }
 
-               if (ss->state & __FIO_SS_PCT)
+               if (ss->state & FIO_SS_PCT)
                        ss->criterion = 100.0 * ss->deviation / mean;
                else
                        ss->criterion = ss->deviation;
@@ -207,7 +207,7 @@ void steadystate_check(void)
 
                if (!ss->dur || td->runstate <= TD_SETTING_UP ||
                    td->runstate >= TD_EXITED || !ss->state ||
-                   ss->state & __FIO_SS_ATTAINED)
+                   ss->state & FIO_SS_ATTAINED)
                        continue;
 
                td_iops = 0;
@@ -221,13 +221,13 @@ void steadystate_check(void)
                prev_groupid = td->groupid;
 
                fio_gettime(&now, NULL);
-               if (ss->ramp_time && !(ss->state & __FIO_SS_RAMP_OVER)) {
+               if (ss->ramp_time && !(ss->state & FIO_SS_RAMP_OVER)) {
                        /*
                         * Begin recording data one second after ss->ramp_time
                         * has elapsed
                         */
                        if (utime_since(&td->epoch, &now) >= (ss->ramp_time + 1000000L))
-                               ss->state |= __FIO_SS_RAMP_OVER;
+                               ss->state |= FIO_SS_RAMP_OVER;
                }
 
                td_io_u_lock(td);
@@ -247,7 +247,7 @@ void steadystate_check(void)
                 * prev_iops/bw the first time through after ss->ramp_time
                 * is done.
                 */
-               if (ss->state & __FIO_SS_RAMP_OVER) {
+               if (ss->state & FIO_SS_RAMP_OVER) {
                        group_bw += 1000 * (td_bytes - ss->prev_bytes) / rate_time;
                        group_iops += 1000 * (td_iops - ss->prev_iops) / rate_time;
                        ++group_ramp_time_over;
@@ -255,7 +255,7 @@ void steadystate_check(void)
                ss->prev_iops = td_iops;
                ss->prev_bytes = td_bytes;
 
-               if (td->o.group_reporting && !(ss->state & __FIO_SS_DATA))
+               if (td->o.group_reporting && !(ss->state & FIO_SS_DATA))
                        continue;
 
                /*
@@ -273,7 +273,7 @@ void steadystate_check(void)
                                        (unsigned long long) group_bw,
                                        ss->head, ss->tail);
 
-               if (ss->state & __FIO_SS_SLOPE)
+               if (ss->state & FIO_SS_SLOPE)
                        ret = steadystate_slope(group_iops, group_bw, td);
                else
                        ret = steadystate_deviation(group_iops, group_bw, td);
@@ -282,12 +282,12 @@ void steadystate_check(void)
                        if (td->o.group_reporting) {
                                for_each_td(td2, j) {
                                        if (td2->groupid == td->groupid) {
-                                               td2->ss.state |= __FIO_SS_ATTAINED;
+                                               td2->ss.state |= FIO_SS_ATTAINED;
                                                fio_mark_td_terminate(td2);
                                        }
                                }
                        } else {
-                               ss->state |= __FIO_SS_ATTAINED;
+                               ss->state |= FIO_SS_ATTAINED;
                                fio_mark_td_terminate(td);
                        }
                }
@@ -314,7 +314,7 @@ int td_steadystate_init(struct thread_data *td)
 
                ss->state = o->ss_state;
                if (!td->ss.ramp_time)
-                       ss->state |= __FIO_SS_RAMP_OVER;
+                       ss->state |= FIO_SS_RAMP_OVER;
 
                ss->sum_x = o->ss_dur * (o->ss_dur - 1) / 2;
                ss->sum_x_sq = (o->ss_dur - 1) * (o->ss_dur) * (2*o->ss_dur - 1) / 6;
index bbc3945..eaba0d7 100644 (file)
@@ -41,19 +41,28 @@ struct steadystate_data {
 };
 
 enum {
-       __FIO_SS_IOPS           = 1,
-       __FIO_SS_BW             = 2,
-       __FIO_SS_SLOPE          = 4,
-       __FIO_SS_ATTAINED       = 8,
-       __FIO_SS_RAMP_OVER      = 16,
-       __FIO_SS_DATA           = 32,
-       __FIO_SS_PCT            = 64,
-       __FIO_SS_BUFFER_FULL    = 128,
-
-       FIO_SS_IOPS             = __FIO_SS_IOPS,
-       FIO_SS_IOPS_SLOPE       = __FIO_SS_IOPS | __FIO_SS_SLOPE,
-       FIO_SS_BW               = __FIO_SS_BW,
-       FIO_SS_BW_SLOPE         = __FIO_SS_BW | __FIO_SS_SLOPE,
+       __FIO_SS_IOPS = 0,
+       __FIO_SS_BW,
+       __FIO_SS_SLOPE,
+       __FIO_SS_ATTAINED,
+       __FIO_SS_RAMP_OVER,
+       __FIO_SS_DATA,
+       __FIO_SS_PCT,
+       __FIO_SS_BUFFER_FULL,
+};
+
+enum {
+       FIO_SS_IOPS             = 1 << __FIO_SS_IOPS,
+       FIO_SS_BW               = 1 << __FIO_SS_BW,
+       FIO_SS_SLOPE            = 1 << __FIO_SS_SLOPE,
+       FIO_SS_ATTAINED         = 1 << __FIO_SS_ATTAINED,
+       FIO_SS_RAMP_OVER        = 1 << __FIO_SS_RAMP_OVER,
+       FIO_SS_DATA             = 1 << __FIO_SS_DATA,
+       FIO_SS_PCT              = 1 << __FIO_SS_PCT,
+       FIO_SS_BUFFER_FULL      = 1 << __FIO_SS_BUFFER_FULL,
+
+       FIO_SS_IOPS_SLOPE       = FIO_SS_IOPS | FIO_SS_SLOPE,
+       FIO_SS_BW_SLOPE         = FIO_SS_BW | FIO_SS_SLOPE,
 };
 
 #define STEADYSTATE_MSEC       1000