Fix SQPOLL tctx allocation failure handling
Jens Axboe
maintainercover Fix SQPOLL tctx allocation failure handling
Hi,
Just a basic prep patch cleaning up something I spotted while looking at the report, and then patch 2 that fixes a recent regression due to missing the sqpoll.c error handling.
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerPATCH 1/2 io_uring: remove duplicate io_uring_alloc_task_context() definition
This function exists in both tctx.h (where it belongs) and in io_uring.h as a remnant of before the tctx handling code got split out. Remove the io_uring.h definition and ensure that sqpoll.c includes the tctx.h header to get the definition.
--- io_uring/io_uring.h | 2 -- io_uring/sqpoll.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-)
io_uring/io_uring.h +0 -2
@@ -98,8 +98,6 @@ struct llist_node *io_handle_tw_list(struct llist_node *node, unsigned int *counstruct llist_node *tctx_task_work_run (struct io_uring_task *tctx,unsigned int max_entries,unsigned int *count);void tctx_task_work (struct callback_head *cb);__cold void io_uring_cancel_generic (bool cancel_all,struct io_sq_data *sqd); -int io_uring_alloc_task_context (struct task_struct *task, -struct io_ring_ctx *ctx);int io_ring_add_registered_file (struct io_uring_task *tctx,struct file *file,int start,int end);
io_uring/sqpoll.c +1 -0
@@ -16,6 +16,7 @@#include <uapi/linux/io_uring.h> #include "io_uring.h" +#include "tctx.h" #include "napi.h" #include "sqpoll.h"
Signature · 1 line
2.50.0
Jens Axboe
maintainerPATCH 2/2 io_uring/sqpoll: don't put task_struct on tctx setup failure
In reply to Jens AxboeA recent commit moved the error handling of sqpoll thread and tctx failures into the thread itself, as part of fixing an issue. However, it missed that tctx allocation may also fail, and that io_sq_offload_create() does its own error handling for the task_struct in that case.
Remove the manual task putting in io_sq_offload_create(), as io_sq_thread() will notice that the tctx did not get setup and hence it should put itself and exit.
--- io_uring/sqpoll.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
io_uring/sqpoll.c +1 -4
@@ -420,7 +420,6 @@ void io_sqpoll_wait_sq(struct io_ring_ctx *ctx)__cold int io_sq_offload_create (struct io_ring_ctx *ctx,struct io_uring_params *p) { -struct task_struct *task_to_put =NULL ;int ret;/* Retain compatibility with failing for an invalid attach attempt */
@@ -499,7 +498,7 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,rcu_assign_pointer (sqd->thread, tsk);mutex_unlock (&sqd->lock); - task_to_put =get_task_struct (tsk); +get_task_struct (tsk); ret =io_uring_alloc_task_context (tsk, ctx);wake_up_new_task (tsk);if (ret)
@@ -514,8 +513,6 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,complete (&ctx->sq_data->exited); err:io_sq_thread_finish (ctx); -if (task_to_put) -put_task_struct (task_to_put);return ret; }
Signature · 1 line
2.50.0