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: Move tick_length* into ntp_data
Date: Wed, 02 Oct 2024 15:44:53 -0000	[thread overview]
Message-ID: <172788389341.1442.10707408136353919336.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240911-devel-anna-maria-b4-timers-ptp-ntp-v1-8-2d52f4e13476@linutronix.de>

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

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

ntp: Move tick_length* into ntp_data

Continue the conversion from static variables to struct based data.

No functional change.

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-8-2d52f4e13476@linutronix.de

---
 kernel/time/ntp.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index f95f233..2430e69 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -25,20 +25,21 @@
 /**
  * struct ntp_data - Structure holding all NTP related state
  * @tick_usec:		USER_HZ period in microseconds
+ * @tick_length:	Adjusted tick length
+ * @tick_length_base:	Base value for @tick_length
  *
  * Protected by the timekeeping locks.
  */
 struct ntp_data {
 	unsigned long		tick_usec;
+	u64			tick_length;
+	u64			tick_length_base;
 };
 
 static struct ntp_data tk_ntp_data = {
 	.tick_usec		= USER_TICK_USEC,
 };
 
-static u64			tick_length;
-static u64			tick_length_base;
-
 #define SECS_PER_DAY		86400
 #define MAX_TICKADJ		500LL		/* usecs */
 #define MAX_TICKADJ_SCALED \
@@ -263,8 +264,8 @@ static void ntp_update_frequency(struct ntp_data *ntpdata)
 	 * Don't wait for the next second_overflow, apply the change to the
 	 * tick length immediately:
 	 */
-	tick_length		+= new_base - tick_length_base;
-	tick_length_base	 = new_base;
+	ntpdata->tick_length		+= new_base - ntpdata->tick_length_base;
+	ntpdata->tick_length_base	 = new_base;
 }
 
 static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
@@ -341,8 +342,8 @@ static void __ntp_clear(struct ntp_data *ntpdata)
 
 	ntp_update_frequency(ntpdata);
 
-	tick_length	= tick_length_base;
-	time_offset	= 0;
+	ntpdata->tick_length	= ntpdata->tick_length_base;
+	time_offset		= 0;
 
 	ntp_next_leap_sec = TIME64_MAX;
 	/* Clear PPS state variables */
@@ -360,7 +361,7 @@ void ntp_clear(void)
 
 u64 ntp_tick_length(void)
 {
-	return tick_length;
+	return tk_ntp_data.tick_length;
 }
 
 /**
@@ -391,6 +392,7 @@ ktime_t ntp_get_next_leap(void)
  */
 int second_overflow(time64_t secs)
 {
+	struct ntp_data *ntpdata = &tk_ntp_data;
 	s64 delta;
 	int leap = 0;
 	s32 rem;
@@ -451,11 +453,11 @@ int second_overflow(time64_t secs)
 	}
 
 	/* Compute the phase adjustment for the next second */
-	tick_length	 = tick_length_base;
+	ntpdata->tick_length	 = ntpdata->tick_length_base;
 
-	delta		 = ntp_offset_chunk(time_offset);
-	time_offset	-= delta;
-	tick_length	+= delta;
+	delta			 = ntp_offset_chunk(time_offset);
+	time_offset		-= delta;
+	ntpdata->tick_length	+= delta;
 
 	/* Check PPS signal */
 	pps_dec_valid();
@@ -465,18 +467,18 @@ int second_overflow(time64_t secs)
 
 	if (time_adjust > MAX_TICKADJ) {
 		time_adjust -= MAX_TICKADJ;
-		tick_length += MAX_TICKADJ_SCALED;
+		ntpdata->tick_length += MAX_TICKADJ_SCALED;
 		goto out;
 	}
 
 	if (time_adjust < -MAX_TICKADJ) {
 		time_adjust += MAX_TICKADJ;
-		tick_length -= MAX_TICKADJ_SCALED;
+		ntpdata->tick_length -= MAX_TICKADJ_SCALED;
 		goto out;
 	}
 
-	tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
-							 << NTP_SCALE_SHIFT;
+	ntpdata->tick_length += (s64)(time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ)
+				<< NTP_SCALE_SHIFT;
 	time_adjust = 0;
 
 out:

  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: timers/core] " tip-bot2 for Thomas Gleixner
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-bot2 for Thomas Gleixner [this message]
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=172788389341.1442.10707408136353919336.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®