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 <axboe@fb.com>
diff --git a/lib/tp.c b/lib/tp.c
index 386e31a..7462f5b 100644
--- a/lib/tp.c
+++ b/lib/tp.c
@@ -11,6 +11,7 @@
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
+#include <string.h>
#include "../smalloc.h"
#include "../log.h"
@@ -21,9 +22,19 @@
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 5b07cc6..9147cc2 100644
--- a/lib/tp.h
+++ b/lib/tp.h
@@ -10,6 +10,7 @@
struct flist_head list;
tp_work_fn *fn;
int wait;
+ int prio;
pthread_cond_t cv;
pthread_mutex_t lock;
volatile int done;