Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp412313pxu; Tue, 1 Dec 2020 14:39:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzXxhc6m4TdD1OSMiuRMlc+W+P5sb7U1ICCzIV+x1zyZAtNlyJNkkFvuNk0xQXciR5xy8RG X-Received: by 2002:a17:906:cec3:: with SMTP id si3mr4429306ejb.277.1606862341099; Tue, 01 Dec 2020 14:39:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606862341; cv=none; d=google.com; s=arc-20160816; b=YMp+2B6xFUSM/sQ7YixSGmv6jB8Sk7G6dcwNHKwrl7qpJGmUzvo+q8Y9VmP4jnd1AW WGzD3UB4uIJHRLwPvXxyUd4XXYIlB4QVb3M6meaUK4l7Vg7P2CXGmEL5yfHvooClKA2X 6K1I97tiBKKQD4itkFn82FZE6baXLkgzCzh2GJdvf7OupgXGHRCmZy0BIytRL04qL+5M hsOao6IpXCyj/dzrprdnjaalM6DJdi7nNB3IR9PQYqciBr3wwTbyWP2nOTc7XhLj+g+a WJrOrxCqjejbtY5AgXch/GhrOyfQg0yfhcwv2Oy3kWdGDWv47Q9kiLj7topwdgypMlhh pvmw== 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=Pv6Mzxor2+R5OnRVrZEMoeinj6r+eUiZ62bCMKojMyI=; b=1JKtXoSIUg5oYeB8fpQdxytC4DCQxRg6lwgJt1Js1GUyHdSqo6FKpKg/hGXuNVo1vB bMk0mTgQxJvR8qzRBl9ph/bY/Nn4PMrk7IQHbMfGzTap77pSUwH3f3gGJLA/WPCX1nrm f0VNaIACDPmCDmEB03BS+aEEEzSlKC6pr7cJP9ffmwCzJBAQxLNYfWtplR8+YbBhy9vU xPbqXqJBWG1KUrnCEADX4l4KtT00TxgUh7Z6sceuVfHctP6Hk7++uqRPv9h54cd3PRgj dkUOnPLdJ40waOTiqrQ7wHHNr+x+VUgco3ERSGeCotGlDRGpmO2juTOM1cGYdQcPjJ6Q cRVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=dYwCu16k; 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 u2si849818ejo.343.2020.12.01.14.38.38; Tue, 01 Dec 2020 14:39:01 -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=dYwCu16k; 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 S2404053AbgLAQNN (ORCPT + 99 others); Tue, 1 Dec 2020 11:13:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388364AbgLAQNM (ORCPT ); Tue, 1 Dec 2020 11:13:12 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E643DC0613CF for ; Tue, 1 Dec 2020 08:12:26 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id b144so1732987qkc.13 for ; Tue, 01 Dec 2020 08:12:26 -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=Pv6Mzxor2+R5OnRVrZEMoeinj6r+eUiZ62bCMKojMyI=; b=dYwCu16kBnubHryi3fTziiQM5QEe7RTg51IUCeYj/YQRiKYeBdFBQsxofehvYiU64V M9OAxZTvCKL+UOzp/TqY5MThox2muiT8b0GUL8d6pnWRxm4X944WMMbS6Smm4eYcKQ85 y/Kh0133C3FxOhhhi5qbuiBorNqIOPxo+7B6fgNw9G7Z7tj6zu95Nfy3K9SWMNkO5T7r DHjY7lnOy2ZxsUF1VXoI3K1O06jAx8SsypyJ2N7rp/MSHr2x+zMJuN/sFrgO5LQ+SINY e5ACiUtDHp0pbCjVHkOW81OK2C61cW3xUq0KGnvzbMCCrqTrQiFgXny7l47lyNLd1us4 01hw== 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=Pv6Mzxor2+R5OnRVrZEMoeinj6r+eUiZ62bCMKojMyI=; b=VRMHZsepPRGgK0OWdTHTRIPqmCyHObCLxARsJDZazKHqAWrUa4ELrRtFB48gBCQ89N KRqGplW7L4aASANzwSPrkZOrI55cZq7L4XD3uDiZVDbA4DC7d0CUHe77lZqseZdeNuno Aa62x9SpFOIjcvm+Pqdlal9bUGBjO5sGzk0v4Qwk5uFzWGzvcFr7yqT1ipphvnyKB7Qr LIZzDJqWtgu8Oz5AOrQ4fpEye5rC+94nPMeg/+DbNEMheVJXylrguNgUfU5k5HRyh6UP PiVdWxW9/9hMXr3qZw1ggWm0xmWzTGVAuXuVKtzjTHIt6hrAjakogwQaXdjgNKk6IQKN GnYA== X-Gm-Message-State: AOAM5316nPEBuN8HET42ijeEWex9pj4GSVK7nFZzDwTyTytQTPqUfjeg lwh3L4qgNux9Li76pBu8NrRYCA== X-Received: by 2002:a05:620a:132d:: with SMTP id p13mr3622067qkj.233.1606839146116; Tue, 01 Dec 2020 08:12:26 -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 b64sm34463qkg.19.2020.12.01.08.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 08:12:25 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kk8GO-004Td8-Jn; Tue, 01 Dec 2020 12:12:24 -0400 Date: Tue, 1 Dec 2020 12:12:24 -0400 From: Jason Gunthorpe To: Miroslav Lichvar Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , John Stultz , Prarit Bhargava Subject: Re: [PATCH] rtc: adapt allowed RTC update error Message-ID: <20201201161224.GF5487@ziepe.ca> References: <20201201143835.2054508-1-mlichvar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201201143835.2054508-1-mlichvar@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01, 2020 at 03:38:35PM +0100, Miroslav Lichvar wrote: > When the system clock is marked as synchronized via adjtimex(), the > kernel is expected to copy the system time to the RTC every 11 minutes. > > There are reports that it doesn't always work reliably. It seems the > current requirement for the RTC update to happen within 5 ticks of the > target time in some cases can consistently fail for hours or even days. > > It is better to set the RTC with a larger error than let it drift for > too long. > > Add a static variable to rtc_tv_nsec_ok() to count the checks. With each > failed check, relax the requirement by one jiffie, and reset the counter > when it finally succeeds. This should allow the RTC update to happen in > a minute at most. > > Signed-off-by: Miroslav Lichvar > Cc: Thomas Gleixner > Cc: John Stultz > Cc: Prarit Bhargava > Cc: Jason Gunthorpe > include/linux/rtc.h | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/include/linux/rtc.h b/include/linux/rtc.h > index 22d1575e4991..8d105f10ef6a 100644 > +++ b/include/linux/rtc.h > @@ -218,21 +218,30 @@ static inline bool rtc_tv_nsec_ok(s64 set_offset_nsec, > struct timespec64 *to_set, > const struct timespec64 *now) > { > - /* Allowed error in tv_nsec, arbitarily set to 5 jiffies in ns. */ > - const unsigned long TIME_SET_NSEC_FUZZ = TICK_NSEC * 5; > struct timespec64 delay = {.tv_sec = 0, > .tv_nsec = set_offset_nsec}; > + unsigned long time_set_nsec_fuzz; > + static unsigned int attempt; Adding a static value instide a static inline should not be done I'm not sure using a static like this is the best idea anyhow, if you want something like this it should be per-rtc, not global Did you look at why time has become so in-accurate in your system? 5 jiffies is usually a pretty long time? Jason