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

From: Peter Zijlstra
Date: Thu May 12 2011 - 06:09:35 EST


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.

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.

> 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!

--
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/