options: add log_compression_cpus option
authorJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 22:45:12 +0000 (15:45 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 22:45:12 +0000 (15:45 -0700)
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 <axboe@fb.com>
HOWTO
cconv.c
fio.1
iolog.c
options.c
server.h
thread_options.h

diff --git a/HOWTO b/HOWTO
index a534aa865d8c4a9384ebee3d823ecaaaf0fdfb3d..eb9c8245d4e3253bd311756cafc0708f9538ef83 100644 (file)
--- 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 c309578cd06a9bf27700468c5866b52069060a16..c0168c47d7ddad0f3c9dfee1cf1d5e2e392084cf 100644 (file)
--- 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 3cc353a3c02a698f709fc6bce6cdbeefec5124d7..eab20d779e35d034e94cf54dfc70e6a1f28eec15 100644 (file)
--- 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 35c656e8f3f7455a3b12b64a6b9528cfc03c3622..27d00ff93c8da91a2e233a93b4209fe895b3d76f 100644 (file)
--- 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,
 };
 
index bcddbf14319db46f20d4c931fb05ab702bc52d16..627029cd732ccba701079e3ec1d7f6d5c3a35b15 100644 (file)
--- 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",
index 6709b5fbdef6dce37c7ffecc28888304ce0ec489..6370c5042eb6bd7a8c1fc8b3c5b596bb1f7e9cc3 100644 (file)
--- 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,
index 567df819a85ee6d02fe6089599fe7b1227d0b35f..f9c156207795c643a874b129e85f36df9e376030 100644 (file)
@@ -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;