Skip to contentSkip to conversation

block: Fix default IO priority if there is no IO context

PATCH Applied Guenter Roeck 4 participants 4 messages Jul 31, 2025 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: Fix default IO priority if there is no IO context

Upstream commit 53889bcaf536 ("block: make __get_task_ioprio() easier to read") changes the IO priority returned to the caller if no IO context is defined for the task. Prior to this commit, the returned IO priority was determined by task_nice_ioclass() and task_nice_ioprio(). Now it is always IOPRIO_DEFAULT, which translates to IOPRIO_CLASS_NONE with priority
0. However, task_nice_ioclass() returns IOPRIO_CLASS_IDLE, IOPRIO_CLASS_RT, or IOPRIO_CLASS_BE depending on the task scheduling policy, and task_nice_ioprio() returns a value determined by task_nice(). This causes regressions in test code checking the IO priority and class of IO operations on tasks with no IO context.

Fix the problem by returning the IO priority calculated from task_nice_ioclass() and task_nice_ioprio() if no IO context is defined to match earlier behavior.

Fixes 53889bcaf536 ("block: make __get_task_ioprio() easier to read")
Cc Jens Axboe <[email protected]>
Cc Bart Van Assche <[email protected]>
---
 include/linux/ioprio.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/ioprio.h +2 -1
index b25377b6ea98..5210e8371238 100644
@@ -60,7 +60,8 @@ static inline int __get_task_ioprio(struct task_struct *p)
 	int prio;
 
 	if (!ioc)
-		return IOPRIO_DEFAULT;
+		return IOPRIO_PRIO_VALUE(task_nice_ioclass(p),
+					 task_nice_ioprio(p));
 
 	if (p != current)
 		lockdep_assert_held(&p->alloc_lock);
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Guenter Roeck

Upstream commit 53889bcaf536 ("block: make __get_task_ioprio() easier to read") changes the IO priority returned to the caller if no IO context is defined for the task. Prior to this commit, the returned IO priority was determined by task_nice_ioclass() and task_nice_ioprio(). Now it is always IOPRIO_DEFAULT, which translates to IOPRIO_CLASS_NONE with priority
0. However, task_nice_ioclass() returns IOPRIO_CLASS_IDLE, IOPRIO_CLASS_RT, or IOPRIO_CLASS_BE depending on the task scheduling policy, and task_nice_ioprio() returns a value determined by task_nice(). This causes regressions in test code checking the IO priority and class of IO operations on tasks with no IO context.

Quoted 8 lines

Fix the problem by returning the IO priority calculated from task_nice_ioclass() and task_nice_ioprio() if no IO context is defined to match earlier behavior.

Fixes 53889bcaf536 ("block: make __get_task_ioprio() easier to read")
Cc Jens Axboe <[email protected]>
Cc Bart Van Assche <[email protected]>

Looks good to me.

Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v1 1/1
#2 lore raw
In reply to Guenter Roeck
Quoted 15 lines · Guenter Roeck

Upstream commit 53889bcaf536 ("block: make __get_task_ioprio() easier to read") changes the IO priority returned to the caller if no IO context is defined for the task. Prior to this commit, the returned IO priority was determined by task_nice_ioclass() and task_nice_ioprio(). Now it is always IOPRIO_DEFAULT, which translates to IOPRIO_CLASS_NONE with priority
0. However, task_nice_ioclass() returns IOPRIO_CLASS_IDLE, IOPRIO_CLASS_RT, or IOPRIO_CLASS_BE depending on the task scheduling policy, and task_nice_ioprio() returns a value determined by task_nice(). This causes regressions in test code checking the IO priority and class of IO operations on tasks with no IO context.

Fix the problem by returning the IO priority calculated from task_nice_ioclass() and task_nice_ioprio() if no IO context is defined to match earlier behavior.

Quoted 8 lines
Fixes 53889bcaf536 ("block: make __get_task_ioprio() easier to read")
Cc Jens Axboe <[email protected]>
Cc Bart Van Assche <[email protected]>
---
  include/linux/ioprio.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

LGTM

Thanks

maintainer Applied
#3 lore raw
In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck

Upstream commit 53889bcaf536 ("block: make __get_task_ioprio() easier to read") changes the IO priority returned to the caller if no IO context is defined for the task. Prior to this commit, the returned IO priority was determined by task_nice_ioclass() and task_nice_ioprio(). Now it is always IOPRIO_DEFAULT, which translates to IOPRIO_CLASS_NONE with priority
0. However, task_nice_ioclass() returns IOPRIO_CLASS_IDLE, IOPRIO_CLASS_RT, or IOPRIO_CLASS_BE depending on the task scheduling policy, and task_nice_ioprio() returns a value determined by task_nice(). This causes regressions in test code checking the IO priority and class of IO operations on tasks with no IO context.

Quoted 1 line

[...]

Applied, thanks!

[1/1] block: Fix default IO priority if there is no IO context

      commit: e2ba58ccc9099514380c3300cbc0750b5055fc1c

Best regards,

Signature · 1 line
Jens Axboe