From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753983AbbEKPiP (ORCPT ); Mon, 11 May 2015 11:38:15 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:49207 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753347AbbEKPiK (ORCPT ); Mon, 11 May 2015 11:38:10 -0400 From: Arnd Bergmann To: Tina Ruchandani Cc: "Ed L. Cashin" , y2038@lists.linaro.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] aoe: Use 64-bit timestamp in frame Date: Mon, 11 May 2015 17:38:03 +0200 Message-ID: <2958316.132LBl1X80@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20150511023505.GA2714@tinar> References: <20150511023505.GA2714@tinar> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:eitUOoNCFUzgiouxoF33YNRNwc/1N5n5U8zfZcIRvabYfw8OSry jHB6mP74XVuwAyOEiim0Ygv5WaLRZGUK1BMtoNTPB0aBgH2hTIET+ZDMKu3ReWg9OPdObhC f/9kf/clxMH+jrrEvcfe0T2NH0RyBiTFXMyDxpcvW/KWLcUYkORfxz1l0BAGDAij5vyZ8RW 8n+FVsxxA8oluWWDOB3SQ== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 11 May 2015 08:05:05 Tina Ruchandani wrote: > 'struct frame' uses two variables to store the sent timestamp - 'struct > timeval' and jiffies. jiffies is used to avoid discrepancies caused by > updates to system time. 'struct timeval' uses 32-bit representation for > seconds which will overflow in year 2038. > This patch does the following: > - Replace the use of 'struct timeval' and jiffies with ktime_t, which > is a 64-bit timestamp and is year 2038 safe. > - ktime_t provides both long range (like jiffies) and high resolution > (like timeval). Using ktime_get (monotonic time) instead of wall-clock > time prevents any discprepancies caused by updates to system time. > > Signed-off-by: Tina Ruchandani Very nice! > @@ -499,32 +497,15 @@ resend(struct aoedev *d, struct frame *f) > static int > tsince_hr(struct frame *f) > { > - struct timeval now; > + ktime_t now; > int n; > > - do_gettimeofday(&now); > - n = now.tv_usec - f->sent.tv_usec; > - n += (now.tv_sec - f->sent.tv_sec) * USEC_PER_SEC; > + now = ktime_get(); > + n = ktime_to_us(ktime_sub(now, f->sent)); > I would cut four extra lines by writing this as return ktime_us_delta(ktime_get(), f->sent)); but the effect is exactly the same. With that change, please add Reviewed-by: Arnd Bergmann Arnd