summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-12-16 20:38:53 -0700
committerMohamad Ayyash <mkayyash@google.com>2015-03-06 17:58:09 -0800
commit80ac020b479bd433590d221fcefa3eb47327f9a3 (patch)
tree4e51ccde32f167637cfcfa0fc18faeddeefe38c9
parent249610114607bcb569318acc25342f44d3cf0cc1 (diff)
downloadfio-80ac020b479bd433590d221fcefa3eb47327f9a3.tar.gz
gettime-thread: set and allow multiple CPUs
Also use the new option checking framework instead of carrying a flag for whether it's set or not. Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--cconv.c2
-rw-r--r--gettime-thread.c16
-rw-r--r--gettime.h2
-rw-r--r--init.c12
-rw-r--r--options.c12
-rw-r--r--server.h2
-rw-r--r--thread_options.h5
7 files changed, 26 insertions, 25 deletions
diff --git a/cconv.c b/cconv.c
index 0de2f5c7..0fca764e 100644
--- a/cconv.c
+++ b/cconv.c
@@ -219,7 +219,6 @@ void convert_thread_options_to_cpu(struct thread_options *o,
o->unified_rw_rep = le32_to_cpu(top->unified_rw_rep);
o->gtod_reduce = le32_to_cpu(top->gtod_reduce);
o->gtod_cpu = le32_to_cpu(top->gtod_cpu);
- o->gtod_offload = le32_to_cpu(top->gtod_offload);
o->clocksource = le32_to_cpu(top->clocksource);
o->no_stall = le32_to_cpu(top->no_stall);
o->trim_percentage = le32_to_cpu(top->trim_percentage);
@@ -381,7 +380,6 @@ void convert_thread_options_to_net(struct thread_options_pack *top,
top->unified_rw_rep = cpu_to_le32(o->unified_rw_rep);
top->gtod_reduce = cpu_to_le32(o->gtod_reduce);
top->gtod_cpu = cpu_to_le32(o->gtod_cpu);
- top->gtod_offload = cpu_to_le32(o->gtod_offload);
top->clocksource = cpu_to_le32(o->clocksource);
top->no_stall = cpu_to_le32(o->no_stall);
top->trim_percentage = cpu_to_le32(o->trim_percentage);
diff --git a/gettime-thread.c b/gettime-thread.c
index 95f35c32..73632d0b 100644
--- a/gettime-thread.c
+++ b/gettime-thread.c
@@ -8,11 +8,14 @@
struct timeval *fio_tv = NULL;
int fio_gtod_offload = 0;
-int fio_gtod_cpu = -1;
+static os_cpu_mask_t fio_gtod_cpumask;
static pthread_t gtod_thread;
void fio_gtod_init(void)
{
+ if (fio_tv)
+ return;
+
fio_tv = smalloc(sizeof(struct timeval));
if (!fio_tv)
log_err("fio: smalloc pool exhausted\n");
@@ -31,10 +34,16 @@ static void fio_gtod_update(void)
}
}
+struct gtod_cpu_data {
+ struct fio_mutex *mutex;
+ unsigned int cpu;
+};
+
static void *gtod_thread_main(void *data)
{
struct fio_mutex *mutex = data;
+ fio_setaffinity(gettid(), fio_gtod_cpumask);
fio_mutex_up(mutex);
/*
@@ -84,4 +93,7 @@ err:
return ret;
}
-
+void fio_gtod_set_cpu(unsigned int cpu)
+{
+ fio_cpu_set(&fio_gtod_cpumask, cpu);
+}
diff --git a/gettime.h b/gettime.h
index f5412286..b775ef3a 100644
--- a/gettime.h
+++ b/gettime.h
@@ -38,4 +38,6 @@ static inline int fio_gettime_offload(struct timeval *tv)
return 1;
}
+extern void fio_gtod_set_cpu(unsigned int cpu);
+
#endif
diff --git a/init.c b/init.c
index f606087e..427768c3 100644
--- a/init.c
+++ b/init.c
@@ -758,6 +758,12 @@ static int fixup_options(struct thread_data *td)
ret = 1;
}
+ if (fio_option_is_set(o, gtod_cpu)) {
+ fio_gtod_init();
+ fio_gtod_set_cpu(o->gtod_cpu);
+ fio_gtod_offload = 1;
+ }
+
return ret;
}
@@ -2385,12 +2391,6 @@ int parse_options(int argc, char *argv[])
return 0;
}
- if (def_thread.o.gtod_offload) {
- fio_gtod_init();
- fio_gtod_offload = 1;
- fio_gtod_cpu = def_thread.o.gtod_cpu;
- }
-
if (output_format == FIO_OUTPUT_NORMAL)
log_info("%s\n", fio_version_string);
diff --git a/options.c b/options.c
index a01b2d9b..80a7047e 100644
--- a/options.c
+++ b/options.c
@@ -1079,16 +1079,6 @@ static int str_gtod_reduce_cb(void *data, int *il)
return 0;
}
-static int str_gtod_cpu_cb(void *data, long long *il)
-{
- struct thread_data *td = data;
- int val = *il;
-
- td->o.gtod_cpu = val;
- td->o.gtod_offload = 1;
- return 0;
-}
-
static int str_size_cb(void *data, unsigned long long *__val)
{
struct thread_data *td = data;
@@ -3404,7 +3394,7 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
.name = "gtod_cpu",
.lname = "Dedicated gettimeofday() CPU",
.type = FIO_OPT_INT,
- .cb = str_gtod_cpu_cb,
+ .off1 = td_var_offset(gtod_cpu),
.help = "Set up dedicated gettimeofday() thread on this CPU",
.verify = gtod_cpu_verify,
.category = FIO_OPT_C_GENERAL,
diff --git a/server.h b/server.h
index cd3f9993..dc5a69e8 100644
--- a/server.h
+++ b/server.h
@@ -38,7 +38,7 @@ struct fio_net_cmd_reply {
};
enum {
- FIO_SERVER_VER = 41,
+ FIO_SERVER_VER = 42,
FIO_SERVER_MAX_FRAGMENT_PDU = 1024,
FIO_SERVER_MAX_CMD_MB = 2048,
diff --git a/thread_options.h b/thread_options.h
index 530dd9a6..611f8e73 100644
--- a/thread_options.h
+++ b/thread_options.h
@@ -195,7 +195,6 @@ struct thread_options {
unsigned int unified_rw_rep;
unsigned int gtod_reduce;
unsigned int gtod_cpu;
- unsigned int gtod_offload;
enum fio_cs clocksource;
unsigned int no_stall;
unsigned int trim_percentage;
@@ -419,7 +418,6 @@ struct thread_options_pack {
uint32_t unified_rw_rep;
uint32_t gtod_reduce;
uint32_t gtod_cpu;
- uint32_t gtod_offload;
uint32_t clocksource;
uint32_t no_stall;
uint32_t trim_percentage;
@@ -428,6 +426,7 @@ struct thread_options_pack {
uint64_t trim_backlog;
uint32_t clat_percentiles;
uint32_t percentile_precision;
+ uint32_t pad2;
fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN];
uint8_t read_iolog_file[FIO_TOP_STR_MAX];
@@ -480,10 +479,10 @@ struct thread_options_pack {
uint64_t number_ios;
uint32_t sync_file_range;
- uint32_t pad2;
uint64_t latency_target;
uint64_t latency_window;
+ uint32_t pad3;
fio_fp64_t latency_percentile;
} __attribute__((packed));