Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757364AbcLAXLN (ORCPT ); Thu, 1 Dec 2016 18:11:13 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:58584 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750775AbcLAXLM (ORCPT ); Thu, 1 Dec 2016 18:11:12 -0500 Date: Fri, 2 Dec 2016 00:08:21 +0100 (CET) From: Thomas Gleixner To: John Stultz cc: David Gibson , lkml , Liav Rehana , Chris Metcalf , Richard Cochran , Ingo Molnar , Prarit Bhargava , Laurent Vivier , "Christopher S . Hall" , "4.6+" , Peter Zijlstra Subject: Re: [PATCH] timekeeping: Change type of nsec variable to unsigned in its calculation. In-Reply-To: Message-ID: References: <1479531216-25361-1-git-send-email-john.stultz@linaro.org> <20161129235727.GA19891@umbus> <20161201021233.GI19891@umbus> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 709 Lines: 17 On Thu, 1 Dec 2016, John Stultz wrote: > Yes, you're right here and apologies, as I wasn't being precise. In > this case time does go backward, but its limited to within the current > interval (just as it would be with a narrow clocksource wrapping > fully). But without this patch, when the overflow occurs, if the > signed bit is set, the signed shift pulls the sign bits down, the time > can go backwards far beyond the current interval, which causes major > wreckage. Backwards is backwards, no matter how much. Depending on the computation which sees the timejump you can end up with major crap as well. Think NTP, PTP, PPS or whatever is able to tweak timekeeping in really bad ways. Thanks, tglx