From 5930db2c065082e4514587de5ccfc6624f73dcc2 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 9 Jul 2014 09:52:20 +0200 Subject: [PATCH] iolog: run compression work at slightly elevated nice level Add support for work items to contain a priority, and use this directly with nice. Run compression at nice 1, to make it slightly less important than the actual IO jobs. Signed-off-by: Jens Axboe --- iolog.c | 1 + lib/tp.c | 11 +++++++++++ lib/tp.h | 1 + 3 files changed, 13 insertions(+) diff --git a/iolog.c b/iolog.c index 3b39f4c6..79c189b7 100644 --- a/iolog.c +++ b/iolog.c @@ -1087,6 +1087,7 @@ int iolog_flush(struct io_log *log, int wait) } else data->work.wait = 0; + data->work.prio = 1; tp_queue_work(tdat, &data->work); if (wait) { diff --git a/lib/tp.c b/lib/tp.c index 386e31af..7462f5bf 100644 --- a/lib/tp.c +++ b/lib/tp.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "../smalloc.h" #include "../log.h" @@ -21,9 +22,19 @@ static void tp_flush_work(struct flist_head *list) struct tp_work *work; while (!flist_empty(list)) { + int prio; + work = flist_entry(list->next, struct tp_work, list); flist_del(&work->list); + + prio = work->prio; + if (nice(prio) < 0) + log_err("fio: nice %s\n", strerror(errno)); + work->fn(work); + + if (nice(prio) < 0) + log_err("fio: nice %s\n", strerror(errno)); } } diff --git a/lib/tp.h b/lib/tp.h index 5b07cc6c..9147cc2c 100644 --- a/lib/tp.h +++ b/lib/tp.h @@ -10,6 +10,7 @@ struct tp_work { struct flist_head list; tp_work_fn *fn; int wait; + int prio; pthread_cond_t cv; pthread_mutex_t lock; volatile int done; -- 2.25.1