Modified by Jens to fixup some of the mtime/utime confusion,
and add a specific ->is_time to options to get rid of future
issues in this area.
Signed-off-by: Jens Axboe <axboe@fb.com>
if (!eta_new_line_init) {
fio_gettime(&disp_eta_new_line, NULL);
eta_new_line_init = 1;
if (!eta_new_line_init) {
fio_gettime(&disp_eta_new_line, NULL);
eta_new_line_init = 1;
- } else if (eta_new_line &&
- mtime_since_now(&disp_eta_new_line) > eta_new_line * 1000) {
+ } else if (eta_new_line && mtime_since_now(&disp_eta_new_line) > eta_new_line) {
fio_gettime(&disp_eta_new_line, NULL);
eta_new_line_pending = 1;
}
fio_gettime(&disp_eta_new_line, NULL);
eta_new_line_pending = 1;
}
static void __attribute__((unused)) yyunput(int c, char *buf_ptr);
static int __attribute__((unused)) input(void);
static void __attribute__((unused)) yyunput(int c, char *buf_ptr);
static int __attribute__((unused)) input(void);
+/* set by parser -- this is another thing which makes the parser thread-unsafe :(. */
+int lexer_value_is_time = 0; /* for determining if "m" suffix means mega- or minutes */
+
#define set_suffix_value(yylval, i_val, d_val, has_d_val) \
(yylval).v.dval = (d_val); \
(yylval).v.ival = (i_val); \
#define set_suffix_value(yylval, i_val, d_val, has_d_val) \
(yylval).v.dval = (d_val); \
(yylval).v.ival = (i_val); \
set_suffix_value(yylval, 1024, 1024.0, 0);
return SUFFIX;
}
set_suffix_value(yylval, 1024, 1024.0, 0);
return SUFFIX;
}
set_suffix_value(yylval, 1024 * 1024, 1024.0 * 1024.0, 0);
return SUFFIX;
}
set_suffix_value(yylval, 1024 * 1024, 1024.0 * 1024.0, 0);
return SUFFIX;
}
set_suffix_value(yylval, 1000000LL, 1000000.0 , 0);
return SUFFIX;
}
set_suffix_value(yylval, 1000000LL, 1000000.0 , 0);
return SUFFIX;
}
+[mM] {
+ if (!lexer_value_is_time) {
+ set_suffix_value(yylval, 1024 * 1024, 1024.0 * 1024.0, 0);
+ } else {
+ set_suffix_value(yylval, 60LL * 1000000LL, 60.0 * 1000000.0, 0);
+ }
+ return SUFFIX;
+ }
[dD] {
set_suffix_value(yylval, 60LL * 60LL * 24LL * 1000000LL,
60.0 * 60.0 * 24.0 * 1000000.0, 0);
[dD] {
set_suffix_value(yylval, 60LL * 60LL * 24LL * 1000000LL,
60.0 * 60.0 * 24.0 * 1000000.0, 0);
extern int yylex(void);
extern void yyrestart(FILE *file);
extern int yylex(void);
extern void yyrestart(FILE *file);
+extern int lexer_value_is_time;
}
int evaluate_arithmetic_expression(const char *buffer, long long *ival, double *dval,
}
int evaluate_arithmetic_expression(const char *buffer, long long *ival, double *dval,
+ double implied_units, int is_time)
{
int rc, units_specified = 0, has_error = 0;
{
int rc, units_specified = 0, has_error = 0;
+ lexer_value_is_time = is_time;
setup_to_parse_string(buffer);
rc = yyparse(ival, dval, &has_error, &units_specified);
yyrestart(NULL);
setup_to_parse_string(buffer);
rc = yyparse(ival, dval, &has_error, &units_specified);
yyrestart(NULL);
#include "../y.tab.h"
extern int evaluate_arithmetic_expression(const char *buffer, long long *ival,
#include "../y.tab.h"
extern int evaluate_arithmetic_expression(const char *buffer, long long *ival,
- double *dval, double implied_units);
+ double *dval, double implied_units, int is_time);
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
rc = strlen(buffer);
if (rc > 0 && buffer[rc - 1] == '\n')
buffer[rc - 1] = '\0';
rc = strlen(buffer);
if (rc > 0 && buffer[rc - 1] == '\n')
buffer[rc - 1] = '\0';
- rc = evaluate_arithmetic_expression(buffer, &result, &dresult, 1.0);
+ rc = evaluate_arithmetic_expression(buffer, &result, &dresult, 1.0, 0);
if (!rc) {
printf("%lld (%20.20lf)\n", result, dresult);
} else {
if (!rc) {
printf("%lld (%20.20lf)\n", result, dresult);
} else {
case 'E': {
long long t = 0;
case 'E': {
long long t = 0;
- if (str_to_decimal(optarg, &t, 0, NULL, 1)) {
+ if (check_str_time(optarg, &t, 1)) {
log_err("fio: failed parsing eta time %s\n", optarg);
exit_val = 1;
do_exit++;
}
log_err("fio: failed parsing eta time %s\n", optarg);
exit_val = 1;
do_exit++;
}
+ eta_new_line = t / 1000;
case 'L': {
long long val;
case 'L': {
long long val;
- if (check_str_time(optarg, &val, 0)) {
+ if (check_str_time(optarg, &val, 1)) {
log_err("fio: failed parsing time %s\n", optarg);
do_exit++;
exit_val = 1;
break;
}
log_err("fio: failed parsing time %s\n", optarg);
do_exit++;
exit_val = 1;
break;
}
- status_interval = val * 1000;
+ status_interval = val / 1000;
- if (str_to_decimal(fname, &val, 1, o, 0)) {
+ if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
log_err("fio: bssplit conversion failed\n");
free(bssplit);
return 1;
log_err("fio: bssplit conversion failed\n");
free(bssplit);
return 1;
- if (str_to_decimal(nr, &val, 1, o, 0)) {
+ if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
log_err("fio: rw postfix parsing failed\n");
free(nr);
return 1;
log_err("fio: rw postfix parsing failed\n");
free(nr);
return 1;
return 0;
nr = get_opt_postfix(str);
return 0;
nr = get_opt_postfix(str);
- if (nr && !str_to_float(nr, &val)) {
+ if (nr && !str_to_float(nr, &val, 0)) {
log_err("fio: random postfix parsing failed\n");
free(nr);
return 1;
log_err("fio: random postfix parsing failed\n");
free(nr);
return 1;
.help = "Only start job when this period has passed",
.def = "0",
.is_seconds = 1,
.help = "Only start job when this period has passed",
.def = "0",
.is_seconds = 1,
.category = FIO_OPT_C_GENERAL,
.group = FIO_OPT_G_RUNTIME,
},
.category = FIO_OPT_C_GENERAL,
.group = FIO_OPT_G_RUNTIME,
},
.help = "Stop workload when this amount of time has passed",
.def = "0",
.is_seconds = 1,
.help = "Stop workload when this amount of time has passed",
.def = "0",
.is_seconds = 1,
.category = FIO_OPT_C_GENERAL,
.group = FIO_OPT_G_RUNTIME,
},
.category = FIO_OPT_C_GENERAL,
.group = FIO_OPT_G_RUNTIME,
},
.off1 = td_var_offset(ramp_time),
.help = "Ramp up time before measuring performance",
.is_seconds = 1,
.off1 = td_var_offset(ramp_time),
.help = "Ramp up time before measuring performance",
.is_seconds = 1,
.category = FIO_OPT_C_GENERAL,
.group = FIO_OPT_G_RUNTIME,
},
.category = FIO_OPT_C_GENERAL,
.group = FIO_OPT_G_RUNTIME,
},
.off1 = td_var_offset(thinktime),
.help = "Idle time between IO buffers (usec)",
.def = "0",
.off1 = td_var_offset(thinktime),
.help = "Idle time between IO buffers (usec)",
.def = "0",
.category = FIO_OPT_C_IO,
.group = FIO_OPT_G_THINKTIME,
},
.category = FIO_OPT_C_IO,
.group = FIO_OPT_G_THINKTIME,
},
.off1 = td_var_offset(thinktime_spin),
.help = "Start think time by spinning this amount (usec)",
.def = "0",
.off1 = td_var_offset(thinktime_spin),
.help = "Start think time by spinning this amount (usec)",
.def = "0",
.parent = "thinktime",
.hide = 1,
.category = FIO_OPT_C_IO,
.parent = "thinktime",
.hide = 1,
.category = FIO_OPT_C_IO,
.type = FIO_OPT_INT,
.off1 = td_var_offset(max_latency),
.help = "Maximum tolerated IO latency (usec)",
.type = FIO_OPT_INT,
.off1 = td_var_offset(max_latency),
.help = "Maximum tolerated IO latency (usec)",
.category = FIO_OPT_C_IO,
.group = FIO_OPT_G_LATPROF,
},
.category = FIO_OPT_C_IO,
.group = FIO_OPT_G_LATPROF,
},
.type = FIO_OPT_STR_VAL_TIME,
.off1 = td_var_offset(latency_target),
.help = "Ramp to max queue depth supporting this latency",
.type = FIO_OPT_STR_VAL_TIME,
.off1 = td_var_offset(latency_target),
.help = "Ramp to max queue depth supporting this latency",
.category = FIO_OPT_C_IO,
.group = FIO_OPT_G_LATPROF,
},
.category = FIO_OPT_C_IO,
.group = FIO_OPT_G_LATPROF,
},
.type = FIO_OPT_STR_VAL_TIME,
.off1 = td_var_offset(latency_window),
.help = "Time to sustain latency_target",
.type = FIO_OPT_STR_VAL_TIME,
.off1 = td_var_offset(latency_window),
.help = "Time to sustain latency_target",
.category = FIO_OPT_C_IO,
.group = FIO_OPT_G_LATPROF,
},
.category = FIO_OPT_C_IO,
.group = FIO_OPT_G_LATPROF,
},
}
extern int evaluate_arithmetic_expression(const char *buffer, long long *ival,
}
extern int evaluate_arithmetic_expression(const char *buffer, long long *ival,
- double *dval, double implied_units);
+ double *dval, double implied_units,
+ int is_time);
#ifdef CONFIG_ARITHMETIC
/*
#ifdef CONFIG_ARITHMETIC
/*
* original number parsing code. Once sufficiently sure that the arithmetic
* code is always getting the right answers, these can be removed.
*/
* original number parsing code. Once sufficiently sure that the arithmetic
* code is always getting the right answers, these can be removed.
*/
-static void verify_exp_parser_float(const char *str, double implied_units)
+static void verify_exp_parser_float(const char *str, double implied_units, int is_time)
{
long long ival;
double dval, tmpval;
{
long long ival;
double dval, tmpval;
if (sscanf(str, "%lf", &tmpval) != 1)
return;
if (sscanf(str, "%lf", &tmpval) != 1)
return;
- if (evaluate_arithmetic_expression(str, &ival, &dval, implied_units) != 0) {
+ if (evaluate_arithmetic_expression(str, &ival, &dval, implied_units, is_time) != 0) {
log_info("Arithmetic failed on '%s'\n", str);
return;
}
log_info("Arithmetic failed on '%s'\n", str);
return;
}
-static void verify_exp_parser_decimal(const char *str, long long val, int kilo, int is_seconds)
+static void verify_exp_parser_decimal(const char *str, long long val, int kilo, int is_seconds,
+ int is_time)
{
int rc;
long long ival;
{
int rc;
long long ival;
if (is_seconds)
implied_units = 1000000.0;
if (is_seconds)
implied_units = 1000000.0;
- rc = evaluate_arithmetic_expression(str, &ival, &dval, implied_units);
+ rc = evaluate_arithmetic_expression(str, &ival, &dval, implied_units, is_time);
if (!rc) {
if (ival != val)
log_info("Arithmetic failed on '%s', expected %lld, got %lld\n",
if (!rc) {
if (ival != val)
log_info("Arithmetic failed on '%s', expected %lld, got %lld\n",
/*
* Convert string into a floating number. Return 1 for success and 0 otherwise.
*/
/*
* Convert string into a floating number. Return 1 for success and 0 otherwise.
*/
-int str_to_float(const char *str, double *val)
+int str_to_float(const char *str, double *val, int is_time)
{
#ifdef CONFIG_ARITHMETIC
int rc;
{
#ifdef CONFIG_ARITHMETIC
int rc;
double dval;
if (str[0] == '(') {
double dval;
if (str[0] == '(') {
- rc = evaluate_arithmetic_expression(str, &ival, &dval, 1.0);
+ rc = evaluate_arithmetic_expression(str, &ival, &dval, 1.0, is_time);
if (!rc) {
*val = dval;
return 1;
}
} else {
if (!rc) {
*val = dval;
return 1;
}
} else {
- verify_exp_parser_float(str, 1.0);
+ verify_exp_parser_float(str, 1.0, is_time);
}
#endif
return 1 == sscanf(str, "%lf", val);
}
#endif
return 1 == sscanf(str, "%lf", val);
* convert string into decimal value, noting any size suffix
*/
int str_to_decimal(const char *str, long long *val, int kilo, void *data,
* convert string into decimal value, noting any size suffix
*/
int str_to_decimal(const char *str, long long *val, int kilo, void *data,
+ int is_seconds, int is_time)
{
int len, base;
int rc = 1;
{
int len, base;
int rc = 1;
if (is_seconds)
implied_units = 1000000.0;
if (str[0] == '(')
if (is_seconds)
implied_units = 1000000.0;
if (str[0] == '(')
- rc = evaluate_arithmetic_expression(str, &ival, &dval, implied_units);
+ rc = evaluate_arithmetic_expression(str, &ival, &dval, implied_units, is_time);
if (str[0] == '(' && !rc) {
if (!kilo && is_seconds)
*val = ival / 1000000LL;
if (str[0] == '(' && !rc) {
if (!kilo && is_seconds)
*val = ival / 1000000LL;
} else
*val *= get_mult_time(str, len, is_seconds);
#ifdef CONFIG_ARITHMETIC
} else
*val *= get_mult_time(str, len, is_seconds);
#ifdef CONFIG_ARITHMETIC
- verify_exp_parser_decimal(str, *val, kilo, is_seconds);
+ verify_exp_parser_decimal(str, *val, kilo, is_seconds, is_time);
#endif
return 0;
}
int check_str_bytes(const char *p, long long *val, void *data)
{
#endif
return 0;
}
int check_str_bytes(const char *p, long long *val, void *data)
{
- return str_to_decimal(p, val, 1, data, 0);
+ return str_to_decimal(p, val, 1, data, 0, 0);
}
int check_str_time(const char *p, long long *val, int is_seconds)
{
}
int check_str_time(const char *p, long long *val, int is_seconds)
{
- return str_to_decimal(p, val, 0, NULL, is_seconds);
+ return str_to_decimal(p, val, 0, NULL, is_seconds, 1);
}
void strip_blank_front(char **p)
}
void strip_blank_front(char **p)
- if (!str_to_decimal(str, &__val, 1, data, 0)) {
+ if (!str_to_decimal(str, &__val, 1, data, 0, 0)) {
*val = __val;
return 0;
}
*val = __val;
return 0;
}
fio_opt_str_val_fn *fn = o->cb;
char tmp[128], *p;
fio_opt_str_val_fn *fn = o->cb;
char tmp[128], *p;
+ if (!is_time && o->is_time)
+ is_time = o->is_time;
+
strncpy(tmp, ptr, sizeof(tmp) - 1);
p = strchr(tmp, ',');
if (p)
strncpy(tmp, ptr, sizeof(tmp) - 1);
p = strchr(tmp, ',');
if (p)
- if (!str_to_float(ptr, &uf)) {
+ if (!str_to_float(ptr, &uf, 0)) { /* this breaks if we ever have lists of times */
log_err("not a floating point value: %s\n", ptr);
return 1;
}
log_err("not a floating point value: %s\n", ptr);
return 1;
}
unsigned int group; /* who to group with */
void *gui_data;
int is_seconds; /* time value with seconds base */
unsigned int group; /* who to group with */
void *gui_data;
int is_seconds; /* time value with seconds base */
+ int is_time; /* time based value */
extern void strip_blank_front(char **);
extern void strip_blank_end(char *);
extern void strip_blank_front(char **);
extern void strip_blank_end(char *);
-extern int str_to_decimal(const char *, long long *, int, void *, int);
+extern int str_to_decimal(const char *, long long *, int, void *, int, int);
extern int check_str_bytes(const char *p, long long *val, void *data);
extern int check_str_time(const char *p, long long *val, int);
extern int check_str_bytes(const char *p, long long *val, void *data);
extern int check_str_time(const char *p, long long *val, int);
-extern int str_to_float(const char *str, double *val);
+extern int str_to_float(const char *str, double *val, int is_time);
/*
* Handlers for the options
/*
* Handlers for the options