Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6592605imu; Wed, 14 Nov 2018 04:07:52 -0800 (PST) X-Google-Smtp-Source: AJdET5eTZmfDRk3Q1xDBZJabiSj4Blt4eaaTM+yyTB3Jy5bBBhNzlQCoTP/NJwHPHY+v5QhaH9gz X-Received: by 2002:a62:a48:: with SMTP id s69mr1763342pfi.136.1542197272092; Wed, 14 Nov 2018 04:07:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542197272; cv=none; d=google.com; s=arc-20160816; b=gtFmyKIz7luigUGhFLD/s5IdOym5J9fsNhEiw/MY56e+Dg63iefQX4rRDM1YRecksl pWVWEsFU07HqYEscmxDC+mOIroMNVpkX8W07zg8eh702NP5VrOziqdGOCyqWd5lYbeH+ 7fgz4M3Sc4ctUgDy/p6vc1WuRntjTMTY8/iGbj2TLLOT2lkU9A1H8DyLSrDjRD/OK8Lo QC3iMigHF/iaiFtsQ9Yj6kJr/WW3tKlTU7k13bs+IkINpzgXMz6wIaTAWFiqHO04ZQTE 4eOndGvx4MIl8E4imyQZXJhAAcJ7eLSNIRtxv+k51Jif4Y19oM4L38+m5fpvOQePDsB4 sA2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=LFTqnV1S4JIKuBgB4a5qr9LQZA4sbsJFMIl8z6BIsUA=; b=Bal6OtqhrZ5JNUXQUI6+nhVgkkAIGPv/2uUHtU/pTzmEEQDrqaBna31T776Cz6rbfH C1b6LNn7iKHQ7LqIsWPa1Y8zIV49rb5GmhYD1b490mEHionCvRBmEFQPNquiT1ssZz1m uxd152REkGxCwJesEkPT7mHGdgQv4xlJ3og3dJMNLXWTExvVFnQPQuBhkHvQpS9xkMs2 XDvox51ABrYsLoE4h6v6KOfbVJt3YJnVUblzKeOsRglq3gK2hk5UZBPLZjrAlwKpdhRr htDw809h7ibhw6960loYUIQbYv1QXdT+dK/mXSW3uSAFTBW3/9+qL/3zsKPWRX1tC7xO K2HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=O586R77W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4-v6si28796526pll.50.2018.11.14.04.07.28; Wed, 14 Nov 2018 04:07:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=O586R77W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732684AbeKNWI2 (ORCPT + 99 others); Wed, 14 Nov 2018 17:08:28 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:42332 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727969AbeKNWI1 (ORCPT ); Wed, 14 Nov 2018 17:08:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LFTqnV1S4JIKuBgB4a5qr9LQZA4sbsJFMIl8z6BIsUA=; b=O586R77W5PI5CBZuEGU83N1RJ PCV1I4eleHO10StVCe0PoCe3ru4foyyAchLQ05jb2MnpovmhuqaFpCDo+ja16JL4+pQ+PjFjp0lUS +cXM/3fzioo7Uea9JmAv0jAHyM3F8g1OeNC96MNLEUAHzIxxsyTvy0lzyvYQQXWZuU46A=; Received: from n2100.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:57870) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gMtuz-0005Dh-Q5; Wed, 14 Nov 2018 12:05:13 +0000 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1gMtus-0006To-14; Wed, 14 Nov 2018 12:05:06 +0000 Date: Wed, 14 Nov 2018 12:05:00 +0000 From: Russell King - ARM Linux To: Finn Thain , John Stultz Cc: Geert Uytterhoeven , Arnd Bergmann , Stephen N Chivers , Thomas Gleixner , Daniel Lezcano , linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [RFC PATCH 01/13] arm: Fix mutual exclusion in arch_gettimeoffset Message-ID: <20181114120500.GE6567@n2100.armlinux.org.uk> References: 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 12, 2018 at 03:12:39PM +1100, Finn Thain wrote: > Implementations of arch_gettimeoffset are generally not re-entrant > and assume that interrupts have been disabled. Unfortunately this > pre-condition got broken in v2.6.32. To me, it looks way worse than what you think. The original code sequence before conversion to arch_gettimeoffset() was: 1. lock (inc. disabling IRQs) 2. read gettimeoffset correction 3. add offset to current xtime 4. unlock This means there is no chance for a timer interrupt to happen between reading the current offset and adding it to the current kernel time. If the timer does roll over, then the interrupt will remain pending, so the whole "read offset and add to xtime" is one atomic block and we can use the pending interrupt to indicate whether the timer has rolled over and apply the appropriate offset correction. With the arch_gettimeoffset() code, that changes: 1. read clocksource (which will be jiffies) 2. compute clocksource delta 3. increment nanoseconds 4. add gettimeoffset correction If we receive a timer interrupt part-way through this, for example, between 2 and 3, then jiffies will increment (via do_timer()) and the interrupt will be cleared. This means that the check in ioc_timer_gettimeoffset() for a pending interrupt, for example, will be false, and we will not know that an interrupt has happened. So, unless I'm missing something, commit 5cfc8ee0bb51 well and truely broke the accuracy of timekeeping on these platforms, and will result in timekeeping spontaneously jumping backwards. I had been wondering why NTP had become less stable on EBSA110, but never investigated. However, that still does not justify blowing away this functionality without replacement, as Finn has been proposing. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up