All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: Document that RT task priorities are 1…99
@ 2019-04-03 21:08 Sebastian Andrzej Siewior
  2019-04-03 21:17 ` John Ogness
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-04-03 21:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Peter Zijlstra, tglx, Sebastian Andrzej Siewior,
	John Ogness

John identified three files which claim that RT task priorities start at
zero. As far as I understand, 0 is used for DL and has nothing to do
wihich RT priorities as identified by the RT policy.

Correct the comment, valid RT priorities are in the range from 1 to 99.

Reported-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 Documentation/scheduler/sched-rt-group.txt | 2 +-
 include/linux/sched/prio.h                 | 2 +-
 kernel/sched/cpupri.h                      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/scheduler/sched-rt-group.txt b/Documentation/scheduler/sched-rt-group.txt
index d8fce3e784574..23f8f8465a775 100644
--- a/Documentation/scheduler/sched-rt-group.txt
+++ b/Documentation/scheduler/sched-rt-group.txt
@@ -175,7 +175,7 @@ get their allocated time.
 
 Implementing SCHED_EDF might take a while to complete. Priority Inheritance is
 the biggest challenge as the current linux PI infrastructure is geared towards
-the limited static priority levels 0-99. With deadline scheduling you need to
+the limited static priority levels 1-99. With deadline scheduling you need to
 do deadline inheritance (since priority is inversely proportional to the
 deadline delta (deadline - now)).
 
diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index 7d64feafc408e..6986c32356842 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -8,7 +8,7 @@
 
 /*
  * Priority of a process goes from 0..MAX_PRIO-1, valid RT
- * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
+ * priority is 1..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
  * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
  * values are inverted: lower p->prio value means higher priority.
  *
diff --git a/kernel/sched/cpupri.h b/kernel/sched/cpupri.h
index 7dc20a3232e72..40257a97fb8f2 100644
--- a/kernel/sched/cpupri.h
+++ b/kernel/sched/cpupri.h
@@ -5,7 +5,7 @@
 #define CPUPRI_INVALID		-1
 #define CPUPRI_IDLE		 0
 #define CPUPRI_NORMAL		 1
-/* values 2-101 are RT priorities 0-99 */
+/* values 2-101 are RT priorities 1-99 */
 
 struct cpupri_vec {
 	atomic_t		count;
-- 
2.20.1


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

* Re: [PATCH] sched: Document that RT task priorities are 1…99
  2019-04-03 21:08 [PATCH] sched: Document that RT task priorities are 1…99 Sebastian Andrzej Siewior
@ 2019-04-03 21:17 ` John Ogness
  2019-04-04  7:45   ` John Ogness
  2019-04-16  8:13 ` [tip:sched/core] sched/core: Document that RT task priorities are 1...99 tip-bot for Sebastian Andrzej Siewior
  2019-06-17 12:24 ` [PATCH] sched: Document that RT task priorities are 1…99 Peter Zijlstra
  2 siblings, 1 reply; 10+ messages in thread
From: John Ogness @ 2019-04-03 21:17 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: linux-kernel, Ingo Molnar, Peter Zijlstra, tglx

On 2019-04-03, Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> John identified three files which claim that RT task priorities start at
> zero. As far as I understand, 0 is used for DL and has nothing to do
> wihich RT priorities as identified by the RT policy.
>
> Correct the comment, valid RT priorities are in the range from 1 to 99.
>
> Reported-by: John Ogness <john.ogness@linutronix.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  Documentation/scheduler/sched-rt-group.txt | 2 +-
>  include/linux/sched/prio.h                 | 2 +-
>  kernel/sched/cpupri.h                      | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/scheduler/sched-rt-group.txt b/Documentation/scheduler/sched-rt-group.txt
> index d8fce3e784574..23f8f8465a775 100644
> --- a/Documentation/scheduler/sched-rt-group.txt
> +++ b/Documentation/scheduler/sched-rt-group.txt
> @@ -175,7 +175,7 @@ get their allocated time.
>  
>  Implementing SCHED_EDF might take a while to complete. Priority Inheritance is
>  the biggest challenge as the current linux PI infrastructure is geared towards
> -the limited static priority levels 0-99. With deadline scheduling you need to
> +the limited static priority levels 1-99. With deadline scheduling you need to
>  do deadline inheritance (since priority is inversely proportional to the
>  deadline delta (deadline - now)).
>  
> diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
> index 7d64feafc408e..6986c32356842 100644
> --- a/include/linux/sched/prio.h
> +++ b/include/linux/sched/prio.h
> @@ -8,7 +8,7 @@
>  
>  /*
>   * Priority of a process goes from 0..MAX_PRIO-1, valid RT
> - * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
> + * priority is 1..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH

Actually, valid RT priority is 0..MAX_RT_PRIO-2 (0-98). This comment is
talking about the kernel representation, not the userspace one.

>   * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
>   * values are inverted: lower p->prio value means higher priority.
>   *
> diff --git a/kernel/sched/cpupri.h b/kernel/sched/cpupri.h
> index 7dc20a3232e72..40257a97fb8f2 100644
> --- a/kernel/sched/cpupri.h
> +++ b/kernel/sched/cpupri.h
> @@ -5,7 +5,7 @@
>  #define CPUPRI_INVALID		-1
>  #define CPUPRI_IDLE		 0
>  #define CPUPRI_NORMAL		 1
> -/* values 2-101 are RT priorities 0-99 */
> +/* values 2-101 are RT priorities 1-99 */

I suppose this also should be 0-98.

>  
>  struct cpupri_vec {
>  	atomic_t		count;

IMHO it is a bit crazy that userspace RT prio 99 maps to kernel prio
0. This leaves a hole at kernel prio 99. Wouldn't it be better just to
map userspace RT prio 1-99 to kernel prio 99-1?

John Ogness

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

* Re: [PATCH] sched: Document that RT task priorities are 1…99
  2019-04-03 21:17 ` John Ogness
@ 2019-04-04  7:45   ` John Ogness
  0 siblings, 0 replies; 10+ messages in thread
From: John Ogness @ 2019-04-04  7:45 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: linux-kernel, Ingo Molnar, Peter Zijlstra, tglx

On 2019-04-03, John Ogness <john.ogness@linutronix.de> wrote:
> IMHO it is a bit crazy that userspace RT prio 99 maps to kernel prio
> 0. This leaves a hole at kernel prio 99. Wouldn't it be better just to
> map userspace RT prio 1-99 to kernel prio 99-1?

FWIW, the current mapping:

    userspace         kernel
    ---------         ------
    rt 1...99         98...0
    nice -20...+19    100...139

has been in place since the introduction of Ingo's scalable scheduler:

Author: linus1 <torvalds@athlon.transmeta.com>
Date:   Sun Dec 16 12:00:00 2001 -0800

    v2.5.1.9 -> v2.5.1.10
    
    - Kai Germaschewski: ISDN updates
    - Al Viro: start moving buffer cache indexing to "struct
    - block_device *"
    - Greg KH: USB update
    - Russell King: fix up some ARM merge issues
    - Ingo Molnar: scalable scheduler

With that commit, the then separate nice and rt_priority task_struct
fields were combined to the new prio field, and thus the mapping was
born.

John Ogness

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

* [tip:sched/core] sched/core: Document that RT task priorities are 1...99
  2019-04-03 21:08 [PATCH] sched: Document that RT task priorities are 1…99 Sebastian Andrzej Siewior
  2019-04-03 21:17 ` John Ogness
@ 2019-04-16  8:13 ` tip-bot for Sebastian Andrzej Siewior
  2019-04-16  9:36   ` Peter Zijlstra
  2019-06-17 12:24 ` [PATCH] sched: Document that RT task priorities are 1…99 Peter Zijlstra
  2 siblings, 1 reply; 10+ messages in thread
From: tip-bot for Sebastian Andrzej Siewior @ 2019-04-16  8:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bigeasy, peterz, hpa, mingo, linux-kernel, torvalds, john.ogness, tglx

Commit-ID:  37a8f8590f307db8f8cfa62dfd82b3fc0978607c
Gitweb:     https://git.kernel.org/tip/37a8f8590f307db8f8cfa62dfd82b3fc0978607c
Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Wed, 3 Apr 2019 23:08:21 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 16 Apr 2019 10:06:08 +0200

sched/core: Document that RT task priorities are 1...99

John identified three files which claim that RT task priorities start at
zero. As far as I understand, 0 is used for DL and has nothing to do
wihich RT priorities as identified by the RT policy.

Correct the comment, valid RT priorities are in the range from 1 to 99.

Reported-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20190403210821.10916-1-bigeasy@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 Documentation/scheduler/sched-rt-group.txt | 2 +-
 include/linux/sched/prio.h                 | 2 +-
 kernel/sched/cpupri.h                      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/scheduler/sched-rt-group.txt b/Documentation/scheduler/sched-rt-group.txt
index d8fce3e78457..23f8f8465a77 100644
--- a/Documentation/scheduler/sched-rt-group.txt
+++ b/Documentation/scheduler/sched-rt-group.txt
@@ -175,7 +175,7 @@ get their allocated time.
 
 Implementing SCHED_EDF might take a while to complete. Priority Inheritance is
 the biggest challenge as the current linux PI infrastructure is geared towards
-the limited static priority levels 0-99. With deadline scheduling you need to
+the limited static priority levels 1-99. With deadline scheduling you need to
 do deadline inheritance (since priority is inversely proportional to the
 deadline delta (deadline - now)).
 
diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index 7d64feafc408..6986c3235684 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -8,7 +8,7 @@
 
 /*
  * Priority of a process goes from 0..MAX_PRIO-1, valid RT
- * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
+ * priority is 1..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
  * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
  * values are inverted: lower p->prio value means higher priority.
  *
diff --git a/kernel/sched/cpupri.h b/kernel/sched/cpupri.h
index 7dc20a3232e7..40257a97fb8f 100644
--- a/kernel/sched/cpupri.h
+++ b/kernel/sched/cpupri.h
@@ -5,7 +5,7 @@
 #define CPUPRI_INVALID		-1
 #define CPUPRI_IDLE		 0
 #define CPUPRI_NORMAL		 1
-/* values 2-101 are RT priorities 0-99 */
+/* values 2-101 are RT priorities 1-99 */
 
 struct cpupri_vec {
 	atomic_t		count;

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

* Re: [tip:sched/core] sched/core: Document that RT task priorities are 1...99
  2019-04-16  8:13 ` [tip:sched/core] sched/core: Document that RT task priorities are 1...99 tip-bot for Sebastian Andrzej Siewior
@ 2019-04-16  9:36   ` Peter Zijlstra
  2019-04-16  9:47     ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Zijlstra @ 2019-04-16  9:36 UTC (permalink / raw)
  To: bigeasy, hpa, mingo, linux-kernel, torvalds, tglx, john.ogness
  Cc: linux-tip-commits

On Tue, Apr 16, 2019 at 01:13:11AM -0700, tip-bot for Sebastian Andrzej Siewior wrote:
> Commit-ID:  37a8f8590f307db8f8cfa62dfd82b3fc0978607c
> Gitweb:     https://git.kernel.org/tip/37a8f8590f307db8f8cfa62dfd82b3fc0978607c
> Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> AuthorDate: Wed, 3 Apr 2019 23:08:21 +0200
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Tue, 16 Apr 2019 10:06:08 +0200
> 
> sched/core: Document that RT task priorities are 1...99
> 
> John identified three files which claim that RT task priorities start at
> zero. As far as I understand, 0 is used for DL and has nothing to do
> wihich RT priorities as identified by the RT policy.

DL is -1, 0 is still very much FIFO/FF


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

* Re: [tip:sched/core] sched/core: Document that RT task priorities are 1...99
  2019-04-16  9:36   ` Peter Zijlstra
@ 2019-04-16  9:47     ` Sebastian Andrzej Siewior
  2019-04-16 11:22       ` Peter Zijlstra
  2019-04-16 12:43       ` John Ogness
  0 siblings, 2 replies; 10+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-04-16  9:47 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: hpa, mingo, linux-kernel, torvalds, tglx, john.ogness, linux-tip-commits

On 2019-04-16 11:36:34 [+0200], Peter Zijlstra wrote:
> On Tue, Apr 16, 2019 at 01:13:11AM -0700, tip-bot for Sebastian Andrzej Siewior wrote:
> > Commit-ID:  37a8f8590f307db8f8cfa62dfd82b3fc0978607c
> > Gitweb:     https://git.kernel.org/tip/37a8f8590f307db8f8cfa62dfd82b3fc0978607c
> > Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > AuthorDate: Wed, 3 Apr 2019 23:08:21 +0200
> > Committer:  Ingo Molnar <mingo@kernel.org>
> > CommitDate: Tue, 16 Apr 2019 10:06:08 +0200
> > 
> > sched/core: Document that RT task priorities are 1...99
> > 
> > John identified three files which claim that RT task priorities start at
> > zero. As far as I understand, 0 is used for DL and has nothing to do
> > wihich RT priorities as identified by the RT policy.
> 
> DL is -1, 0 is still very much FIFO/FF

but it can't be set. The lowest we can set is 1. Is this a bug then?

Sebastian

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

* Re: [tip:sched/core] sched/core: Document that RT task priorities are 1...99
  2019-04-16  9:47     ` Sebastian Andrzej Siewior
@ 2019-04-16 11:22       ` Peter Zijlstra
  2019-04-16 12:08         ` Sebastian Andrzej Siewior
  2019-04-16 12:43       ` John Ogness
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Zijlstra @ 2019-04-16 11:22 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: hpa, mingo, linux-kernel, torvalds, tglx, john.ogness, linux-tip-commits

On Tue, Apr 16, 2019 at 11:47:27AM +0200, Sebastian Andrzej Siewior wrote:
> On 2019-04-16 11:36:34 [+0200], Peter Zijlstra wrote:
> > On Tue, Apr 16, 2019 at 01:13:11AM -0700, tip-bot for Sebastian Andrzej Siewior wrote:
> > > Commit-ID:  37a8f8590f307db8f8cfa62dfd82b3fc0978607c
> > > Gitweb:     https://git.kernel.org/tip/37a8f8590f307db8f8cfa62dfd82b3fc0978607c
> > > Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > > AuthorDate: Wed, 3 Apr 2019 23:08:21 +0200
> > > Committer:  Ingo Molnar <mingo@kernel.org>
> > > CommitDate: Tue, 16 Apr 2019 10:06:08 +0200
> > > 
> > > sched/core: Document that RT task priorities are 1...99
> > > 
> > > John identified three files which claim that RT task priorities start at
> > > zero. As far as I understand, 0 is used for DL and has nothing to do
> > > wihich RT priorities as identified by the RT policy.
> > 
> > DL is -1, 0 is still very much FIFO/FF
> 
> but it can't be set. The lowest we can set is 1. Is this a bug then?

What cannot be set?

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

* Re: [tip:sched/core] sched/core: Document that RT task priorities are 1...99
  2019-04-16 11:22       ` Peter Zijlstra
@ 2019-04-16 12:08         ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 10+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-04-16 12:08 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: hpa, mingo, linux-kernel, torvalds, tglx, john.ogness, linux-tip-commits

On 2019-04-16 13:22:35 [+0200], Peter Zijlstra wrote:
> On Tue, Apr 16, 2019 at 11:47:27AM +0200, Sebastian Andrzej Siewior wrote:
> > On 2019-04-16 11:36:34 [+0200], Peter Zijlstra wrote:
> > > On Tue, Apr 16, 2019 at 01:13:11AM -0700, tip-bot for Sebastian Andrzej Siewior wrote:
> > > > Commit-ID:  37a8f8590f307db8f8cfa62dfd82b3fc0978607c
> > > > Gitweb:     https://git.kernel.org/tip/37a8f8590f307db8f8cfa62dfd82b3fc0978607c
> > > > Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > > > AuthorDate: Wed, 3 Apr 2019 23:08:21 +0200
> > > > Committer:  Ingo Molnar <mingo@kernel.org>
> > > > CommitDate: Tue, 16 Apr 2019 10:06:08 +0200
> > > > 
> > > > sched/core: Document that RT task priorities are 1...99
> > > > 
> > > > John identified three files which claim that RT task priorities start at
> > > > zero. As far as I understand, 0 is used for DL and has nothing to do
> > > > wihich RT priorities as identified by the RT policy.
> > > 
> > > DL is -1, 0 is still very much FIFO/FF
> > 
> > but it can't be set. The lowest we can set is 1. Is this a bug then?
> 
> What cannot be set?
|         {
|                 struct sched_param sp;
|                 int r;
| 
|                 sp.sched_priority = 0;
|                 r = sched_setscheduler_nocheck(current, SCHED_FIFO, &sp);
|                 pr_err("%s(%d): %d\n", __func__, __LINE__, r);
| 
|         }

