Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp483008pxu; Fri, 4 Dec 2020 07:59:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyb4KRe3wTIJzqSCPSiqZGRBxvOaYbz6GcuDFMxh7U3iEHCjZgf9ukeUI1SlORxWkQj38+X X-Received: by 2002:a05:6402:559:: with SMTP id i25mr8242376edx.128.1607097599699; Fri, 04 Dec 2020 07:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607097599; cv=none; d=google.com; s=arc-20160816; b=I2x5m8qqv+oQGKehYabCNwyaDvvHFPaXSR8r2wQFVogfT5oXrwlGMdVcxt6QsbwVuG Y7n0BPAssCUZCLw4TrKF43emo30IB0DRc9CcZVGwZF11aRAH7k0zef5d0W4TnxU1Ytlv FbaJRsUtPHl1Zur9jHnToAHJQxhFORItn+b0vJhGLcs7quCxk+OAqw/wuCH1GU8gSaWg qGhSjRlfBSN/E8w2N1NzbNo2caCzcu9EzTaYKFRe2uN30Z7Zpn8Ux/aWd0mOvy94P5Ao mzPBJ23VIgemgpYRJaatxatMdGsBeTUi7+OEp2L8yZ9NJhGPJXezf8SjjsLHpdjBoZvH SmEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xiuRU5gjXIm9XOVD+WEIsXlsJb8C9JaURz+n0lPMd1E=; b=neaUjxOR93Yyg1bPz4ka/lXM620E2IvHkvKBi51FJuVSMe7f6n0tj3Ml9q5uaI+6uy ATIHuVbowCT3gbA9DBDIP4J/6tw0+80G8e8EzLAox5sPXeeCqBu77wA7RcBb82M3kUQR gdlYTcd4PHjadYs/daLzzTpUXunPYTG/0HJMy7gf0IO0KDJxEcIFsj9Yrdl4zK+mKnat VTPFphSF/hpAGQHSH2iQT5d9i5VQpkqv7V1J1JdTDf7cKUbn5i8Cj1cndTTSpo+5Pazw PE87vd4GCdrCy6yqTjH10IWqtufAsoDunRODQ9XMojQ6Hdej/z2fyJTzqioVPZ5L8I0C ItaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=OoNzvPR6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t14si3301604edy.67.2020.12.04.07.59.36; Fri, 04 Dec 2020 07:59:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=OoNzvPR6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729787AbgLDP5v (ORCPT + 99 others); Fri, 4 Dec 2020 10:57:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727381AbgLDP5u (ORCPT ); Fri, 4 Dec 2020 10:57:50 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7BA5C061A51 for ; Fri, 4 Dec 2020 07:57:10 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id b144so5759318qkc.13 for ; Fri, 04 Dec 2020 07:57:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=xiuRU5gjXIm9XOVD+WEIsXlsJb8C9JaURz+n0lPMd1E=; b=OoNzvPR6tta9qFPmGEZPxv16PRpJ8m9Xsr7MpTtZiRB34AsjeRiFblkofygVNn1SIX yQ6c/LTmKsRbFKH22ohxRCverE9PiYwmBwKt+WSERBtv/XEX2HiXcHdgAz+ewJLR382n 2YbExCBDyUaO1vgnBg79ahsyox4uJqjMctIgM2C123oTKHgcR4+htP+OEHtk/riPviOM 5HiO1F6BtGFrYZyBkZGWARoLJL3lUObUSmspF996TTbx8gMjPno5j+UPzMmQAvdEjFH4 nk0GifIObwFA3+6JKKKUAOngOpueTJ4uvodZdWyHN886s6GCWTUs+qorHDqCTYHPoNDK zQSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xiuRU5gjXIm9XOVD+WEIsXlsJb8C9JaURz+n0lPMd1E=; b=hgqD+qGgKeHMi3Pt/5Kff+w7pjrMijaPzGTS0TQJDH2/m6hVkdE69JkBx9+jXSk1xP PpzuSFMnnNr+45znK8XvNBXR0NyoK04YmMpRfx5lKaUzrIGBaTwQrI//H6Cl2etJig2d dbw75y/7dCoorWjbTE3v8yOfi0B4FbzRK5G/PG73KNCC9Vf743XiPCwE39fyAe6Jcz1p EHnnFRssF4hYu8t8Rp4xcOA9JsRxGlV+64ht5if2wDVrLgxZUSJYRsBPCQzY5PV4YpJH eOXjGpu7zLMnB09PZKuz/NoqFtTz++ij1LQ+t8SQM4LSZJ/ps3JL2P5o/9//UUUoBiZg v77w== X-Gm-Message-State: AOAM531KFNbs7wCZHL3H7R3BMKQa1Kt2rtN4wh+JE+MOjvAsNp1Nz/Aw wBHbZxlM/yvdP0LpQZ9wwxCdrw== X-Received: by 2002:a05:620a:806:: with SMTP id s6mr9366450qks.193.1607097429916; Fri, 04 Dec 2020 07:57:09 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id c65sm5075664qkf.47.2020.12.04.07.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 07:57:09 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1klDSG-005vNM-6L; Fri, 04 Dec 2020 11:57:08 -0400 Date: Fri, 4 Dec 2020 11:57:08 -0400 From: Jason Gunthorpe To: Alexandre Belloni Cc: Thomas Gleixner , Miroslav Lichvar , linux-kernel@vger.kernel.org, John Stultz , Prarit Bhargava , Alessandro Zummo , linux-rtc@vger.kernel.org, Peter Zijlstra Subject: Re: [PATCH] rtc: adapt allowed RTC update error Message-ID: <20201204155708.GB5487@ziepe.ca> References: <87pn3qdhli.fsf@nanos.tec.linutronix.de> <20201203161622.GA1317829@ziepe.ca> <87zh2ubny2.fsf@nanos.tec.linutronix.de> <87wnxybmqx.fsf@nanos.tec.linutronix.de> <20201203223646.GA1335797@ziepe.ca> <877dpxbu66.fsf@nanos.tec.linutronix.de> <20201204140819.GX5487@ziepe.ca> <20201204143735.GI74177@piout.net> <20201204144659.GY5487@ziepe.ca> <20201204150857.GJ74177@piout.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201204150857.GJ74177@piout.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 04, 2020 at 04:08:57PM +0100, Alexandre Belloni wrote: > > I mean literatally time the excution of something like a straight > > read. This will give some estimate of the bus latency and it should > > linearly relate to the bus latency for a write. > > > It doesn't, some rtc will require writing dozen registers to set the > time and reading only 3 to get the time, the only accurate way is to > really time setting the time. You set the RTC time once, set up an alarm for > the next second, once you get the alarm, you get system time and you now > how far you are off. This is why I said linearly related. Yes the relation is per-driver, based on the ops required, but in principle it can get close. > Notice that systohc could do that if you wanted to be accurate and then > the whole issue with mc146818 is gone and this nicely solves it for all > the RTCs at once. Another good solution is to have systohc progam the time and then immediately read it back (eg with an alarm). The difference between the read back and the system RTC is the single value to plug into the adjustment offset and naturally includes all the time factors Thomas identified, including the additional factor of 'latency to read the time' > > The goal was to bring the system to correct time as quickly as > > possible in as many cases as possible, not to maintain the > > monotonicity of the realtime clock. > > I'm really curious, in your use case, couldn't you have read the RTC > from userspace and set the system time from there, right before starting > NTP and other applications? This was RAM constrainted embedded, a few hundred bytes of kernel code wins over 100k of userspace > Doing so, you would have probably been able to ensure monotonicity. No, this case also wasn't willing to wait the 1s to load the time. It had to go parallel with the rest of the boot up. This was enterprise gear, boot time to operational counts against the achievable availability rating. From an upstream perspective this was hacky because - We historically try not to create non-monotinicity in CLOCK_REALTIME because too much stuff wrongly works on CLOCK_REALTIME when they really need CLOCK_MONOTONIC - Having the kernel async set the clock is racy with NTP also trying to set the clock But in a closed system the two above were delt with reliably. > > As I said before, if there is no desire to address the read side then > > the whole thing should be abandoned. > > What was your plan back in 2017? Well I was helping RMK because we had similar issues, but I saw some path to achive the low offset round trip, and view this as laudable for the embedded world. I see I also changed jobs right around then which probably explains why things stopped at this one patch. The fact nobody else picked it up probably says people really just don't care about realtime accuracy. Jason