Re: [PATCH] sched/cpupri: fix cpupri_find() for high priority tasks

From: Steven Rostedt
Date: Sun Apr 13 2014 - 09:40:46 EST


On Wed, 09 Apr 2014 05:50:10 +0200
Mike Galbraith <umgwanakikbuti@xxxxxxxxx> wrote:

> Hi Steven,
>
> Seems c92211d9b7727 introduced a buglet.
>
> --snip--
>
> Bail on task_pri >= MAX_RT_PRIO excludes userspace prio 98 and 99 tasks,
> which map to 100 and 101 respectively.
>
> A user reported that given two SCHED_RR tasks, one hog, one light, the light
> task may be stacked on top of the hog iff prio >= 98, latency hit follows.
>
> Signed-off-by: Mike Galbraith <umgwanakikbuti@xxxxxxxxx>
> Cc: <stable@xxxxxxxxxxxxxxx>
> Fixes: c92211d9b7727 sched/cpupri: Remove the vec->lock
> ---
> kernel/sched/cpupri.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> --- a/kernel/sched/cpupri.c
> +++ b/kernel/sched/cpupri.c
> @@ -70,9 +70,6 @@ int cpupri_find(struct cpupri *cp, struc
> int idx = 0;
> int task_pri = convert_prio(p->prio);
>
> - if (task_pri >= MAX_RT_PRIO)
> - return 0;

task_pri is used as an index into pri_to_cpu. Although I don't see how
this can be called for a non RT task, the safer solution is below.

-- Steve

> -
> for (idx = 0; idx < task_pri; idx++) {
> struct cpupri_vec *vec = &cp->pri_to_cpu[idx];
> int skip = 0;
>