Skip to contentSkip to conversation

2.6.8.1: xtime value may become incorrect

DISCUSSION Vladimir Grouzdev 2 participants 2 messages Sep 27, 2004

lore
Share & tools
lore
#0 lore raw

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,

#1 lore raw
Quoted 5 lines · Vladimir Grouzdev

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