]> git.itanic.dy.fi Git - linux-stable/commitdiff
block: move __get_task_ioprio() into header file
authorJens Axboe <axboe@kernel.dk>
Mon, 8 Jan 2024 18:50:16 +0000 (11:50 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 8 Jan 2024 19:27:39 +0000 (12:27 -0700)
We call this once per IO, which can be millions of times per second.
Since nobody really uses io priorities, or at least it isn't very
common, this is all wasted time and can amount to as much as 3% of
the total kernel time.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/ioprio.c
include/linux/ioprio.h

index b5a942519a797ceab4729231dd7c673e50ab0613..73301a261429ff9e04a166aefa5c72df55eaee57 100644 (file)
@@ -139,32 +139,6 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
        return ret;
 }
 
-/*
- * If the task has set an I/O priority, use that. Otherwise, return
- * the default I/O priority.
- *
- * Expected to be called for current task or with task_lock() held to keep
- * io_context stable.
- */
-int __get_task_ioprio(struct task_struct *p)
-{
-       struct io_context *ioc = p->io_context;
-       int prio;
-
-       if (p != current)
-               lockdep_assert_held(&p->alloc_lock);
-       if (ioc)
-               prio = ioc->ioprio;
-       else
-               prio = IOPRIO_DEFAULT;
-
-       if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE)
-               prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p),
-                                        task_nice_ioprio(p));
-       return prio;
-}
-EXPORT_SYMBOL_GPL(__get_task_ioprio);
-
 static int get_task_ioprio(struct task_struct *p)
 {
        int ret;
index 7578d4f6a969a419a8e39e38a8886dc9119c6973..d6a9b5b7ed1671dbb13bed816610505edb85b1b0 100644 (file)
@@ -47,7 +47,30 @@ static inline int task_nice_ioclass(struct task_struct *task)
 }
 
 #ifdef CONFIG_BLOCK
-int __get_task_ioprio(struct task_struct *p);
+/*
+ * If the task has set an I/O priority, use that. Otherwise, return
+ * the default I/O priority.
+ *
+ * Expected to be called for current task or with task_lock() held to keep
+ * io_context stable.
+ */
+static inline int __get_task_ioprio(struct task_struct *p)
+{
+       struct io_context *ioc = p->io_context;
+       int prio;
+
+       if (p != current)
+               lockdep_assert_held(&p->alloc_lock);
+       if (ioc)
+               prio = ioc->ioprio;
+       else
+               prio = IOPRIO_DEFAULT;
+
+       if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE)
+               prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p),
+                                        task_nice_ioprio(p));
+       return prio;
+}
 #else
 static inline int __get_task_ioprio(struct task_struct *p)
 {