mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Will Deacon <will.deacon@arm.com>
Cc: linux-kernel@vger.kernel.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] sched: prevent compiler from optimising sched_avg_update loop
Date: Tue, 23 Mar 2010 18:53:24 +0100	[thread overview]
Message-ID: <1269366804.2983.300.camel@edumazet-laptop> (raw)
In-Reply-To: <1269365805-17280-1-git-send-email-will.deacon@arm.com>

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@arm.com>
> Cc: Ingo Molnar <mingo@elte.hu>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Will Deacon <will.deacon@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
> @@ -1238,11 +1238,10 @@ 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);
>  
> -	while ((s64)(rq->clock - rq->age_stamp) > period) {
> -		rq->age_stamp += period;
> -		rq->rt_avg /= 2;
> -	}
> +	rq->age_stamp += (u64)(elapsed_periods * period);
> +	rq->rt_avg >>= elapsed_periods;
>  }
>  
>  static void sched_rt_avg_update(struct rq *rq, u64 rt_delta)

Please take a look at __iter_div_u64_rem() , because we had a similar
problem in the past. We want to avoid this div_s64() call.




  reply	other threads:[~2010-03-23 17:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-23 17:36 Will Deacon
2010-03-23 17:53 ` Eric Dumazet [this message]
     [not found]   ` <000101cacab3$25af90a0$710eb1e0$@deacon@arm.com>
2010-03-23 18:10     ` Peter Zijlstra
2010-03-23 18:08 ` Peter Zijlstra
2010-03-23 19:05 ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1269366804.2983.300.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®