Handle ctrl-c properly with threads
[fio.git] / options.c
index d4fc18489683c5522edf5d825f0d8fb2ba400f42..3d27f2551d6b55ab76fd3c93c71036c138e3bbe6 100644 (file)
--- a/options.c
+++ b/options.c
@@ -154,8 +154,10 @@ static int str_rw_cb(void *data, const char *str)
        char *nr = get_opt_postfix(str);
 
        td->o.ddir_nr = 1;
-       if (nr)
+       if (nr) {
                td->o.ddir_nr = atoi(nr);
+               free(nr);
+       }
 
        return 0;
 }
@@ -285,8 +287,10 @@ static int str_fst_cb(void *data, const char *str)
        char *nr = get_opt_postfix(str);
 
        td->file_service_nr = 1;
-       if (nr)
+       if (nr) {
                td->file_service_nr = atoi(nr);
+               free(nr);
+       }
 
        return 0;
 }
@@ -426,8 +430,24 @@ static int str_lockfile_cb(void *data, const char *str)
        char *nr = get_opt_postfix(str);
 
        td->o.lockfile_batch = 1;
-       if (nr)
+       if (nr) {
                td->o.lockfile_batch = atoi(nr);
+               free(nr);
+       }
+
+       return 0;
+}
+
+static int str_gtod_reduce_cb(void *data, int *il)
+{
+       struct thread_data *td = data;
+       int val = *il;
+
+       td->o.disable_clat = !!val;
+       td->o.disable_slat = !!val;
+       td->o.disable_bw = !!val;
+       if (val)
+               td->tv_cache_mask = 63;
 
        return 0;
 }
@@ -1290,11 +1310,19 @@ static struct fio_option options[] = {
                .def    = "1",
        },
 #endif
+       {
+               .name   = "gtod_reduce",
+               .type   = FIO_OPT_BOOL,
+               .help   = "Greatly reduce number of gettimeofday() calls",
+               .cb     = str_gtod_reduce_cb,
+               .def    = "0",
+       },
        {
                .name   = "disable_clat",
                .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(disable_clat),
                .help   = "Disable completion latency numbers",
+               .parent = "gtod_reduce",
                .def    = "0",
        },
        {
@@ -1302,6 +1330,7 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(disable_slat),
                .help   = "Disable submissionn latency numbers",
+               .parent = "gtod_reduce",
                .def    = "0",
        },
        {
@@ -1309,6 +1338,7 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_BOOL,
                .off1   = td_var_offset(disable_bw),
                .help   = "Disable bandwidth logging",
+               .parent = "gtod_reduce",
                .def    = "0",
        },
        {