mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: akpm@osdl.org
Cc: john stultz <johnstul@us.ibm.com>,
	linux-kernel@vger.kernel.org, johnstul@us.ibm.com
Subject: [-mm PATCH 7/11] Time: generic timekeeping infrastructure - wall_offset helper cleanup
Date: Mon, 20 Feb 2006 23:21:46 -0700	[thread overview]
Message-ID: <20060221062146.13304.76302.sendpatchset@cog.beaverton.ibm.com> (raw)
In-Reply-To: <20060221062102.13304.81613.sendpatchset@cog.beaverton.ibm.com>

Cleans up some of the wall_time offset manipulations
with a  __set_wall_time_offset() helper.

Also fixes some whitespaces.

Signed-off-by: John Stultz <johnstul@us.ibm.com>

 Documentation/timekeeping.txt   |    2 
 include/asm-generic/timeofday.h |    2 
 include/linux/time.h            |    7 --
 kernel/time/clocksource.c       |    1 
 kernel/time/timeofday.c         |   97 +++++++++++++++++++---------------------
 kernel/timer.c                  |    1 
 6 files changed, 53 insertions(+), 57 deletions(-)

Index: mm-merge/kernel/timer.c
===================================================================
--- mm-merge.orig/kernel/timer.c
+++ mm-merge/kernel/timer.c
@@ -882,7 +882,6 @@ void ntp_advance(unsigned long interval_
 	write_sequnlock_irqrestore(&ntp_lock, flags);
 }
 
-
 #ifdef CONFIG_GENERIC_TIME
 # define update_wall_time(x) do { } while (0)
 #else
Index: mm-merge/kernel/time/clocksource.c
===================================================================
--- mm-merge.orig/kernel/time/clocksource.c
+++ mm-merge/kernel/time/clocksource.c
@@ -155,6 +155,7 @@ int register_clocksource(struct clocksou
 	spin_unlock_irqrestore(&clocksource_lock, flags);
 	return ret;
 }
+
 EXPORT_SYMBOL(register_clocksource);
 
 /**
Index: mm-merge/kernel/time/timeofday.c
===================================================================
--- mm-merge.orig/kernel/time/timeofday.c
+++ mm-merge/kernel/time/timeofday.c
@@ -338,6 +338,35 @@ void do_gettimeofday(struct timeval *tv)
 EXPORT_SYMBOL(do_gettimeofday);
 
 /**
+ * __increment_system_time - Increments system time
+ * @delta:	nanosecond delta to add to the time variables
+ *
+ * Private helper that increments system_time and related
+ * timekeeping variables.
+ */
+static void __increment_system_time(s64 delta)
+{
+	system_time = ktime_add_ns(system_time, delta);
+	timespec_add_ns(&wall_time_ts, delta);
+	timespec_add_ns(&mono_time_ts, delta);
+}
+
+/**
+ * __set_wall_time_offset - Sets the wall time offset
+ * @delta:	nanosecond delta to adjust to the time variables
+ *
+ * Private helper that adjusts wall_time_offset and related
+ * timekeeping variables.
+ */
+static void __set_wall_time_offset(ktime_t val)
+{
+	wall_time_offset = val;
+	wall_time_ts = ktime_to_timespec(ktime_add(system_time,
+						wall_time_offset));
+	monotonic_time_offset_ts = ktime_to_timespec(wall_time_offset);
+}
+
+/**
  * do_settimeofday - Sets the time of day
  * @tv:		pointer to the timespec variable containing the new time
  *
@@ -356,12 +385,7 @@ int do_settimeofday(struct timespec *tv)
 	write_seqlock_irqsave(&system_time_lock, flags);
 
 	/* calculate the new offset from the monotonic clock */
-	wall_time_offset = ktime_sub(newtime, __get_monotonic_clock());
-
-	/* update the internal timespec variables */
-	wall_time_ts = ktime_to_timespec(ktime_add(system_time,
-						wall_time_offset));
-	monotonic_time_offset_ts = ktime_to_timespec(wall_time_offset);
+	__set_wall_time_offset(ktime_sub(newtime, __get_monotonic_clock()));
 
 	ntp_clear();
 	update_legacy_time_values();
