Will Deacon | 23 Mar 18:36 2010

[PATCH] sched: prevent compiler from optimising sched_avg_update loop

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 [taken against 2.6.34-rc2] replaces the loop with a call to
div_s64 which allows the Kernel to link.

Cc: Catalin Marinas <catalin.marinas <at> arm.com>
Cc: Ingo Molnar <mingo <at> elte.hu>
Cc: Andrew Morton <akpm <at> linux-foundation.org>
Cc: Peter Zijlstra <peterz <at> infradead.org>
Signed-off-by: Will Deacon <will.deacon <at> arm.com>
---
 kernel/sched.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 9ab3cd7..6b74f21 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
 <at>  <at>  -1238,11 +1238,10  <at>  <at>  static u64 sched_avg_period(void)
 static void sched_avg_update(struct rq *rq)
 {
 	s64 period = sched_avg_period();
+	s64 elapsed_periods = div_s64(rq->clock - rq->age_stamp - 1, period);
(Continue reading)

Eric Dumazet | 23 Mar 18:53 2010
Picon

Re: [PATCH] sched: prevent compiler from optimising sched_avg_update loop

Le mardi 23 mars 2010 à 17:36 +0000, Will Deacon a écrit :
> 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 [taken against 2.6.34-rc2] replaces the loop with a call to
> div_s64 which allows the Kernel to link.
> 
> Cc: Catalin Marinas <catalin.marinas <at> arm.com>
> Cc: Ingo Molnar <mingo <at> elte.hu>
> Cc: Andrew Morton <akpm <at> linux-foundation.org>
> Cc: Peter Zijlstra <peterz <at> infradead.org>
> Signed-off-by: Will Deacon <will.deacon <at> arm.com>
> ---
>  kernel/sched.c |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 9ab3cd7..6b74f21 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
>  <at>  <at>  -1238,11 +1238,10  <at>  <at>  static u64 sched_avg_period(void)
>  static void sched_avg_update(struct rq *rq)
>  {
>  	s64 period = sched_avg_period();
(Continue reading)

Peter Zijlstra | 23 Mar 19:08 2010

Re: [PATCH] sched: prevent compiler from optimising sched_avg_update loop

On Tue, 2010-03-23 at 17:36 +0000, Will Deacon wrote:
> 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 [taken against 2.6.34-rc2] replaces the loop with a call to
> div_s64 which allows the Kernel to link.
> 
> Cc: Catalin Marinas <catalin.marinas <at> arm.com>
> Cc: Ingo Molnar <mingo <at> elte.hu>
> Cc: Andrew Morton <akpm <at> linux-foundation.org>
> Cc: Peter Zijlstra <peterz <at> infradead.org>
> Signed-off-by: Will Deacon <will.deacon <at> arm.com>
> ---
>  kernel/sched.c |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 9ab3cd7..6b74f21 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
>  <at>  <at>  -1238,11 +1238,10  <at>  <at>  static u64 sched_avg_period(void)
>  static void sched_avg_update(struct rq *rq)
>  {
>  	s64 period = sched_avg_period();
(Continue reading)

Will Deacon | 23 Mar 20:05 2010

[PATCH] sched: prevent compiler from optimising sched_avg_update loop

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 [taken against 2.6.34-rc2] introduces a fake data hazard to
the loop body to prevent the compiler optimising the loop away.

Cc: Catalin Marinas <catalin.marinas <at> arm.com>
Cc: Ingo Molnar <mingo <at> elte.hu>
Cc: Andrew Morton <akpm <at> linux-foundation.org>
Cc: Peter Zijlstra <peterz <at> infradead.org>
Signed-off-by: Will Deacon <will.deacon <at> arm.com>
---
 kernel/sched.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 9ab3cd7..0846815 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
 <at>  <at>  -1240,6 +1240,12  <at>  <at>  static void sched_avg_update(struct rq *rq)
 	s64 period = sched_avg_period();

 	while ((s64)(rq->clock - rq->age_stamp) > period) {
+		/*
(Continue reading)


Gmane