mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Thomas Gleixner" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
	John Stultz <jstultz@google.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: timers/core] ntp: Read reference time only once
Date: Wed, 02 Oct 2024 15:44:54 -0000	[thread overview]
Message-ID: <172788389470.1442.1849710502053804594.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-6-2d52f4e13476@linutronix.de>

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     136bccbc2e78d3cd0bd8831e4c5a4509c0ddd945
Gitweb:        https://git.kernel.org/tip/136bccbc2e78d3cd0bd8831e4c5a4509c0ddd945
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Wed, 11 Sep 2024 15:17:42 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 02 Oct 2024 16:53:39 +02:00

ntp: Read reference time only once

The reference time is required twice in ntp_update_offset(). It will not
change in the meantime as the calling code holds the timekeeper lock. Read
it only once and store it into a local variable.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: John Stultz <jstultz@google.com>
Link: https://lore.kernel.org/all/20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-6-2d52f4e13476@linutronix.de

---
 kernel/time/ntp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 905b021..0bfd07d 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -283,9 +283,8 @@ static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
 
 static void ntp_update_offset(long offset)
 {
-	s64 freq_adj;
-	s64 offset64;
-	long secs;
+	s64 freq_adj, offset64;
+	long secs, real_secs;
 
 	if (!(time_status & STA_PLL))
 		return;
@@ -303,11 +302,12 @@ static void ntp_update_offset(long offset)
 	 * Select how the frequency is to be controlled
 	 * and in which mode (PLL or FLL).
 	 */
-	secs = (long)(__ktime_get_real_seconds() - time_reftime);
+	real_secs = __ktime_get_real_seconds();
+	secs = (long)(real_secs - time_reftime);
 	if (unlikely(time_status & STA_FREQHOLD))
 		secs = 0;
 
-	time_reftime = __ktime_get_real_seconds();
+	time_reftime = real_secs;
 
 	offset64    = offset;
 	freq_adj    = ntp_update_offset_fll(offset64, secs);

  parent reply	other threads:[~2024-10-02 15:44 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11 13:17 [PATCH 00/21] ntp: Rework to prepare support of indenpendent PTP clocks Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 01/21] ntp: Remove unused tick_nsec Anna-Maria Behnsen
2024-09-11 20:06   ` John Stultz
2024-10-02 15:44   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-09-11 13:17 ` [PATCH 02/21] ntp: Make tick_usec static Anna-Maria Behnsen
2024-09-11 20:28   ` John Stultz
2024-10-02 15:44   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-09-11 13:17 ` [PATCH 03/21] ntp: Clean up comments Anna-Maria Behnsen
2024-09-11 20:08   ` John Stultz
2024-10-02 15:44   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-09-11 13:17 ` [PATCH 04/21] ntp: Cleanup formatting of code Anna-Maria Behnsen
2024-09-11 20:11   ` John Stultz
2024-10-02 15:44   ` [tip: timers/core] " tip-bot2 for Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 05/21] ntp: Convert functions with only two states to bool Anna-Maria Behnsen
2024-09-11 20:12   ` John Stultz
2024-10-02 15:44   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-09-11 13:17 ` [PATCH 06/21] ntp: Read reference time only once Anna-Maria Behnsen
2024-09-11 20:00   ` John Stultz
2024-10-02 15:44   ` tip-bot2 for Thomas Gleixner [this message]
2024-09-11 13:17 ` [PATCH 07/21] ntp: Introduce struct ntp_data Anna-Maria Behnsen
2024-09-11 20:20   ` John Stultz
2024-10-02 15:44   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-09-11 13:17 ` [PATCH 08/21] ntp: Move tick_length* into ntp_data Anna-Maria Behnsen
2024-09-11 20:23   ` John Stultz
2024-10-02 15:44   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-09-11 13:17 ` [PATCH 09/21] ntp: Move tick_stat* " Anna-Maria Behnsen
2024-09-11 20:25   ` John Stultz
2024-10-02 15:44   ` [tip: timers/core] " tip-bot2 for Thomas Gleixner
2024-09-11 13:17 ` [PATCH 10/21] ntp: Move time_offset/constant " Anna-Maria Behnsen
2024-09-11 20:27   ` John Stultz
2024-09-11 13:17 ` [PATCH 11/21] ntp: Move time_max/esterror " Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 12/21] ntp: Move time_freq/reftime " Anna-Maria Behnsen
2024-09-11 20:30   ` John Stultz
2024-09-11 13:17 ` [PATCH 13/21] ntp: Move time_adj/ntp_tick_adj " Anna-Maria Behnsen
2024-09-11 20:36   ` John Stultz
2024-09-11 13:17 ` [PATCH 14/21] ntp: Move ntp_next_leap_sec " Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 15/21] ntp: Move pps_valid " Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 16/21] ntp: Move pps_ft " Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 17/21] ntp: Move pps_jitter " Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 18/21] ntp: Move pps_fbase " Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 19/21] ntp: Move pps_shift/intcnt " Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 20/21] ntp: Move pps_freq/stabil " Anna-Maria Behnsen
2024-09-11 13:17 ` [PATCH 21/21] ntp: Move pps monitors " Anna-Maria Behnsen
2024-09-12  8:12 ` [PATCH 00/21] ntp: Rework to prepare support of indenpendent PTP clocks Miroslav Lichvar
2024-09-13  3:59   ` Richard Cochran
2024-09-13 10:28   ` Anna-Maria Behnsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=172788389470.1442.1849710502053804594.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=anna-maria@linutronix.de \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®