From c08f9fe23b0f257f914b2d9e0e4f1117418e5da6 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 8 Dec 2015 15:45:12 -0700 Subject: [PATCH] options: add log_compression_cpus option We generally don't want online log compression to interfere with the IO jobs. Add an option that allows us to contain the log compression to a specific CPU, or set of CPUs. Signed-off-by: Jens Axboe --- HOWTO | 14 +++++++++----- cconv.c | 2 ++ fio.1 | 12 ++++++++---- iolog.c | 18 +++++++++++++++++- options.c | 24 ++++++++++++++++++++++++ server.h | 2 +- thread_options.h | 2 ++ 7 files changed, 63 insertions(+), 11 deletions(-) diff --git a/HOWTO b/HOWTO index a534aa86..eb9c8245 100644 --- a/HOWTO +++ b/HOWTO @@ -1580,11 +1580,15 @@ log_compression=int If this is set, fio will compress the IO logs as in the specified log file. This feature depends on the availability of zlib. -log_store_compressed=bool If set, and log_compression is also set, - fio will store the log files in a compressed format. They - can be decompressed with fio, using the --inflate-log - command line parameter. The files will be stored with a - .fz suffix. +log_compression_cpus=str Define the set of CPUs that are allowed to + handle online log compression for the IO jobs. This can + provide better isolation between performance sensitive jobs, + and background compression work. + +log_store_compressed=bool If set, fio will store the log files in a + compressed format. They can be decompressed with fio, using + the --inflate-log command line parameter. The files will be + stored with a .fz suffix. block_error_percentiles=bool If set, record errors in trim block-sized units from writes and trims and output a histogram of diff --git a/cconv.c b/cconv.c index c309578c..c0168c47 100644 --- a/cconv.c +++ b/cconv.c @@ -261,6 +261,7 @@ void convert_thread_options_to_cpu(struct thread_options *o, #if 0 uint8_t cpumask[FIO_TOP_STR_MAX]; uint8_t verify_cpumask[FIO_TOP_STR_MAX]; + uint8_t log_gz_cpumask[FIO_TOP_STR_MAX]; #endif } @@ -482,6 +483,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top, #if 0 uint8_t cpumask[FIO_TOP_STR_MAX]; uint8_t verify_cpumask[FIO_TOP_STR_MAX]; + uint8_t log_gz_cpumask[FIO_TOP_STR_MAX]; #endif } diff --git a/fio.1 b/fio.1 index 3cc353a3..eab20d77 100644 --- a/fio.1 +++ b/fio.1 @@ -1427,11 +1427,15 @@ most of the system memory. So pick your poison. The IO logs are saved normally at the end of a run, by decompressing the chunks and storing them in the specified log file. This feature depends on the availability of zlib. .TP +.BI log_compression_cpus \fR=\fPstr +Define the set of CPUs that are allowed to handle online log compression +for the IO jobs. This can provide better isolation between performance +sensitive jobs, and background compression work. +.TP .BI log_store_compressed \fR=\fPbool -If set, and \fBlog\fR_compression is also set, fio will store the log files in -a compressed format. They can be decompressed with fio, using the -\fB\-\-inflate-log\fR command line parameter. The files will be stored with a -\fB\.fz\fR suffix. +If set, fio will store the log files in a compressed format. They can be +decompressed with fio, using the \fB\-\-inflate-log\fR command line parameter. +The files will be stored with a \fB\.fz\fR suffix. .TP .BI block_error_percentiles \fR=\fPbool If set, record errors in trim block-sized units from writes and trims and output diff --git a/iolog.c b/iolog.c index 35c656e8..27d00ff9 100644 --- a/iolog.c +++ b/iolog.c @@ -1115,8 +1115,24 @@ err: goto done; } +static int gz_init_worker(struct submit_worker *sw) +{ + struct thread_data *td = sw->wq->td; + + if (!fio_option_is_set(&td->o, log_gz_cpumask)) + return 0; + + if (fio_setaffinity(gettid(), td->o.log_gz_cpumask) == -1) { + log_err("gz: failed to set CPU affinity\n"); + return 1; + } + + return 0; +} + static struct workqueue_ops log_compress_wq_ops = { - .fn = gz_work, + .fn = gz_work, + .init_worker_fn = gz_init_worker, .nice = 1, }; diff --git a/options.c b/options.c index bcddbf14..627029cd 100644 --- a/options.c +++ b/options.c @@ -535,6 +535,17 @@ static int str_verify_cpus_allowed_cb(void *data, const char *input) return set_cpus_allowed(td, &td->o.verify_cpumask, input); } + +static int str_log_cpus_allowed_cb(void *data, const char *input) +{ + struct thread_data *td = data; + + if (parse_dryrun()) + return 0; + + return set_cpus_allowed(td, &td->o.log_gz_cpumask, input); +} + #endif #ifdef CONFIG_LIBNUMA @@ -3229,6 +3240,19 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .category = FIO_OPT_C_LOG, .group = FIO_OPT_G_INVALID, }, +#ifdef FIO_HAVE_CPU_AFFINITY + { + .name = "log_compression_cpus", + .lname = "Log Compression CPUs", + .type = FIO_OPT_STR, + .cb = str_log_cpus_allowed_cb, + .off1 = td_var_offset(log_gz_cpumask), + .parent = "log_compression", + .help = "Limit log compression to these CPUs", + .category = FIO_OPT_C_LOG, + .group = FIO_OPT_G_INVALID, + }, +#endif { .name = "log_store_compressed", .lname = "Log store compressed", diff --git a/server.h b/server.h index 6709b5fb..6370c504 100644 --- a/server.h +++ b/server.h @@ -38,7 +38,7 @@ struct fio_net_cmd_reply { }; enum { - FIO_SERVER_VER = 48, + FIO_SERVER_VER = 49, FIO_SERVER_MAX_FRAGMENT_PDU = 1024, FIO_SERVER_MAX_CMD_MB = 2048, diff --git a/thread_options.h b/thread_options.h index 567df819..f9c15620 100644 --- a/thread_options.h +++ b/thread_options.h @@ -170,6 +170,7 @@ struct thread_options { unsigned int numjobs; os_cpu_mask_t cpumask; os_cpu_mask_t verify_cpumask; + os_cpu_mask_t log_gz_cpumask; unsigned int cpus_allowed_policy; char *numa_cpunodes; unsigned short numa_mem_mode; @@ -415,6 +416,7 @@ struct thread_options_pack { uint32_t numjobs; uint8_t cpumask[FIO_TOP_STR_MAX]; uint8_t verify_cpumask[FIO_TOP_STR_MAX]; + uint8_t log_gz_cpumask[FIO_TOP_STR_MAX]; uint32_t cpus_allowed_policy; uint32_t iolog; uint32_t rwmixcycle; -- 2.25.1