Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp718434imm; Wed, 23 May 2018 04:34:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqZ3lkoUilyKCKVRQnVZ0as1Qad77Cl1/AFLlUH15m3dWs/8GCNmAPSN2rxgvOnNW4Bme9l X-Received: by 2002:a65:4d47:: with SMTP id j7-v6mr2008444pgt.19.1527075250804; Wed, 23 May 2018 04:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527075250; cv=none; d=google.com; s=arc-20160816; b=ttvLlcJCdXilQek890vcc3DgZnG5VoGGC06nhnC75SALw4I6/K4YBDLwTtzlUs5+hg Sxjh9Ej0MmXTkdINWQiwcVel4t6HTweS19d0wbHZ9Mvm4RW5lOPbTNYfujeGlitKZSGh +QNZ7o8rvtg4lpdR4LeF4CK/7MTHy3K55fnPfB1j0iIIyI4W1j8tI/7kqMhJE21T8cD7 XC/8oitZwc0rCsOwaqa9ijNZ+drFZ4vnEbi8bGH4dEAnImh8+H11MDt8zlrrLjpFmU4y Co6lEzcIe1gHtZIRhK2422hhgr82YotdraXOP/uvx3LhUFTetZSMnjrDWlAB7YUHNhQZ 3JQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sP8JbzXYLEs4kb0tlUgYexS4wopPPXZ/37WRbk7cPQ8=; b=HsKBN/t/f+3jHjceWtTL0B7wkXJ9bmCmgVxchLCeWmuj2f5bMuisSH98QZvEhXDG2y oCAhZJvAh1mFRl1/+iSzeVpeUqOFkl+AMXVuhtmwc/tBSyE2jDjCEwzhOsMT/jsUjqHO VfX3qUVsQr5aXl0FW31gjo1u8Hv/M2uhyD1rTsCWH6ckR97TvWTmZCkdDIv8Q07Cu+ui b6bXyt75c8xAMuSzwbMOFuUFavBYNK2Nhr2TKvvoUCKy3N0z6j6DZeySTNZwzhRqxHpx YALJVtdK4syMG0DMLLVMdnq3C4YJcBTNOpZ5wwZ3543UvK1P8m7srx9jI1GDhxeLTNdg +Ong== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97-v6si17875538plm.495.2018.05.23.04.33.56; Wed, 23 May 2018 04:34:10 -0700 (PDT) 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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932670AbeEWLdc (ORCPT + 99 others); Wed, 23 May 2018 07:33:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53580 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932529AbeEWLdb (ORCPT ); Wed, 23 May 2018 07:33:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 511684023112; Wed, 23 May 2018 11:33:30 +0000 (UTC) Received: from holly.tpb.lab.eng.brq.redhat.com (unknown [10.43.134.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3169F63F5A; Wed, 23 May 2018 11:33:29 +0000 (UTC) From: Miroslav Lichvar To: linux-kernel@vger.kernel.org Cc: Miroslav Lichvar , Thomas Gleixner , John Stultz , Richard Cochran , Prarit Bhargava Subject: [PATCH RFC] timekeeping: Update multiplier when NTP frequency is set directly Date: Wed, 23 May 2018 13:33:21 +0200 Message-Id: <20180523113321.20404-1-mlichvar@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 23 May 2018 11:33:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 23 May 2018 11:33:30 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mlichvar@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the NTP frequency is set directly from userspace using the ADJ_FREQUENCY or ADJ_TICK timex mode, immediately update the timekeeper's multiplier instead of waiting for the next tick. This removes a hidden non-deterministic delay in setting of the frequency and allows an extremely tight control of the system clock with update rates close to or even exceeding the kernel HZ. Cc: Thomas Gleixner Cc: John Stultz Cc: Richard Cochran Cc: Prarit Bhargava Signed-off-by: Miroslav Lichvar --- kernel/time/timekeeping.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 49cbceef5deb..6922dae7317c 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -2047,10 +2047,6 @@ void update_wall_time(void) tk->tkr_mono.cycle_last, tk->tkr_mono.mask); #endif - /* Check if there's really nothing to do */ - if (offset < real_tk->cycle_interval) - goto out; - /* Do some additional sanity checking */ timekeeping_check_update(tk, offset); @@ -2332,6 +2328,10 @@ int do_adjtimex(struct timex *txc) write_seqcount_end(&tk_core.seq); raw_spin_unlock_irqrestore(&timekeeper_lock, flags); + /* Update the multiplier immediately if frequency was set directly */ + if (txc->modes & (ADJ_FREQUENCY | ADJ_TICK)) + update_wall_time(); + if (tai != orig_tai) clock_was_set(); -- 2.14.3