@@ -377,20 +401,6 @@ int do_settimeofday(struct timespec *tv)
 EXPORT_SYMBOL(do_settimeofday);
 
 /**
- * __increment_system_time - Increments system time
- * @delta:	nanosecond delta to add to the time variables
- *
- * Private helper that increments system_time and related
- * timekeeping variables.
- */
-static void __increment_system_time(nsec_t delta)
-{
-	system_time = ktime_add_ns(system_time, delta);
-	timespec_add_ns(&wall_time_ts, delta);
-	timespec_add_ns(&mono_time_ts, delta);
-}
-
-/**
  * timeofday_suspend_hook - allows the timeofday subsystem to be shutdown
  * @dev:	unused
  * @state:	unused
@@ -539,12 +549,9 @@ static void timeofday_periodic_hook(unsi
 	if (second_check >= NSEC_PER_SEC) {
 		/* do ntp leap second processing: */
 		leapsecond = ntp_leapsecond(wall_time_ts);
-		if (leapsecond) {
-			wall_time_offset = ktime_add_ns(wall_time_offset,
-						leapsecond * NSEC_PER_SEC);
-			wall_time_ts.tv_sec += leapsecond;
-			monotonic_time_offset_ts.tv_sec += leapsecond;
-		}
+		if (leapsecond)
+			__set_wall_time_offset(ktime_add_ns(wall_time_offset,
+						leapsecond * NSEC_PER_SEC));
 		second_check -= NSEC_PER_SEC;
 	}
 	/* sync the persistent clock: */
@@ -662,13 +669,8 @@ void __init timeofday_init(void)
 
 	/* initialize wall_time_offset to now: */
 	/* XXX - this should be something like ns_to_ktime() */
-	wall_time_offset = ktime_add_ns(wall_time_offset,
-					read_persistent_clock());
-
-	/* initialize timespec values: */
-	wall_time_ts = ktime_to_timespec(ktime_add(system_time,
-						wall_time_offset));
-	monotonic_time_offset_ts = ktime_to_timespec(wall_time_offset);
+	__set_wall_time_offset(ktime_add_ns(wall_time_offset,
+					read_persistent_clock()));
 
 	/* clear NTP scaling factor & state machine: */
 	ntp_adj = 0;

  parent reply	other threads:[~2006-02-21  6:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-21  6:21 [-mm PATCHSET 0/11] Sync -mm w/ B19 timekeeping patches john stultz
2006-02-21  6:21 ` [-mm PATCH 1/11] Time: reduced ntp rework part 1 - fix adjtimeadj john stultz
2006-02-21  6:21 ` [-mm PATCH 2/11] Time: reduced ntp rework part 2 (updated) john stultz
2006-02-21  6:21 ` [-mm PATCH 3/11] Time: reduced ntp rework part 2 - fix adjtimeadj john stultz
2006-02-21  6:21 ` [-mm PATCH 4/11] Time: clocksource infrastructure - remove nsec_t john stultz
2006-02-21  6:21 ` [-mm PATCH 5/11] Time: generic timekeeping " john stultz
2006-02-21  6:21 ` [-mm PATCH 6/11] Time: generic timekeeping infrastructure - fix ntp_synced john stultz
2006-02-21  6:21 ` john stultz [this message]
2006-02-21  6:21 ` [-mm PATCH 8/11] Time: i386 conversion part 3 - remove nsec_t john stultz
2006-02-21  6:21 ` [-mm PATCH 9/11] Time: i386 conversion part 3 - backout pmtmr changes john stultz
2006-02-21  6:22 ` [-mm PATCH 10/11] Time: i386 conversion part 4 - del timer_tsc.c john stultz
2006-02-21  6:22 ` [-mm PATCH 11/11]Time: i386 clocksource drivers - backout pmtmr changes john stultz

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=20060221062146.13304.76302.sendpatchset@cog.beaverton.ibm.com \
    --to=johnstul@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.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®