io_uring/io-wq: fix incorrect io_wq_for_each_worker() termination logic
Jens Axboe
maintainerPATCH v2 1/1 io_uring/io-wq: fix incorrect io_wq_for_each_worker() termination logic
A previous commit added this helper, and had it terminate if false is returned from the handler. However, that is completely opposite, it should abort the loop if true is returned.
Fix this up by having io_wq_for_each_worker() keep iterating as long as false is returned, and only abort if true is returned.
---
v2: fix the actual bug, rather than work-around it for the exit
condition only.
io_uring/io-wq.c +3 -3
@@ -952,11 +952,11 @@ static bool io_wq_for_each_worker(struct io_wq *wq, void *data) {for (int i =0 ; i <IO_WQ_ACCT_NR ; i++) { -if (!io_acct_for_each_worker (&wq->acct[i], func, data)) -return false; +if (io_acct_for_each_worker (&wq->acct[i], func, data)) +return true; } -return true; +return false; }static bool io_wq_worker_wake (struct io_worker *worker,void *data)
Signature · 1 line
Jens Axboe
Quoted 6 lines · Jens Axboe
A previous commit added this helper, and had it terminate if false is returned from the handler. However, that is completely opposite, it should abort the loop if true is returned.
Fix this up by having
io_wq_for_each_worker()keep iterating as long as false is returned, and only abort if true is returned.
The fix is good, but the API is just weird.
io_acct_for_each_worker returning true indicates an error that will abort the wq walk. It is a non-issue, since all the two callers cannot fail and always return false for success :-)
Quoted 28 lines
Fixes 751eedc4b4b7 ("io_uring/io-wq: move worker lists to struct io_wq_acct")Signed-off-by Jens Axboe <[email protected]>---
v2: fix the actual bug, rather than work-around it for the exit
condition only.io_uring/io-wq.c +3
-3@@ -952,11 +952,11 @@ static bool io_wq_for_each_worker(struct io_wq *wq, void *data) {for (int i =0 ; i <IO_WQ_ACCT_NR ; i++) { -if (!io_acct_for_each_worker (&wq->acct[i], func, data)) -return false; +if (io_acct_for_each_worker (&wq->acct[i], func, data)) +return true; } -return true; +return false; }static bool io_wq_worker_wake (struct io_worker *worker,void *data)
Signature · 1 line
Gabriel Krisman Bertazi
Jens Axboe
maintainerQuoted 9 lines · Gabriel Krisman Bertazi
Quoted 6 lines · Jens Axboe
A previous commit added this helper, and had it terminate if false is returned from the handler. However, that is completely opposite, it should abort the loop if true is returned.
Fix this up by having
io_wq_for_each_worker()keep iterating as long as false is returned, and only abort if true is returned.
Quoted 7 lines
The fix is good, but the API is just weird.
io_acct_for_each_workerreturning true indicates an error that will abort the wq walk. It is a non-issue, since all the two callers cannot fail and always return false for success :-)Reviewed-by Gabriel Krisman Bertazi <[email protected]>
Thanks for taking a look! Was going to post a followup just killing the return value of io_wq_for_each_worker() to void as nobody uses it. Only the cancelation side with its matching will use a true return, most of iterations want to iterate all of them.
Signature · 1 line
Jens Axboe
FOSS is generally in perfect condition for rip off :-)
Quoted 27 lines · Jens Axboe
Quoted 9 lines · Gabriel Krisman Bertazi
Quoted 6 lines · Jens Axboe
A previous commit added this helper, and had it terminate if false is returned from the handler. However, that is completely opposite, it should abort the loop if true is returned.
Fix this up by having
io_wq_for_each_worker()keep iterating as long as false is returned, and only abort if true is returned.Quoted 7 lines
The fix is good, but the API is just weird.
io_acct_for_each_workerreturning true indicates an error that will abort the wq walk. It is a non-issue, since all the two callers cannot fail and always return false for success :-)Reviewed-by Gabriel Krisman Bertazi <[email protected]>Thanks for taking a look! Was going to post a followup just killing the return value of
io_wq_for_each_worker()to void as nobody uses it. Only the cancelation side with its matching will use a true return, most of iterations want to iterate all of them.--
Jens Axboe