workqueue: handle nice better
authorVincent Fu <vincent.fu@samsung.com>
Fri, 29 Sep 2023 14:04:50 +0000 (10:04 -0400)
committerVincent Fu <vincent.fu@samsung.com>
Fri, 29 Sep 2023 15:51:10 +0000 (11:51 -0400)
nice returns the program's schedule priority. This can be a negative
value when there is no error condition. To check if nice is triggering
an error we have to check errno.

The most recent three macOS test failures appear to be due to this
problem.

https://github.com/axboe/fio/actions/runs/6347762639/job/17243247222
https://github.com/axboe/fio/actions/runs/6346019205/job/17239370410
https://github.com/axboe/fio/actions/runs/6241934089/job/16944981876

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
workqueue.c

index 9e6c41ff2f399172703b6e438061236670962df8..3636bc3a8a60df765b582f8e4a889f8ef25b9769 100644 (file)
@@ -136,7 +136,8 @@ static void *worker_thread(void *data)
        sk_out_assign(sw->sk_out);
 
        if (wq->ops.nice) {
-               if (nice(wq->ops.nice) < 0) {
+               errno = 0;
+               if (nice(wq->ops.nice) == -1 && errno != 0) {
                        log_err("workqueue: nice %s\n", strerror(errno));
                        ret = 1;
                }