2004-09-27 15:22:54

by Vladimir Grouzdev

[permalink] [raw]
Subject: 2.6.8.1: xtime value may become incorrect


The xtime value may become incorrect when the
update_wall_time(ticks) function is called with "ticks" > 1.
In such a case, the xtime variable is updated multiple times
inside the loop but it is normalized only once outside of
the loop.

This bug was reported at:

http://bugme.osdl.org/show_bug.cgi?id=3403

Patch to fix the problem:

diff -Nrca linux-2.6.8.1/kernel/timer.c linux-2.6.8.1-patched/kernel/timer.c
*** linux-2.6.8.1/kernel/timer.c 2004-08-14 12:56:00.000000000 +0200
--- linux-2.6.8.1-patched/kernel/timer.c 2004-09-27
16:24:48.000000000 +0200
***************
*** 776,788 ****
do {
ticks--;
update_wall_time_one_tick();
} while (ticks);
-
- if (xtime.tv_nsec >= 1000000000) {
- xtime.tv_nsec -= 1000000000;
- xtime.tv_sec++;
- second_overflow();
- }
}

static inline void do_process_times(struct task_struct *p,
--- 776,787 ----
do {
ticks--;
update_wall_time_one_tick();
+ if (xtime.tv_nsec >= 1000000000) {
+ xtime.tv_nsec -= 1000000000;
+ xtime.tv_sec++;
+ second_overflow();
+ }
} while (ticks);
}

static inline void do_process_times(struct task_struct *p,



2004-09-27 15:52:20

by john stultz

[permalink] [raw]
Subject: Re: 2.6.8.1: xtime value may become incorrect

On Mon, 2004-09-27 at 08:22, Vladimir Grouzdev wrote:
> The xtime value may become incorrect when the
> update_wall_time(ticks) function is called with "ticks" > 1.
> In such a case, the xtime variable is updated multiple times
> inside the loop but it is normalized only once outside of
> the loop.

Vladimir,
This looks like a good patch to me. If no one else has any complaints,
send it on to Andrew.

thanks!
-john