Re: [RFC][PATCH] Catch xtime_nsec underflows and fix them

From: Roman Zippel
Date: Wed Dec 03 2008 - 11:10:03 EST


Hi,

On Wed, 3 Dec 2008, Zhang, Yanmin wrote:

> > > When ïïxtime_nsec underflows at the first time, xtime.tv_nsec becomes -1.
> > > Later on when the second tick arrives, below statement in the while loop
> > > clock->xtime_nsec += clock->xtime_interval;
> > > will cause ïclock->xtime_nsec becomes positive again. So the second tick
> > > appears a going-backward time.
> >
> > Yes, but only by 1nsec, so normally it wouldn't be noticable.
> Not 1nsec. At the second tick, go back about 4294967296 nsec (2^32), about
> 4 seconds. That matches the output of testing process.

Above code is not the problem. The error appeared in do_vgettimeofday() as
it only uses unsigned values, so the -1 became 0xffffffff in nsec and the
clock jumped forward 4 seconds and a tick later 4 seconds back.

bye, Roman