lkml.org 
[lkml]   [2015]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2015-04-16 10:21    [W:0.058 / U:1.800 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site