From e6a6a9844038b1e4dd8f979c37579be695c770d0 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Tue, 22 Nov 2016 14:06:32 -0500 Subject: [PATCH] steadystate: get rid of ->ss_pct and encode this information in ->state via __FIO_SS_PCT This leaves a 32-bit filler in thread_options_pack that can be removed when it is possible to maintain required byte alignment --- cconv.c | 2 -- options.c | 6 +----- stat.c | 5 +++-- steadystate.c | 6 ++---- steadystate.h | 2 +- thread_options.h | 3 +-- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/cconv.c b/cconv.c index a795f1e9..a01475a9 100644 --- a/cconv.c +++ b/cconv.c @@ -215,7 +215,6 @@ void convert_thread_options_to_cpu(struct thread_options *o, o->ss_dur = le64_to_cpu(top->ss_dur); o->ss_ramp_time = le64_to_cpu(top->ss_ramp_time); o->ss = le32_to_cpu(top->ss); - o->ss_pct = le32_to_cpu(top->ss_pct); o->ss_limit.u.f = fio_uint64_to_double(le64_to_cpu(top->ss_limit.u.i)); o->zone_range = le64_to_cpu(top->zone_range); o->zone_size = le64_to_cpu(top->zone_size); @@ -521,7 +520,6 @@ void convert_thread_options_to_net(struct thread_options_pack *top, top->ss_dur = __cpu_to_le64(top->ss_dur); top->ss_ramp_time = __cpu_to_le64(top->ss_ramp_time); top->ss = cpu_to_le32(top->ss); - top->ss_pct = cpu_to_le32(top->ss_pct); top->ss_limit.u.i = __cpu_to_le64(fio_double_to_uint64(o->ss_limit.u.f)); top->zone_range = __cpu_to_le64(o->zone_range); top->zone_size = __cpu_to_le64(o->zone_size); diff --git a/options.c b/options.c index 3af604bd..9d471bbd 100644 --- a/options.c +++ b/options.c @@ -1099,7 +1099,7 @@ static int str_steadystate_cb(void *data, const char *str) if (parse_dryrun()) return 0; - td->o.ss_pct = true; + td->o.ss |= __FIO_SS_PCT; td->o.ss_limit.u.f = val; } else if (td->o.ss & __FIO_SS_IOPS) { if (!str_to_float(nr, &val, 0)) { @@ -1113,9 +1113,7 @@ static int str_steadystate_cb(void *data, const char *str) if (parse_dryrun()) return 0; - td->o.ss_pct = false; td->o.ss_limit.u.f = val; - } else { /* bandwidth criterion */ if (str_to_decimal(nr, &ll, 1, td, 0, 0)) { log_err("fio: steadystate BW threshold postfix parsing failed\n"); @@ -1128,9 +1126,7 @@ static int str_steadystate_cb(void *data, const char *str) if (parse_dryrun()) return 0; - td->o.ss_pct = false; td->o.ss_limit.u.f = (double) ll; - } td->ss.state = td->o.ss; diff --git a/stat.c b/stat.c index c41ac899..a42ee9b8 100644 --- a/stat.c +++ b/stat.c @@ -1269,7 +1269,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts, ss->state & __FIO_SS_IOPS ? "iops" : "bw", ss->state & __FIO_SS_SLOPE ? "_slope" : "", (float) ss->limit, - ss->pct ? "%" : ""); + ss->state & __FIO_SS_PCT ? "%" : ""); tmp = json_create_object(); json_object_add_value_object(root, "steadystate", tmp); @@ -1278,7 +1278,8 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts, json_object_add_value_int(tmp, "steadystate_ramptime", ss->ramp_time / 1000000L); json_object_add_value_int(tmp, "attained", (ss->state & __FIO_SS_ATTAINED) > 0); - snprintf(ss_buf, sizeof(ss_buf), "%f%s", (float) ss->criterion, ss->pct ? "%" : ""); + snprintf(ss_buf, sizeof(ss_buf), "%f%s", (float) ss->criterion, + ss->state & __FIO_SS_PCT ? "%" : ""); json_object_add_value_string(tmp, "criterion", ss_buf); json_object_add_value_float(tmp, "max_deviation", ss->deviation); json_object_add_value_float(tmp, "slope", ss->slope); diff --git a/steadystate.c b/steadystate.c index f5d80462..696ad164 100644 --- a/steadystate.c +++ b/steadystate.c @@ -107,7 +107,7 @@ static bool steadystate_slope(unsigned long iops, unsigned long 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->pct) + if (ss->state & __FIO_SS_PCT) ss->criterion = 100.0 * ss->slope / (ss->sum_y / ss->dur); else ss->criterion = ss->slope; @@ -172,7 +172,7 @@ static bool steadystate_deviation(unsigned long iops, unsigned long bw, ss->deviation = max(ss->deviation, diff * (diff < 0.0 ? -1.0 : 1.0)); } - if (ss->pct) + if (ss->state & __FIO_SS_PCT) ss->criterion = 100.0 * ss->deviation / mean; else ss->criterion = ss->deviation; @@ -311,7 +311,6 @@ int td_steadystate_init(struct thread_data *td) ss->dur = o->ss_dur; ss->limit = o->ss_limit.u.f; ss->ramp_time = o->ss_ramp_time; - ss->pct = o->ss_pct; ss->state = o->ss; if (!td->ss.ramp_time) @@ -331,7 +330,6 @@ int td_steadystate_init(struct thread_data *td) if (ss2->dur != ss->dur || ss2->limit != ss->limit || ss2->ramp_time != ss->ramp_time || - ss2->pct != ss->pct || ss2->state != ss->state || ss2->sum_x != ss->sum_x || ss2->sum_x_sq != ss->sum_x_sq) { diff --git a/steadystate.h b/steadystate.h index aea8969b..a23c45ba 100644 --- a/steadystate.h +++ b/steadystate.h @@ -16,7 +16,6 @@ struct steadystate_data { double limit; unsigned long long dur; unsigned long long ramp_time; - bool pct; unsigned int state; @@ -47,6 +46,7 @@ enum { __FIO_SS_ATTAINED = 8, __FIO_SS_RAMP_OVER = 16, __FIO_SS_DATA = 32, + __FIO_SS_PCT = 64, FIO_SS_IOPS = __FIO_SS_IOPS, FIO_SS_IOPS_SLOPE = __FIO_SS_IOPS | __FIO_SS_SLOPE, diff --git a/thread_options.h b/thread_options.h index f15ebef8..e28c59d0 100644 --- a/thread_options.h +++ b/thread_options.h @@ -170,7 +170,6 @@ struct thread_options { unsigned long long timeout; unsigned long long ramp_time; unsigned int ss; - bool ss_pct; fio_fp64_t ss_limit; unsigned long long ss_dur; unsigned long long ss_ramp_time; @@ -433,7 +432,6 @@ struct thread_options_pack { uint64_t ss_dur; uint64_t ss_ramp_time; uint32_t ss; - uint32_t ss_pct; fio_fp64_t ss_limit; uint32_t overwrite; uint32_t bw_avg_time; @@ -495,6 +493,7 @@ struct thread_options_pack { uint64_t trim_backlog; uint32_t clat_percentiles; uint32_t percentile_precision; + uint32_t padding; /* REMOVE ME when possible to maintain alignment */ fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN]; uint8_t read_iolog_file[FIO_TOP_STR_MAX]; -- 2.25.1