Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756682AbbDPH4m (ORCPT ); Thu, 16 Apr 2015 03:56:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44536 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753012AbbDPH4f (ORCPT ); Thu, 16 Apr 2015 03:56:35 -0400 Date: Thu, 16 Apr 2015 09:56:33 +0200 From: Miroslav Lichvar To: Justin Keller Cc: linux-kernel@vger.kernel.org, John Stultz , Thomas Gleixner , Prarit Bhargava , Richard Cochran , Arnd Bergmann Subject: Re: [RFC][PATCH] timekeeping: Limit system time to prevent 32-bit time_t overflow Message-ID: <20150416075633.GA7968@localhost> References: <1429112488-12574-1-git-send-email-mlichvar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1447 Lines: 33 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/