Re: [PATCH] sched: rt_rq runtime leakage bug fix

From: Cheng Xu
Date: Thu May 12 2011 - 06:55:40 EST


On 5/12/2011 18:12, Peter Zijlstra wrote:
> On Thu, 2011-05-12 at 01:30 +0800, Cheng Xu wrote:
>>
>> I tried but hit a boot-time error "Unable to handle kernel paging
>> request for data at address 0x100000008", and therefore would like to
>> propose an alternative patch like,
>>
> I probably made a silly mistake somehwere, it was after all something
> quickly typed in an email :-)
>
>> #define for_each_rt_rq(rt_rq, iter, rq) \
>> for (iter = list_entry_rcu(task_groups.next, typeof(*iter), list); \
>> (&iter->list != &task_groups) && (rt_rq = iter->rt_rq[cpu_of(rq)]); \
>> iter = list_entry_rcu(iter->list.next, typeof(*iter), list))
>>
>> This worked, it seems to pass the tests. Is this correct from a scheduler perspective?
>
> Creative ;-), it would be nice to know why the , operator version
> doesn't work though, since that looks to be the more conventional way to
> write it.

Yes I am also wondering why it doesn't work. will look into it and get
back to you later.

>
> That said, I don't see a problem with using your existing on.
>
>> For the not CONFIG_RT_GROUP_SCHED part, I used
>>
>> typedef struct rt_rq *rt_rq_iter_t;
>>
>> #define for_each_rt_rq(rt_rq, iter, rq) \
>> (void) iter; \
>> for (rt_rq = &rq->rt; rt_rq; rt_rq = NULL)
>>
>> An alternative is
>> #define for_each_rt_rq(rt_rq, iter, rq) \
>> for (rt_rq = iter = &rq->rt; iter; rt_rq = iter = NULL)
>
> Tough call that, the first has a multi-statement macro, which is
> generally discouraged because then:
>
> for()
> for_each_rt_rq() {
> }
>
> will not work as expected, so I think we want the second version.

Agree, I realized this problem soon after sending out the email
yesterday, :) and improved it to be

#define for_each_rt_rq(rt_rq, iter, rq) \
for ((void) iter, rt_rq = &rq->rt; rt_rq; rt_rq = NULL)

maybe we can still use it?

>
>> The patch is attached below. Could you check whether it is workable? Thank you.
>
> Yes, given how things are I can't really see it getting any better,
> thanks!
>

I have updated the patch content according to the comments, and done
part of the test. will send out the complete second version for your
review soon.

Thank you very much!

> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/