Skip to content

Commit

Permalink
time: Workaround gcc loop optimization that causes 64bit div errors
Browse files Browse the repository at this point in the history
Early 4.3 versions of gcc apparently aggressively optimize the raw
time accumulation loop, replacing it with a divide.

On 32bit systems, this causes the following link errors:
	undefined reference to `__umoddi3'
	undefined reference to `__udivdi3'

The gcc issue has been fixed in 4.4 and greater.

This patch replaces the accumulation loop with a do_div, as suggested
by Linus.

Signed-off-by: John Stultz <[email protected]>
CC: Jason Wessel <[email protected]>
CC: Larry Finger <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Linus Torvalds <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
John Stultz authored and torvalds committed Aug 13, 2010
1 parent 2be1f3a commit c7dcf87
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,9 +710,10 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
/* Accumulate raw time */
raw_nsecs = timekeeper.raw_interval << shift;
raw_nsecs += raw_time.tv_nsec;
while (raw_nsecs >= NSEC_PER_SEC) {
raw_nsecs -= NSEC_PER_SEC;
raw_time.tv_sec++;
if (raw_nsecs >= NSEC_PER_SEC) {
u64 raw_secs = raw_nsecs;
raw_nsecs = do_div(raw_secs, NSEC_PER_SEC);
raw_time.tv_sec += raw_secs;
}
raw_time.tv_nsec = raw_nsecs;

Expand Down

0 comments on commit c7dcf87

Please sign in to comment.