Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2168935pxb; Mon, 11 Jan 2021 02:49:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5UuIQmgOyJFsLMWbf7gSTU6CB7NteiVRI/md2V0Hp+tYzVZoiYdqFfuFCTsLxC31HYhk0 X-Received: by 2002:a05:6402:1646:: with SMTP id s6mr13559041edx.319.1610362186945; Mon, 11 Jan 2021 02:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610362186; cv=none; d=google.com; s=arc-20160816; b=V2RL+n+nHuJcxbFIebU0f1Zz+YVdANuQ7YeA4UM1bTZCHbfXTi95CX2gi3tUQNoEjS XpRRC0UhsWzMSUTPxWvNOjpmraaeP+EsAmovHkyX+dmX5Bb7HwZgywp6ueeMjkldnjGa lMdhIruhZMiRjSvrFiOVV6S/gUgO5VxBU4QgE5Zq0/5Wzdn22ZW0EnJUZujIHqH3Gss6 OWQCfvSSvoxD1uPU4YAPemvQ22ynHYY0RgC59SlUR9DOcvP3eaplsGb4J42TduYXWrmT PCnre50IJmAG6u3v03vfhlfVr4KwRJuDjDgSrPqJ2nu2lDedbMGRtLB85LXJya7qS0Ws 7Zeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=4fymldqGOkaY/X4BCR3dG+yWyFLPZhv3fozV8pGd9vo=; b=UsNqnZZYLeLm8wwaw3ILYTNmodda9pdaZFd9jD5TDUGRv4uW9sgNCmnmNddaUFCZ6X w//ap9IOX7GyeRF0dFxdkk0tIp6D59mL86j1zRnZoPY8E6vX6B5yXa+Oycx26MSYk/l1 jpPVGZsHFssW2gPMpDc4EsowSACV9YpFhHxmsZvlAN3zb/rGcu+THSOqYuXUkkky1Lod aBoTXrETS6Gi1EETbtoRp5u3D6CpI4DX9CCckscW+woV9uoKlo+fEl1EO22RFuRlSkor O5RyErfXggxoOHm1nVAH894wiGgkPP8GcncoDvtKBsu+UVWivSclJIVBS9S/8FozDJDE Fjlw== ARC-Authentication-Results: i=1; mx.google.com; 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 w11si5313449ejc.533.2021.01.11.02.49.23; Mon, 11 Jan 2021 02:49:46 -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; 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 S1729403AbhAKKov (ORCPT + 99 others); Mon, 11 Jan 2021 05:44:51 -0500 Received: from mail-ot1-f48.google.com ([209.85.210.48]:36661 "EHLO mail-ot1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729305AbhAKKou (ORCPT ); Mon, 11 Jan 2021 05:44:50 -0500 Received: by mail-ot1-f48.google.com with SMTP id d20so16480065otl.3 for ; Mon, 11 Jan 2021 02:44:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4fymldqGOkaY/X4BCR3dG+yWyFLPZhv3fozV8pGd9vo=; b=S1kHnCAV3ZU19h64W3seHu+/rNGnN7Qyz6kFPYw8jsl8Nz47vCuFH/nDiJHS5fi8Z1 JD9pfkA3rgYCZIi+5Yu16BDqwpomM/ycE2E377TtR2RzmBZDUG0kHxCpXj8WTC9ML/iA kGTglcNwh5i0fD1T+d3w0jKkElTNCDjlcqzO3NpioYP/5aA8a35b836FL+T2CKakj7y/ qY/2qeuJvILtvhfcmutcaP6P4h7HH3LUa4YVXMap6Sm5kcecfYvbCmburtffraNqQWe/ rHw9MrDufpALyXWmexNAar+PFujABU3KvJ9lwkM6C6n7jdg5jbnDn0RmvxVAcPrgXyY7 jppQ== X-Gm-Message-State: AOAM532wRexoSw6BvUZWqiufRDaettwvGxaZxJqydzHXCfoe00rOEqBe WJ2zaEnvX43ZQUJbl6FT4pC3439Db3d35Rt8sWRLsGUjgPY= X-Received: by 2002:a9d:c01:: with SMTP id 1mr10382183otr.107.1610361849532; Mon, 11 Jan 2021 02:44:09 -0800 (PST) MIME-Version: 1.0 References: <20210111103956.290378-1-geert+renesas@glider.be> In-Reply-To: <20210111103956.290378-1-geert+renesas@glider.be> From: Geert Uytterhoeven Date: Mon, 11 Jan 2021 11:43:58 +0100 Message-ID: Subject: Re: [PATCH] ntp: Fix RTC synchronization on 32-bit platforms To: Thomas Gleixner Cc: John Stultz , Jason Gunthorpe , Alexandre Belloni , Stephen Boyd , Linux Kernel Mailing List , Geert Uytterhoeven Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021 at 11:40 AM Geert Uytterhoeven wrote: > Due to an integer overflow, RTC synchronization now happens every 2s > instead of the intended 11 minutes. Fix this by forcing 64-bit > arithmetic for the sync period calculation. > > Fixes: c9e6189fb03123a7 ("ntp: Make the RTC synchronization more reliable") > Signed-off-by: Geert Uytterhoeven > --- > kernel/time/ntp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c > index 7404d38315276a96..54d52fab201d283e 100644 > --- a/kernel/time/ntp.c > +++ b/kernel/time/ntp.c > @@ -498,7 +498,7 @@ int second_overflow(time64_t secs) > static void sync_hw_clock(struct work_struct *work); > static DECLARE_WORK(sync_work, sync_hw_clock); > static struct hrtimer sync_hrtimer; > -#define SYNC_PERIOD_NS (11UL * 60 * NSEC_PER_SEC) > +#define SYNC_PERIOD_NS (11ULL * 60 * NSEC_PER_SEC) > > static enum hrtimer_restart sync_timer_callback(struct hrtimer *timer) > { While the line exp = ktime_add_ns(exp, 2 * NSEC_PER_SEC - offset_nsec); is currently not an issue, it may be wise to change it to exp = ktime_add_ns(exp, 2ULL * NSEC_PER_SEC - offset_nsec); in case someone wants to experiment with values larger then 4s? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds