sched/cpupri: Remove pri_to_cpu[1]

pri_to_cpu[1] isn't used since cpupri_set(..., newpri) is
never called with newpri = 99.

The valid RT priorities RT1..RT99 (p->rt_priority = [1..99]) map into
cpupri (idx of pri_to_cpu[]) = [2..100]

Current mapping:

p->rt_priority   p->prio   newpri   cpupri

                               -1       -1 (CPUPRI_INVALID)

                              100        0 (CPUPRI_NORMAL)

             1        98       98        2
           ...
            49        50       50       50
            50        49       49       51
           ...
            99         0        0      100

So cpupri = 1 isn't used.

Reduce the size of pri_to_cpu[] by 1 and adapt the cpupri
implementation accordingly. This will save a useless for loop with an
atomic_read in cpupri_find_fitness() calling __cpupri_find().

New mapping:

p->rt_priority   p->prio   newpri   cpupri

                               -1       -1 (CPUPRI_INVALID)

                              100        0 (CPUPRI_NORMAL)

             1        98       98        1
           ...
            49        50       50       49
            50        49       49       50
           ...
            99         0        0       99

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200922083934.19275-3-dietmar.eggemann@arm.com
This commit is contained in:
Dietmar Eggemann 2020-09-22 10:39:34 +02:00 committed by Peter Zijlstra
parent 5e054bca44
commit 1b08782ce3
2 changed files with 5 additions and 5 deletions

View file

@ -19,12 +19,12 @@
* in that class). Therefore a typical application without affinity
* restrictions can find a suitable CPU with O(1) complexity (e.g. two bit
* searches). For tasks with affinity restrictions, the algorithm has a
* worst case complexity of O(min(101, nr_domcpus)), though the scenario that
* worst case complexity of O(min(100, nr_domcpus)), though the scenario that
* yields the worst case search is fairly contrived.
*/
#include "sched.h"
/* Convert between a 140 based task->prio, and our 101 based cpupri */
/* Convert between a 140 based task->prio, and our 100 based cpupri */
static int convert_prio(int prio)
{
int cpupri;
@ -34,7 +34,7 @@ static int convert_prio(int prio)
else if (prio >= MAX_RT_PRIO)
cpupri = CPUPRI_NORMAL;
else
cpupri = MAX_RT_PRIO - prio;
cpupri = MAX_RT_PRIO - prio - 1;
return cpupri;
}

View file

@ -1,10 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0 */
#define CPUPRI_NR_PRIORITIES (MAX_RT_PRIO + 1)
#define CPUPRI_NR_PRIORITIES MAX_RT_PRIO
#define CPUPRI_INVALID -1
#define CPUPRI_NORMAL 0
/* values 2-100 are RT priorities 0-99 */
/* values 1-99 are for RT1-RT99 priorities */
struct cpupri_vec {
atomic_t count;