Skip to content

Commit dc12d17

Browse files
isilenceaxboe
authored andcommitted
io_uring: adjust defer tw counting
The UINT_MAX work item counting bias in io_req_local_work_add() in case of !IOU_F_TWQ_LAZY_WAKE works in a sense that we will not miss a wake up, however it's still eerie. In particular, if we add a lazy work item after a non-lazy one, we'll increment it and get nr_tw==0, and subsequent adds may try to unnecessarily wake up the task, which is though not so likely to happen in real workloads. Half the bias, it's still large enough to be larger than any valid ->cq_wait_nr, which is limited by IORING_MAX_CQ_ENTRIES, but further have a good enough of space before it overflows. Fixes: 8751d15 ("io_uring: reduce scheduling due to tw") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/108b971e958deaf7048342930c341ba90f75d806.1705438669.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent baf5977 commit dc12d17

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

io_uring/io_uring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ static inline void io_req_local_work_add(struct io_kiocb *req, unsigned flags)
13251325
nr_tw = nr_tw_prev + 1;
13261326
/* Large enough to fail the nr_wait comparison below */
13271327
if (!(flags & IOU_F_TWQ_LAZY_WAKE))
1328-
nr_tw = -1U;
1328+
nr_tw = INT_MAX;
13291329

13301330
req->nr_tw = nr_tw;
13311331
req->io_task_work.node.next = first;

0 commit comments

Comments
 (0)