Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933285Ab0G3Snh (ORCPT ); Fri, 30 Jul 2010 14:43:37 -0400 Received: from kroah.org ([198.145.64.141]:35875 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932314Ab0G3RfH (ORCPT ); Fri, 30 Jul 2010 13:35:07 -0400 X-Mailbox-Line: From gregkh@clark.site Fri Jul 30 10:31:09 2010 Message-Id: <20100730173109.398607672@clark.site> User-Agent: quilt/0.48-11.2 Date: Fri, 30 Jul 2010 10:30:39 -0700 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: stable-review@kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Will Deacon , Peter Zijlstra , Catalin Marinas , Russell King , Ingo Molnar Subject: [074/140] sched: Prevent compiler from optimising the sched_avg_update() loop In-Reply-To: <20100730173205.GA22581@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1846 Lines: 55 2.6.33-stable review patch. If anyone has any objections, please let us know. ------------------ From: Will Deacon commit 0d98bb2656e9bd2dfda2d089db1fe1dbdab41504 upstream. 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': kernel/sched.c:1261: undefined reference to `__aeabi_uldivmod' 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 Signed-off-by: Andrew Morton Acked-by: Peter Zijlstra Cc: Catalin Marinas Cc: Russell King Cc: Linus Torvalds Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- kernel/sched.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1259,6 +1259,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; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/