Skip to content

Commit 91c7884

Browse files
isilenceaxboe
authored andcommitted
io_uring: remove IOU_F_TWQ_FORCE_NORMAL
Extract a function for non-local task_work_add, and use it directly from io_move_task_work_from_local(). Now we don't use IOU_F_TWQ_FORCE_NORMAL and it can be killed. As a small positive side effect we don't grab task->io_uring in io_req_normal_work_add anymore, which is not needed for io_req_local_work_add(). Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/2e55571e8ff2927ae3cc12da606d204e2485525b.1687518903.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2fdd6fb commit 91c7884

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

io_uring/io_uring.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ static __cold void io_fallback_tw(struct io_uring_task *tctx)
13171317
}
13181318
}
13191319

1320-
static void io_req_local_work_add(struct io_kiocb *req, unsigned flags)
1320+
static inline void io_req_local_work_add(struct io_kiocb *req, unsigned flags)
13211321
{
13221322
struct io_ring_ctx *ctx = req->ctx;
13231323
unsigned nr_wait, nr_tw, nr_tw_prev;
@@ -1368,19 +1368,11 @@ static void io_req_local_work_add(struct io_kiocb *req, unsigned flags)
13681368
wake_up_state(ctx->submitter_task, TASK_INTERRUPTIBLE);
13691369
}
13701370

1371-
void __io_req_task_work_add(struct io_kiocb *req, unsigned flags)
1371+
static void io_req_normal_work_add(struct io_kiocb *req)
13721372
{
13731373
struct io_uring_task *tctx = req->task->io_uring;
13741374
struct io_ring_ctx *ctx = req->ctx;
13751375

1376-
if (!(flags & IOU_F_TWQ_FORCE_NORMAL) &&
1377-
(ctx->flags & IORING_SETUP_DEFER_TASKRUN)) {
1378-
rcu_read_lock();
1379-
io_req_local_work_add(req, flags);
1380-
rcu_read_unlock();
1381-
return;
1382-
}
1383-
13841376
/* task_work already pending, we're done */
13851377
if (!llist_add(&req->io_task_work.node, &tctx->task_list))
13861378
return;
@@ -1394,6 +1386,17 @@ void __io_req_task_work_add(struct io_kiocb *req, unsigned flags)
13941386
io_fallback_tw(tctx);
13951387
}
13961388

1389+
void __io_req_task_work_add(struct io_kiocb *req, unsigned flags)
1390+
{
1391+
if (req->ctx->flags & IORING_SETUP_DEFER_TASKRUN) {
1392+
rcu_read_lock();
1393+
io_req_local_work_add(req, flags);
1394+
rcu_read_unlock();
1395+
} else {
1396+
io_req_normal_work_add(req);
1397+
}
1398+
}
1399+
13971400
static void __cold io_move_task_work_from_local(struct io_ring_ctx *ctx)
13981401
{
13991402
struct llist_node *node;
@@ -1404,7 +1407,7 @@ static void __cold io_move_task_work_from_local(struct io_ring_ctx *ctx)
14041407
io_task_work.node);
14051408

14061409
node = node->next;
1407-
__io_req_task_work_add(req, IOU_F_TWQ_FORCE_NORMAL);
1410+
io_req_normal_work_add(req);
14081411
}
14091412
}
14101413

io_uring/io_uring.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@
1616
#endif
1717

1818
enum {
19-
/* don't use deferred task_work */
20-
IOU_F_TWQ_FORCE_NORMAL = 1,
21-
2219
/*
2320
* A hint to not wake right away but delay until there are enough of
2421
* tw's queued to match the number of CQEs the task is waiting for.
2522
*
2623
* Must not be used wirh requests generating more than one CQE.
2724
* It's also ignored unless IORING_SETUP_DEFER_TASKRUN is set.
2825
*/
29-
IOU_F_TWQ_LAZY_WAKE = 2,
26+
IOU_F_TWQ_LAZY_WAKE = 1,
3027
};
3128

3229
enum {

0 commit comments

Comments
 (0)