Add gtod_cpu option for pinning gettimeofday() to a single CPU
Similar to what real life products sometimes do, offload gettimeofday()
calls to a single CPU and have that update the current time into a shared
memory location. This option pins a specific CPU for that job, and excludes
it from participating in any of the IO jobs.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/init.c b/init.c
index f00ced3..a8acdc0 100644
--- a/init.c
+++ b/init.c
@@ -27,7 +27,7 @@
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 @@
{
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 @@
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;
}