Re: [PATCH] fix potential jiffies overflow

From: Andrew Morton
Date: Thu Mar 02 2006 - 22:48:04 EST


Atsushi Nemoto <anemo@xxxxxxxxxxxxx> wrote:
>
> >>>>> On Thu, 2 Mar 2006 18:45:02 -0800, Andrew Morton <akpm@xxxxxxxx> said:
> akpm> Thanks, that looks like 2.6.16 material.
>
> akpm> What happens if the machine slept for more than 49.7 days?
>
> Well, jiffies will lose 49.7 days... Then, how about this? We can
> sleep 136 years.
>
> Signed-off-by: Atsushi Nemoto <anemo@xxxxxxxxxxxxx>
>
> diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
> index a14d594..be5d079 100644
> --- a/arch/i386/kernel/time.c
> +++ b/arch/i386/kernel/time.c
> @@ -400,7 +400,7 @@ static int timer_resume(struct sys_devic
> {
> unsigned long flags;
> unsigned long sec;
> - unsigned long sleep_length;
> + u64 sleep_length;
>
> #ifdef CONFIG_HPET_TIMER
> if (is_hpet_enabled())
> @@ -408,7 +408,7 @@ static int timer_resume(struct sys_devic
> #endif
> setup_pit_timer();
> sec = get_cmos_time() + clock_cmos_diff;
> - sleep_length = (get_cmos_time() - sleep_start) * HZ;
> + sleep_length = (u64)(get_cmos_time() - sleep_start) * HZ;
> write_seqlock_irqsave(&xtime_lock, flags);
> xtime.tv_sec = sec;
> xtime.tv_nsec = 0;

but...

wall_jiffies += sleep_length;

wall_jiffies is 32-bit.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/