Re: [PATCH] sched: fix priority leakage in pick_next_highest_task_rt()

From: Yong Zhang
Date: Mon May 16 2011 - 22:29:06 EST


On Mon, May 16, 2011 at 8:55 PM, Hillf Danton <dhillf@xxxxxxxxx> wrote:
> When picking the second highest RT task for a given runqueue, if no
> task found after scanning the queue of priority == idx, the next idx
> should also be checked even in case that next is already existing, or
> the window of priority leakage could be opened.

I don't see what kind of problem you patch will fix.
And mind explaining how priority leakage could happen?

Thanks,
Yong

>
> Signed-off-by: Hillf Danton <dhillf@xxxxxxxxx>
> ---
>
> --- a/kernel/sched_rt.c 2011-04-27 11:48:50.000000000 +0800
> +++ b/kernel/sched_rt.c 2011-05-16 19:58:42.000000000 +0800
> @@ -1166,6 +1166,8 @@ static struct task_struct *pick_next_hig
> Â Â Â Âint idx;
>
> Â Â Â Âfor_each_leaf_rt_rq(rt_rq, rq) {
> + Â Â Â Â Â Â Â struct task_struct *this;
> +
> Â Â Â Â Â Â Â Âarray = &rt_rq->active;
> Â Â Â Â Â Â Â Âidx = sched_find_first_bit(array->bitmap);
> Ânext_idx:
> @@ -1173,6 +1175,7 @@ next_idx:
> Â Â Â Â Â Â Â Â Â Â Â Âcontinue;
> Â Â Â Â Â Â Â Âif (next && next->prio < idx)
> Â Â Â Â Â Â Â Â Â Â Â Âcontinue;
> + Â Â Â Â Â Â Â this = NULL;
> Â Â Â Â Â Â Â Âlist_for_each_entry(rt_se, array->queue + idx, run_list) {
> Â Â Â Â Â Â Â Â Â Â Â Âstruct task_struct *p;
>
> @@ -1181,11 +1184,15 @@ next_idx:
>
> Â Â Â Â Â Â Â Â Â Â Â Âp = rt_task_of(rt_se);
> Â Â Â Â Â Â Â Â Â Â Â Âif (pick_rt_task(rq, p, cpu)) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â next = p;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â this = p;
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> Â Â Â Â Â Â Â Â Â Â Â Â}
> Â Â Â Â Â Â Â Â}
> - Â Â Â Â Â Â Â if (!next) {
> + Â Â Â Â Â Â Â if (this != NULL)
> + Â Â Â Â Â Â Â Â Â Â Â next = this;
> + Â Â Â Â Â Â Â else { Â/*
> + Â Â Â Â Â Â Â Â Â Â Â Â* we have to check next idx even if next != NULL
> + Â Â Â Â Â Â Â Â Â Â Â Â*/
> Â Â Â Â Â Â Â Â Â Â Â Âidx = find_next_bit(array->bitmap, MAX_RT_PRIO, idx+1);
> Â Â Â Â Â Â Â Â Â Â Â Âgoto next_idx;
> Â Â Â Â Â Â Â Â}
>



--
Only stand for myself
N‹§²æìr¸›yúèšØb²X¬¶ÇvØ^–)Þ{.nÇ+‰·¥Š{±‘êçzX§¶›¡Ü}©ž²ÆzÚ&j:+v‰¨¾«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹®w¥¢¸?™¨è­Ú&¢)ßf”ù^jÇy§m…á@A«a¶Úÿ 0¶ìh®å’i