Skip to content

Commit 3b7cb74

Browse files
committed
block: move __get_task_ioprio() into header file
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 587371e commit 3b7cb74

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

block/ioprio.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -139,32 +139,6 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
139139
return ret;
140140
}
141141

142-
/*
143-
* If the task has set an I/O priority, use that. Otherwise, return
144-
* the default I/O priority.
145-
*
146-
* Expected to be called for current task or with task_lock() held to keep
147-
* io_context stable.
148-
*/
149-
int __get_task_ioprio(struct task_struct *p)
150-
{
151-
struct io_context *ioc = p->io_context;
152-
int prio;
153-
154-
if (p != current)
155-
lockdep_assert_held(&p->alloc_lock);
156-
if (ioc)
157-
prio = ioc->ioprio;
158-
else
159-
prio = IOPRIO_DEFAULT;
160-
161-
if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE)
162-
prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p),
163-
task_nice_ioprio(p));
164-
return prio;
165-
}
166-
EXPORT_SYMBOL_GPL(__get_task_ioprio);
167-
168142
static int get_task_ioprio(struct task_struct *p)
169143
{
170144
int ret;

include/linux/ioprio.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,30 @@ static inline int task_nice_ioclass(struct task_struct *task)
4747
}
4848

4949
#ifdef CONFIG_BLOCK
50-
int __get_task_ioprio(struct task_struct *p);
50+
/*
51+
* If the task has set an I/O priority, use that. Otherwise, return
52+
* the default I/O priority.
53+
*
54+
* Expected to be called for current task or with task_lock() held to keep
55+
* io_context stable.
56+
*/
57+
static inline int __get_task_ioprio(struct task_struct *p)
58+
{
59+
struct io_context *ioc = p->io_context;
60+
int prio;
61+
62+
if (p != current)
63+
lockdep_assert_held(&p->alloc_lock);
64+
if (ioc)
65+
prio = ioc->ioprio;
66+
else
67+
prio = IOPRIO_DEFAULT;
68+
69+
if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE)
70+
prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p),
71+
task_nice_ioprio(p));
72+
return prio;
73+
}
5174
#else
5275
static inline int __get_task_ioprio(struct task_struct *p)
5376
{

0 commit comments

Comments
 (0)