Messages in this thread | | | Date | Thu, 16 Apr 2015 09:56:33 +0200 | From | Miroslav Lichvar <> | Subject | Re: [RFC][PATCH] timekeeping: Limit system time to prevent 32-bit time_t overflow |
| |
On Wed, Apr 15, 2015 at 12:17:36PM -0400, Justin Keller wrote: > Is there a reason for "step = leap"?
It's there to not change the behavior when a leap second occurs, the clock still needs to be stepped. I guess it could be optimized a bit, if it used "if (unlikely(leap || tk->xtime_sec >= time_max_sec))", the 64-bit step variable wouldn't have to be used in normal operation.
> > /* Figure out if its a leap sec and apply if needed */ > > leap = second_overflow(tk->xtime_sec); > > - if (unlikely(leap)) { > > + step = leap; > > + > > + /* If the system time reached the maximum, step it back */ > > + if (unlikely(tk->xtime_sec >= time_max_sec)) { > > + step = time_max_sec - tk->xtime_sec - SEC_PER_WEEK; > > + printk(KERN_NOTICE > > + "Clock: maximum time reached, stepping back\n"); > > + } > > + > > + if (unlikely(step)) { > > struct timespec64 ts; > > > > - tk->xtime_sec += leap; > > + tk->xtime_sec += step;
-- Miroslav Lichvar
| |