Skip to content

Commit 0537fbb

Browse files
committed
Merge tag 'io_uring-6.15-20250424' of git://git.kernel.dk/linux
Pull io_uring fixes from Jens Axboe: - Fix an older bug for handling of fallback task_work, when the task is exiting. Found by code inspection while reworking cancelation. - Fix duplicate flushing in one of the CQE posting helpers. * tag 'io_uring-6.15-20250424' of git://git.kernel.dk/linux: io_uring: fix 'sync' handling of io_fallback_tw() io_uring: don't duplicate flushing in io_req_post_cqe
2 parents 6e3597f + edd43f4 commit 0537fbb

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

io_uring/io_uring.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,15 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags)
872872
lockdep_assert(!io_wq_current_is_worker());
873873
lockdep_assert_held(&ctx->uring_lock);
874874

875-
__io_cq_lock(ctx);
876-
posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
875+
if (!ctx->lockless_cq) {
876+
spin_lock(&ctx->completion_lock);
877+
posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
878+
spin_unlock(&ctx->completion_lock);
879+
} else {
880+
posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
881+
}
882+
877883
ctx->submit_state.cq_flush = true;
878-
__io_cq_unlock_post(ctx);
879884
return posted;
880885
}
881886

@@ -1078,21 +1083,22 @@ static __cold void __io_fallback_tw(struct llist_node *node, bool sync)
10781083
while (node) {
10791084
req = container_of(node, struct io_kiocb, io_task_work.node);
10801085
node = node->next;
1081-
if (sync && last_ctx != req->ctx) {
1086+
if (last_ctx != req->ctx) {
10821087
if (last_ctx) {
1083-
flush_delayed_work(&last_ctx->fallback_work);
1088+
if (sync)
1089+
flush_delayed_work(&last_ctx->fallback_work);
10841090
percpu_ref_put(&last_ctx->refs);
10851091
}
10861092
last_ctx = req->ctx;
10871093
percpu_ref_get(&last_ctx->refs);
10881094
}
1089-
if (llist_add(&req->io_task_work.node,
1090-
&req->ctx->fallback_llist))
1091-
schedule_delayed_work(&req->ctx->fallback_work, 1);
1095+
if (llist_add(&req->io_task_work.node, &last_ctx->fallback_llist))
1096+
schedule_delayed_work(&last_ctx->fallback_work, 1);
10921097
}
10931098

10941099
if (last_ctx) {
1095-
flush_delayed_work(&last_ctx->fallback_work);
1100+
if (sync)
1101+
flush_delayed_work(&last_ctx->fallback_work);
10961102
percpu_ref_put(&last_ctx->refs);
10971103
}
10981104
}

0 commit comments

Comments
 (0)