History

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

Linus Torvalds committed 1 year ago

Commit 0537fbb2 parents 6e3597f edd43f41 file · +15 −9Browse files

Unified · Split

io_uring/io_uring.c+15−9
@@ -872,10 +872,15 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags) · 871 unmodified lines
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) · 196 unmodified lines
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 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t