-22 due to

4160 static int __sched_setscheduler(struct task_struct *p,
…
4191         /*
4192          * Valid priorities for SCHED_FIFO and SCHED_RR are
4193          * 1..MAX_USER_RT_PRIO-1, valid priority for SCHED_NORMAL,
4194          * SCHED_BATCH and SCHED_IDLE is 0.
4195          */
4196         if ((p->mm && attr->sched_priority > MAX_USER_RT_PRIO-1) ||
4197             (!p->mm && attr->sched_priority > MAX_RT_PRIO-1))
4198                 return -EINVAL;
4199         if ((dl_policy(policy) && !__checkparam_dl(attr)) ||
4200             (rt_policy(policy) != (attr->sched_priority != 0)))
4201                 return -EINVAL;
                               ↑

Sebastian

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

* Re: [tip:sched/core] sched/core: Document that RT task priorities are 1...99
  2019-04-16  9:47     ` Sebastian Andrzej Siewior
  2019-04-16 11:22       ` Peter Zijlstra
@ 2019-04-16 12:43       ` John Ogness
  1 sibling, 0 replies; 10+ messages in thread
From: John Ogness @ 2019-04-16 12:43 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Peter Zijlstra, hpa, mingo, linux-kernel, torvalds, tglx,
	linux-tip-commits

On 2019-04-16, Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> On 2019-04-16 11:36:34 [+0200], Peter Zijlstra wrote:
>> On Tue, Apr 16, 2019 at 01:13:11AM -0700, tip-bot for Sebastian Andrzej Siewior wrote:
>> > Commit-ID:  37a8f8590f307db8f8cfa62dfd82b3fc0978607c
>> > Gitweb:     https://git.kernel.org/tip/37a8f8590f307db8f8cfa62dfd82b3fc0978607c
>> > Author:     Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> > AuthorDate: Wed, 3 Apr 2019 23:08:21 +0200
>> > Committer:  Ingo Molnar <mingo@kernel.org>
>> > CommitDate: Tue, 16 Apr 2019 10:06:08 +0200
>> > 
>> > sched/core: Document that RT task priorities are 1...99
>> > 
>> > John identified three files which claim that RT task priorities start at
>> > zero. As far as I understand, 0 is used for DL and has nothing to do
>> > wihich RT priorities as identified by the RT policy.
>> 
>> DL is -1, 0 is still very much FIFO/FF
>
> but it can't be set. The lowest we can set is 1. Is this a bug then?

I think it is important to clarify if you are talking about userspace or
kernel. They are different. For userspace 1(low)-99(high) is
allowed. For kernel 0(high)-98(low) is used.

John Ogness

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

* Re: [PATCH] sched: Document that RT task priorities are 1…99
  2019-04-03 21:08 [PATCH] sched: Document that RT task priorities are 1…99 Sebastian Andrzej Siewior
  2019-04-03 21:17 ` John Ogness
  2019-04-16  8:13 ` [tip:sched/core] sched/core: Document that RT task priorities are 1...99 tip-bot for Sebastian Andrzej Siewior
@ 2019-06-17 12:24 ` Peter Zijlstra
  2 siblings, 0 replies; 10+ messages in thread
From: Peter Zijlstra @ 2019-06-17 12:24 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-kernel, Ingo Molnar, tglx, John Ogness, richard

On Wed, Apr 03, 2019 at 11:08:21PM +0200, Sebastian Andrzej Siewior wrote:
> John identified three files which claim that RT task priorities start at
> zero. As far as I understand, 0 is used for DL and has nothing to do
> wihich RT priorities as identified by the RT policy.
> 
> Correct the comment, valid RT priorities are in the range from 1 to 99.

It all depends on what view I'm afraid. User priorities go from 1-99, as
per sched_get_priority_{min,max}(), but Kernel priority is:

 kernel_prio := MAX_RT_PRIO-1 - user_prio

and that then gives [0-98], where 0 is max and 98 is min (see
__sched_setscheduler() and normal_prio()).

And DL uses kernel prio -1 (there is no user prio equivalent).

Nice maps to:

 kernel_prio := MAX_RT_PRIO + (MAX_NICE - MIN_NICE + 1) / 2 + user_nice

which is: [100-139].

Which then, as derRichard says, leaves (kernel) 99 unaccounted for.


> Reported-by: John Ogness <john.ogness@linutronix.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  Documentation/scheduler/sched-rt-group.txt | 2 +-
>  include/linux/sched/prio.h                 | 2 +-
>  kernel/sched/cpupri.h                      | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/scheduler/sched-rt-group.txt b/Documentation/scheduler/sched-rt-group.txt
> index d8fce3e784574..23f8f8465a775 100644
> --- a/Documentation/scheduler/sched-rt-group.txt
> +++ b/Documentation/scheduler/sched-rt-group.txt
> @@ -175,7 +175,7 @@ get their allocated time.
>  
>  Implementing SCHED_EDF might take a while to complete. Priority Inheritance is
>  the biggest challenge as the current linux PI infrastructure is geared towards
> -the limited static priority levels 0-99. With deadline scheduling you need to
> +the limited static priority levels 1-99. With deadline scheduling you need to
>  do deadline inheritance (since priority is inversely proportional to the
>  deadline delta (deadline - now)).
>  

This might be correct,.. but I feel we should strive to delete
everything rt groups.

> diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
> index 7d64feafc408e..6986c32356842 100644
> --- a/include/linux/sched/prio.h
> +++ b/include/linux/sched/prio.h
> @@ -8,7 +8,7 @@
>  
>  /*
>   * Priority of a process goes from 0..MAX_PRIO-1, valid RT
> - * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
> + * priority is 1..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
>   * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
>   * values are inverted: lower p->prio value means higher priority.
>   *

So that comment talks about kernel prio, and there, as we've shown, 0 is
an actual valid RR/FIFO priority (in fact, the highest).

> diff --git a/kernel/sched/cpupri.h b/kernel/sched/cpupri.h
> index 7dc20a3232e72..40257a97fb8f2 100644
> --- a/kernel/sched/cpupri.h
> +++ b/kernel/sched/cpupri.h
> @@ -5,7 +5,7 @@
>  #define CPUPRI_INVALID		-1
>  #define CPUPRI_IDLE		 0
>  #define CPUPRI_NORMAL		 1
> -/* values 2-101 are RT priorities 0-99 */
> +/* values 2-101 are RT priorities 1-99 */

Again, this is kernel prios, not user prios.

>  struct cpupri_vec {
>  	atomic_t		count;
> -- 
> 2.20.1
> 

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

end of thread, other threads:[~2019-06-17 12:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 21:08 [PATCH] sched: Document that RT task priorities are 1…99 Sebastian Andrzej Siewior
2019-04-03 21:17 ` John Ogness
2019-04-04  7:45   ` John Ogness
2019-04-16  8:13 ` [tip:sched/core] sched/core: Document that RT task priorities are 1...99 tip-bot for Sebastian Andrzej Siewior
2019-04-16  9:36   ` Peter Zijlstra
2019-04-16  9:47     ` Sebastian Andrzej Siewior
2019-04-16 11:22       ` Peter Zijlstra
2019-04-16 12:08         ` Sebastian Andrzej Siewior
2019-04-16 12:43       ` John Ogness
2019-06-17 12:24 ` [PATCH] sched: Document that RT task priorities are 1…99 Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.