Add gtod_cpu option for pinning gettimeofday() to a single CPU
[fio.git] / init.c
diff --git a/init.c b/init.c
index a55868624e8ec277ec90466f09f35f316a2ba756..a8acdc04b4e1be49fc080be3f0a9a17e09281cef 100644 (file)
--- a/init.c
+++ b/init.c
@@ -19,7 +19,7 @@
 #include "smalloc.h"
 #include "filehash.h"
 
-static char fio_version_string[] = "fio 1.22";
+static char fio_version_string[] = "fio 1.23";
 
 #define FIO_RANDSEED           (0xb1899bedUL)
 
@@ -27,7 +27,7 @@ static char **ini_file;
 static int max_jobs = MAX_JOBS;
 static int dump_cmdline;
 
-struct thread_data def_thread;
+static struct thread_data def_thread;
 struct thread_data *threads = NULL;
 
 int exitall_on_terminate = 0;
@@ -214,6 +214,14 @@ static int fixup_options(struct thread_data *td)
 {
        struct thread_options *o = &td->o;
 
+#ifndef FIO_HAVE_CPU_AFFINITY
+       if (td->o.gtod_cpu) {
+               log_err("fio: platform must support CPU affinity for"
+                       "gettimeofday() offloading\n");
+               return 1;
+       }
+#endif
+
        if (read_only && td_write(td)) {
                log_err("fio: job <%s> has write bit set, but fio is in"
                        " read-only mode\n", td->o.name);
@@ -1104,5 +1112,11 @@ int parse_options(int argc, char *argv[])
                return 1;
        }
 
+       if (def_thread.o.gtod_offload) {
+               fio_gtod_init();
+               fio_gtod_offload = 1;
+               fio_gtod_cpu = def_thread.o.gtod_cpu;
+       }
+
        return 0;
 }