diff options
author | Jens Axboe <axboe@kernel.dk> | 2022-05-25 11:01:04 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-07-24 18:39:12 -0600 |
commit | c9f06aa7de153cdbe424e7e38be39f2272cf78bc (patch) | |
tree | cd88c2b482d95378da7ed99ce691c722c37d8388 /io_uring/tctx.h | |
parent | a4ad4f748ea96202451f88b6385d7283d0f2e513 (diff) | |
download | linux-c9f06aa7de153cdbe424e7e38be39f2272cf78bc.tar.gz linux-c9f06aa7de153cdbe424e7e38be39f2272cf78bc.tar.bz2 linux-c9f06aa7de153cdbe424e7e38be39f2272cf78bc.zip |
io_uring: move io_uring_task (tctx) helpers into its own file
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/tctx.h')
-rw-r--r-- | io_uring/tctx.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/io_uring/tctx.h b/io_uring/tctx.h new file mode 100644 index 000000000000..f4964e40d07e --- /dev/null +++ b/io_uring/tctx.h @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Arbitrary limit, can be raised if need be + */ +#define IO_RINGFD_REG_MAX 16 + +struct io_uring_task { + /* submission side */ + int cached_refs; + struct xarray xa; + struct wait_queue_head wait; + const struct io_ring_ctx *last; + struct io_wq *io_wq; + struct percpu_counter inflight; + atomic_t inflight_tracked; + atomic_t in_idle; + + spinlock_t task_lock; + struct io_wq_work_list task_list; + struct io_wq_work_list prio_task_list; + struct callback_head task_work; + struct file **registered_rings; + bool task_running; +}; + +struct io_tctx_node { + struct list_head ctx_node; + struct task_struct *task; + struct io_ring_ctx *ctx; +}; + +int io_uring_alloc_task_context(struct task_struct *task, + struct io_ring_ctx *ctx); +void io_uring_del_tctx_node(unsigned long index); +int __io_uring_add_tctx_node(struct io_ring_ctx *ctx); +void io_uring_clean_tctx(struct io_uring_task *tctx); + +void io_uring_unreg_ringfd(void); +int io_ringfd_register(struct io_ring_ctx *ctx, void __user *__arg, + unsigned nr_args); +int io_ringfd_unregister(struct io_ring_ctx *ctx, void __user *__arg, + unsigned nr_args); + +/* + * Note that this task has used io_uring. We use it for cancelation purposes. + */ +static inline int io_uring_add_tctx_node(struct io_ring_ctx *ctx) +{ + struct io_uring_task *tctx = current->io_uring; + + if (likely(tctx && tctx->last == ctx)) + return 0; + return __io_uring_add_tctx_node(ctx); +} |