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
Unified · Split
| @@ -872,10 +872,15 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags) · 871 unmodified lines | ||
| 872 | 872 | lockdep_assert(!io_wq_current_is_worker()); |
| 873 | 873 | lockdep_assert_held(&ctx->uring_lock); |
| 874 | 874 | |
| 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 | + | |
| 877 | 883 | ctx->submit_state.cq_flush = true; |
| 878 | − __io_cq_unlock_post(ctx); | |
| 879 | 884 | return posted; |
| 880 | 885 | } |
| 881 | 886 | |
| @@ -1078,21 +1083,22 @@ static __cold void __io_fallback_tw(struct llist_node *node, bool sync) · 196 unmodified lines | ||
| 1078 | 1083 | while (node) { |
| 1079 | 1084 | req = container_of(node, struct io_kiocb, io_task_work.node); |
| 1080 | 1085 | node = node->next; |
| 1081 | − if (sync && last_ctx != req->ctx) { | |
| 1086 | + if (last_ctx != req->ctx) { | |
| 1082 | 1087 | if (last_ctx) { |
| 1083 | − flush_delayed_work(&last_ctx->fallback_work); | |
| 1088 | + if (sync) | |
| 1089 | + flush_delayed_work(&last_ctx->fallback_work); | |
| 1084 | 1090 | percpu_ref_put(&last_ctx->refs); |
| 1085 | 1091 | } |
| 1086 | 1092 | last_ctx = req->ctx; |
| 1087 | 1093 | percpu_ref_get(&last_ctx->refs); |
| 1088 | 1094 | } |
| 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); | |
| 1092 | 1097 | } |
| 1093 | 1098 | |
| 1094 | 1099 | if (last_ctx) { |
| 1095 | − flush_delayed_work(&last_ctx->fallback_work); | |
| 1100 | + if (sync) | |
| 1101 | + flush_delayed_work(&last_ctx->fallback_work); | |
| 1096 | 1102 | percpu_ref_put(&last_ctx->refs); |
| 1097 | 1103 | } |
| 1098 | 1104 | } |