linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] sched/rt: Add a helper to test for a RT task
@ 2017-10-04 15:49 Sebastian Andrzej Siewior
  2017-10-04 15:49 ` [PATCH 2/2] block/ioprio: use a helper to check for RT prio Sebastian Andrzej Siewior
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-10-04 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Jens Axboe, tglx, Sebastian Andrzej Siewior

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.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/sched/rt.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h
index f93329aba31a..30a86b8178f8 100644
--- a/include/linux/sched/rt.h
+++ b/include/linux/sched/rt.h
@@ -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.
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] block/ioprio: use a helper to check for RT prio
  2017-10-04 15:49 [PATCH 1/2] sched/rt: Add a helper to test for a RT task Sebastian Andrzej Siewior
@ 2017-10-04 15:49 ` Sebastian Andrzej Siewior
  2017-10-10 11:01   ` [tip:sched/core] block/ioprio: Use " tip-bot for Sebastian Andrzej Siewior
  2017-10-06  8:19 ` [PATCH 1/2] sched/rt: Add a helper to test for a RT task Peter Zijlstra
  2017-10-10 11:01 ` [tip:sched/core] " tip-bot for Sebastian Andrzej Siewior
  2 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-10-04 15:49 UTC (permalink / raw)
  To: linux-kernel
  Cc: Peter Zijlstra, Ingo Molnar, Jens Axboe, tglx, Sebastian Andrzej Siewior

A side-effect to the old code is that now SCHED_DEADLINE is also
recognized.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/ioprio.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index 8c1239020d79..c8f3f0302220 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -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;
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] sched/rt: Add a helper to test for a RT task
  2017-10-04 15:49 [PATCH 1/2] sched/rt: Add a helper to test for a RT task Sebastian Andrzej Siewior
  2017-10-04 15:49 ` [PATCH 2/2] block/ioprio: use a helper to check for RT prio Sebastian Andrzej Siewior
@ 2017-10-06  8:19 ` Peter Zijlstra
  2017-10-06  8:51   ` Sebastian Andrzej Siewior
  2017-10-10 11:01 ` [tip:sched/core] " tip-bot for Sebastian Andrzej Siewior
  2 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2017-10-06  8:19 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: linux-kernel, Ingo Molnar, Jens Axboe, tglx

On Wed, Oct 04, 2017 at 05:49:00PM +0200, Sebastian Andrzej Siewior wrote:
> 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.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  include/linux/sched/rt.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h
> index f93329aba31a..30a86b8178f8 100644
> --- a/include/linux/sched/rt.h
> +++ b/include/linux/sched/rt.h
> @@ -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.

> +{
> +	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.
> -- 
> 2.14.2
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] sched/rt: Add a helper to test for a RT task
  2017-10-06  8:19 ` [PATCH 1/2] sched/rt: Add a helper to test for a RT task Peter Zijlstra
@ 2017-10-06  8:51   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-10-06  8:51 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel, Ingo Molnar, Jens Axboe, tglx

On 2017-10-06 10:19:37 [+0200], Peter Zijlstra wrote:
> > --- a/include/linux/sched/rt.h
> > +++ b/include/linux/sched/rt.h
> > @@ -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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:sched/core] sched/rt: Add a helper to test for a RT task
  2017-10-04 15:49 [PATCH 1/2] sched/rt: Add a helper to test for a RT task Sebastian Andrzej Siewior
  2017-10-04 15:49 ` [PATCH 2/2] block/ioprio: use a helper to check for RT prio Sebastian Andrzej Siewior
  2017-10-06  8:19 ` [PATCH 1/2] sched/rt: Add a helper to test for a RT task Peter Zijlstra
@ 2017-10-10 11:01 ` tip-bot for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2017-10-10 11:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, torvalds, axboe, efault, tglx, linux-kernel, peterz, mingo, bigeasy

Commit-ID:  ff0d4a9dc16b1f4c954f6407c233ab848bdfe8b0
Gitweb:     https://git.kernel.org/tip/ff0d4a9dc16b1f4c954f6407c233ab848bdfe8b0
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Wed, 4 Oct 2017 17:49:00 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20171004154901.26904-1-bigeasy@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/sched/rt.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h
index f93329a..1330016 100644
--- a/include/linux/sched/rt.h
+++ b/include/linux/sched/rt.h
@@ -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.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:sched/core] block/ioprio: Use a helper to check for RT prio
  2017-10-04 15:49 ` [PATCH 2/2] block/ioprio: use a helper to check for RT prio Sebastian Andrzej Siewior
@ 2017-10-10 11:01   ` tip-bot for Sebastian Andrzej Siewior
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2017-10-10 11:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, linux-kernel, torvalds, efault, axboe, tglx, bigeasy, peterz, hpa

Commit-ID:  36436440cd19f59f5be12a1b181d299af2725140
Gitweb:     https://git.kernel.org/tip/36436440cd19f59f5be12a1b181d299af2725140
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Wed, 4 Oct 2017 17:49:01 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20171004154901.26904-2-bigeasy@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/ioprio.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index 8c12390..2f19aab 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -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;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-10 11:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-04 15:49 [PATCH 1/2] sched/rt: Add a helper to test for a RT task Sebastian Andrzej Siewior
2017-10-04 15:49 ` [PATCH 2/2] block/ioprio: use a helper to check for RT prio Sebastian Andrzej Siewior
2017-10-10 11:01   ` [tip:sched/core] block/ioprio: Use " tip-bot for Sebastian Andrzej Siewior
2017-10-06  8:19 ` [PATCH 1/2] sched/rt: Add a helper to test for a RT task Peter Zijlstra
2017-10-06  8:51   ` Sebastian Andrzej Siewior
2017-10-10 11:01 ` [tip:sched/core] " tip-bot for Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).