The patch titled sched: prevent compiler from optimising sched_avg_update loop has been added to the -mm tree. Its filename is sched-prevent-compiler-from-optimising-sched_avg_update-loop.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: sched: prevent compiler from optimising sched_avg_update loop From: Will Deacon <will.deacon@xxxxxxx> GCC 4.4.1 on ARM has been observed to replace the while loop in sched_avg_update with a call to uldivmod, resulting in the following build failure at link-time: kernel/built-in.o: In function `sched_avg_update': /linux-2.6/kernel/sched.c:1261: undefined reference to `__aeabi_uldivmod' /linux-2.6/kernel/sched.c:1261: undefined reference to `__aeabi_uldivmod' make: *** [.tmp_vmlinux1] Error 1 This patch introduces a fake data hazard to the loop body to prevent the compiler optimising the loop away. Signed-off-by: Will Deacon <will.deacon@xxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Cc: Russell King <rmk@xxxxxxxxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/sched.c | 6 ++++++ 1 file changed, 6 insertions(+) diff -puN kernel/sched.c~sched-prevent-compiler-from-optimising-sched_avg_update-loop kernel/sched.c --- a/kernel/sched.c~sched-prevent-compiler-from-optimising-sched_avg_update-loop +++ a/kernel/sched.c @@ -1240,6 +1240,12 @@ static void sched_avg_update(struct rq * s64 period = sched_avg_period(); while ((s64)(rq->clock - rq->age_stamp) > period) { + /* + * Inline assembly required to prevent the compiler + * optimising this loop into a divmod call. + * See __iter_div_u64_rem() for another example of this. + */ + asm("" : "+rm" (rq->age_stamp)); rq->age_stamp += period; rq->rt_avg /= 2; } _ Patches currently in -mm which might be from will.deacon@xxxxxxx are linux-next.patch sched-prevent-compiler-from-optimising-sched_avg_update-loop.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html