Skip to content

Commit 80d767d

Browse files
Mikulas PatockaKAGA-KOKO
authored andcommitted
time: Fix overflow when HZ is smaller than 60
When compiling for the IA-64 ski emulator, HZ is set to 32 because the emulation is slow and we don't want to waste too many cycles processing timers. Alpha also has an option to set HZ to 32. This causes integer underflow in kernel/time/jiffies.c: kernel/time/jiffies.c:66:2: warning: large integer implicitly truncated to unsigned type [-Woverflow] .mult = NSEC_PER_JIFFY << JIFFIES_SHIFT, /* details above */ ^ This patch reduces the JIFFIES_SHIFT value to avoid the overflow. Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1401241639100.23871@file01.intranet.prod.int.rdu2.redhat.com Cc: stable@vger.kernel.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 38dbfb5 commit 80d767d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎kernel/time/jiffies.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@
5151
* HZ shrinks, so values greater than 8 overflow 32bits when
5252
* HZ=100.
5353
*/
54+
#if HZ < 34
55+
#define JIFFIES_SHIFT 6
56+
#elif HZ < 67
57+
#define JIFFIES_SHIFT 7
58+
#else
5459
#define JIFFIES_SHIFT 8
60+
#endif
5561

5662
static cycle_t jiffies_read(struct clocksource *cs)
5763
{

0 commit comments

Comments
 (0)