Skip to content

Commit

Permalink
sched_clock: Fix integer overflow
Browse files Browse the repository at this point in the history
The expression '(1 << 32)' happens to evaluate as 0 on ARM, but
it evaluates as 1 on xtensa and x86_64. This zeros sched_clock_mask,
and breaks sched_clock().

Set the type of 1 to 'unsigned long long' to get the value we need.

Reported-by: Max Filippov <jcmvbkbc@gmail.com>
Tested-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: John Stultz <john.stultz@linaro.org>
  • Loading branch information
Baruch Siach authored and John Stultz committed Jul 22, 2013
1 parent b0ec636 commit 53c0352
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/time/sched_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
BUG_ON(bits > 32);
WARN_ON(!irqs_disabled());
read_sched_clock = read;
sched_clock_mask = (1 << bits) - 1;
sched_clock_mask = (1ULL << bits) - 1;
cd.rate = rate;

/* calculate the mult/shift to convert counter ticks to ns. */
Expand Down

0 comments on commit 53c0352

Please sign in to comment.