sched/rt: Add a helper to test for a RT task
PATCH 1/2 sched/rt: Add a helper to test for a RT task
This helper returns true if a task has elevated priority which is true for RT tasks (SCHED_RR and SCHED_FIFO) and also for SCHED_DEADLINE. A task which runs at RT priority due to PI-boosting is not considered as one with elevated priority.
--- include/linux/sched/rt.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/sched/rt.h +11 -0
@@ -17,6 +17,17 @@ static inline int rt_task(struct task_struct *p)return rt_prio (p->prio); } +static inline bool task_is_elevated (struct task_struct *tsk) +{ +int policy = tsk->policy; + +if (policy ==SCHED_FIFO || policy ==SCHED_RR ) +return true; +if (policy ==SCHED_DEADLINE ) +return true; +return false; +} +#ifdef CONFIG_RT_MUTEXES /* * Must hold either p->pi_lock or task_rq(p)->lock.
Signature · 1 line
2.14.2
PATCH 2/2 block/ioprio: use a helper to check for RT prio
A side-effect to the old code is that now SCHED_DEADLINE is also recognized.
--- include/linux/ioprio.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/ioprio.h +2 -1
@@ -2,6 +2,7 @@#define IOPRIO_H #include <linux/sched.h> +#include <linux/sched/rt.h> #include <linux/iocontext.h> /*
@@ -62,7 +63,7 @@ static inline int task_nice_ioclass(struct task_struct *task) {if (task->policy ==SCHED_IDLE )return IOPRIO_CLASS_IDLE ; -else if (task->policy ==SCHED_FIFO || task->policy ==SCHED_RR ) +else if (task_is_elevated (task))return IOPRIO_CLASS_RT ;else return IOPRIO_CLASS_BE ;
Signature · 1 line
2.14.2
tip-bot for Sebastian Andrzej Siewior
merge bot[tip:sched/core] block/ioprio: Use a helper to check for RT prio
block/ioprio: Use a helper to check for RT prio
Commit-ID: 36436440cd19f59f5be12a1b181d299af2725140 Gitweb: https://git.kernel.org/tip/36436440cd19f59f5be12a1b181d299af2725140 Author: Sebastian Andrzej Siewior <[email protected]> AuthorDate: Wed, 4 Oct 2017 17:49:01 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 10 Oct 2017 11:45:39 +0200
block/ioprio: Use a helper to check for RT prio
A side-effect to the old code is that now SCHED_DEADLINE is also recognized.
--- include/linux/ioprio.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/ioprio.h +2 -1
@@ -2,6 +2,7 @@#define IOPRIO_H #include <linux/sched.h> +#include <linux/sched/rt.h> #include <linux/iocontext.h> /*
@@ -62,7 +63,7 @@ static inline int task_nice_ioclass(struct task_struct *task) {if (task->policy ==SCHED_IDLE )return IOPRIO_CLASS_IDLE ; -else if (task->policy ==SCHED_FIFO || task->policy ==SCHED_RR ) +else if (task_is_realtime (task))return IOPRIO_CLASS_RT ;else return IOPRIO_CLASS_BE ;
Quoted 15 lines · Sebastian Andrzej Siewior
This helper returns true if a task has elevated priority which is true for RT tasks (
SCHED_RRandSCHED_FIFO) and also forSCHED_DEADLINE. A task which runs at RT priority due to PI-boosting is not considered as one with elevated priority.Signed-off-by Sebastian Andrzej Siewior <[email protected]>--- include/linux/sched/rt.h | 11 +++++++++++ 1 file changed, 11 insertions(+)include/linux/sched/rt.h +0
-0
include/linux/sched/rt.h static inline int rt_task(struct task_struct *p) · line 20
Quoted 4 lines
include/linux/sched/rt.h +1
-0@@ -17,6 +17,17 @@ static inline int rt_task(struct task_struct *p)return rt_prio (p->prio); } +static inline bool task_is_elevated (struct task_struct *tsk)
Would you be terribly upset if I rename that? I'm thinking something like task_is_realtime() better reflects what it does.
Quoted 16 lines
include/linux/sched/rt.h +10
-0+{ +int policy = tsk->policy; + +if (policy ==SCHED_FIFO || policy ==SCHED_RR ) +return true; +if (policy ==SCHED_DEADLINE ) +return true; +return false; +} +#ifdef CONFIG_RT_MUTEXES /* * Must hold either p->pi_lock or task_rq(p)->lock. Signature · 1 line
2.14.2
Quoted 10 lines · Peter Zijlstra
include/linux/sched/rt.h static inline int rt_task(struct task_struct *p) · line 20
Quoted 7 lines
include/linux/sched/rt.h +1
-0@@ -17,6 +17,17 @@ static inline int rt_task(struct task_struct *p)return rt_prio (p->prio); } +static inline bool task_is_elevated (struct task_struct *tsk)Would you be terribly upset if I rename that? I'm thinking something like
task_is_realtime()better reflects what it does.
no, not at all.
Sebastian
tip-bot for Sebastian Andrzej Siewior
merge botsched/rt: Add a helper to test for a RT task
Commit-ID: ff0d4a9dc16b1f4c954f6407c233ab848bdfe8b0 Gitweb: https://git.kernel.org/tip/ff0d4a9dc16b1f4c954f6407c233ab848bdfe8b0 Author: Sebastian Andrzej Siewior <[email protected]> AuthorDate: Wed, 4 Oct 2017 17:49:00 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 10 Oct 2017 11:45:38 +0200
sched/rt: Add a helper to test for a RT task
This helper returns true if a task has elevated priority which is true for RT tasks (SCHED_RR and SCHED_FIFO) and also for SCHED_DEADLINE. A task which runs at RT priority due to PI-boosting is not considered as one with elevated priority.
--- include/linux/sched/rt.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/sched/rt.h +11 -0
@@ -17,6 +17,17 @@ static inline int rt_task(struct task_struct *p)return rt_prio (p->prio); } +static inline bool task_is_realtime (struct task_struct *tsk) +{ +int policy = tsk->policy; + +if (policy ==SCHED_FIFO || policy ==SCHED_RR ) +return true; +if (policy ==SCHED_DEADLINE ) +return true; +return false; +} +#ifdef CONFIG_RT_MUTEXES /* * Must hold either p->pi_lock or task_rq(p)->lock.