workqueue: add nice support
authorJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 15:56:30 +0000 (08:56 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 8 Dec 2015 15:56:30 +0000 (08:56 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
workqueue.c
workqueue.h

index 9fe7bec..b9b0986 100644 (file)
@@ -134,10 +134,19 @@ static void *worker_thread(void *data)
 {
        struct submit_worker *sw = data;
        struct workqueue *wq = sw->wq;
-       unsigned int eflags = 0, ret;
+       unsigned int eflags = 0, ret = 0;
        FLIST_HEAD(local_list);
 
-       ret = workqueue_init_worker(sw);
+       if (wq->ops.nice) {
+               if (nice(wq->ops.nice) < 0) {
+                       log_err("workqueue: nice %s\n", strerror(errno));
+                       ret = 1;
+               }
+       }
+
+       if (!ret)
+               ret = workqueue_init_worker(sw);
+
        pthread_mutex_lock(&sw->lock);
        sw->flags |= SW_F_RUNNING;
        if (ret)
index c2464b2..f732b30 100644 (file)
@@ -40,6 +40,8 @@ struct workqueue_ops {
 
        workqueue_init_worker_fn *init_worker_fn;
        workqueue_exit_worker_fn *exit_worker_fn;
+
+       unsigned int nice;
 };
 
 struct workqueue {