]> Git Repo - linux.git/commitdiff
io_uring: export io_put_task()
authorPavel Begunkov <[email protected]>
Tue, 12 Jul 2022 20:52:37 +0000 (21:52 +0100)
committerJens Axboe <[email protected]>
Mon, 25 Jul 2022 00:41:06 +0000 (18:41 -0600)
Make io_put_task() available to non-core parts of io_uring, we'll need
it for notification infrastructure.

Signed-off-by: Pavel Begunkov <[email protected]>
Link: https://lore.kernel.org/r/3686807d4c03b72e389947b0e8692d4d44334ef0.1657643355.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <[email protected]>
include/linux/io_uring_types.h
io_uring/io_uring.c
io_uring/io_uring.h
io_uring/tctx.h

index d54b8b7e0746296eb4a9f448ef2d0349f93b6ed6..368c34d14b1364e11309fc4b673b1985f419c769 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/blkdev.h>
 #include <linux/task_work.h>
 #include <linux/bitmap.h>
+#include <linux/llist.h>
 #include <uapi/linux/io_uring.h>
 
 struct io_wq_work_node {
@@ -43,6 +44,30 @@ struct io_hash_table {
        unsigned                hash_bits;
 };
 
+/*
+ * Arbitrary limit, can be raised if need be
+ */
+#define IO_RINGFD_REG_MAX 16
+
+struct io_uring_task {
+       /* submission side */
+       int                             cached_refs;
+       const struct io_ring_ctx        *last;
+       struct io_wq                    *io_wq;
+       struct file                     *registered_rings[IO_RINGFD_REG_MAX];
+
+       struct xarray                   xa;
+       struct wait_queue_head          wait;
+       atomic_t                        in_idle;
+       atomic_t                        inflight_tracked;
+       struct percpu_counter           inflight;
+
+       struct { /* task_work */
+               struct llist_head       task_list;
+               struct callback_head    task_work;
+       } ____cacheline_aligned_in_smp;
+};
+
 struct io_uring {
        u32 head ____cacheline_aligned_in_smp;
        u32 tail ____cacheline_aligned_in_smp;
index 4b3fd645d0231ae886b5f37f23d372e694825ac8..7795cfedf6bf0e6cd3cce89af1db54e03c5941a6 100644 (file)
@@ -608,7 +608,7 @@ static bool io_cqring_overflow_flush(struct io_ring_ctx *ctx)
        return ret;
 }
 
-static void __io_put_task(struct task_struct *task, int nr)
+void __io_put_task(struct task_struct *task, int nr)
 {
        struct io_uring_task *tctx = task->io_uring;
 
@@ -618,15 +618,6 @@ static void __io_put_task(struct task_struct *task, int nr)
        put_task_struct_many(task, nr);
 }
 
-/* must to be called somewhat shortly after putting a request */
-static inline void io_put_task(struct task_struct *task, int nr)
-{
-       if (likely(task == current))
-               task->io_uring->cached_refs += nr;
-       else
-               __io_put_task(task, nr);
-}
-
 static void io_task_refs_refill(struct io_uring_task *tctx)
 {
        unsigned int refill = -tctx->cached_refs + IO_TCTX_REFS_CACHE_NR;
index 5db0a60dc04efc3bb7689eb43c39b4e8ab742fb4..b1c0c0a400d855ae20959b0c00968b8bd2f1350d 100644 (file)
@@ -71,6 +71,7 @@ void io_wq_submit_work(struct io_wq_work *work);
 
 void io_free_req(struct io_kiocb *req);
 void io_queue_next(struct io_kiocb *req);
+void __io_put_task(struct task_struct *task, int nr);
 
 bool io_match_task_safe(struct io_kiocb *head, struct task_struct *task,
                        bool cancel_all);
@@ -258,4 +259,13 @@ static inline void io_commit_cqring_flush(struct io_ring_ctx *ctx)
                __io_commit_cqring_flush(ctx);
 }
 
+/* must to be called somewhat shortly after putting a request */
+static inline void io_put_task(struct task_struct *task, int nr)
+{
+       if (likely(task == current))
+               task->io_uring->cached_refs += nr;
+       else
+               __io_put_task(task, nr);
+}
+
 #endif
index 8a33ff6e5d91380419f1e633253abc54056c6c81..25974beed4d6be1e14d8dbd674e74bae48e849dc 100644 (file)
@@ -1,31 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 
-#include <linux/llist.h>
-
-/*
- * Arbitrary limit, can be raised if need be
- */
-#define IO_RINGFD_REG_MAX 16
-
-struct io_uring_task {
-       /* submission side */
-       int                             cached_refs;
-       const struct io_ring_ctx        *last;
-       struct io_wq                    *io_wq;
-       struct file                     *registered_rings[IO_RINGFD_REG_MAX];
-
-       struct xarray                   xa;
-       struct wait_queue_head          wait;
-       atomic_t                        in_idle;
-       atomic_t                        inflight_tracked;
-       struct percpu_counter           inflight;
-
-       struct { /* task_work */
-               struct llist_head       task_list;
-               struct callback_head    task_work;
-       } ____cacheline_aligned_in_smp;
-};
-
 struct io_tctx_node {
        struct list_head        ctx_node;
        struct task_struct      *task;
This page took 0.075787 seconds and 4 git commands to generate.