diff mbox

[V10,01/15] time: Introduce timekeeping_inject_offset

Message ID 6aec014551fc1d34924d6a7bcf97769867c15ba9.1296124770.git.richard.cochran@omicron.at
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Richard Cochran Jan. 27, 2011, 10:54 a.m. UTC
This adds a kernel-internal timekeeping interface to add or subtract
a fixed amount from CLOCK_REALTIME. This makes it so kernel users or
interfaces trying to do so do not have to read the time, then add an
offset and then call settimeofday(), which adds some extra error in
comparision to just simply adding the offset in the kernel timekeeping
core.

CC: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
---
 include/linux/time.h      |    1 +
 kernel/time/timekeeping.c |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)

Comments

John Stultz Jan. 27, 2011, 6:48 p.m. UTC | #1
On Thu, 2011-01-27 at 11:54 +0100, John Stultz wrote:
> This adds a kernel-internal timekeeping interface to add or subtract
> a fixed amount from CLOCK_REALTIME. This makes it so kernel users or
> interfaces trying to do so do not have to read the time, then add an
> offset and then call settimeofday(), which adds some extra error in
> comparision to just simply adding the offset in the kernel timekeeping
> core.
> 
> CC: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Richard Cochran <richard.cochran@omicron.at>
> ---


Hey Richard,
	Something seems wrong with your mail sending script. It looks like your
sending the email under my name (John Stultz
<richardcochran@gmail.com>).

While I appreciate you preserving the path author, and the signoffs are
right, you really should send the email under your own name.

The proper style is to keep the mail-header From: the same (ie: Richard
Cochran <richardcochran@gmail.com>), but as the first line of the mail
body put:
   From: Author Name <author@lemail.com>

thanks
-john


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Cochran Jan. 28, 2011, 7:08 a.m. UTC | #2
On Thu, Jan 27, 2011 at 10:48:19AM -0800, John Stultz wrote:
> While I appreciate you preserving the path author, and the signoffs are
> right, you really should send the email under your own name.

Guess I've been reading too much spam. It wore off on me.
 
> The proper style is to keep the mail-header From: the same (ie: Richard
> Cochran <richardcochran@gmail.com>), but as the first line of the mail
> body put:
>    From: Author Name <author@lemail.com>

Sorry about this. Arnd already explained this to me, and I did catch
it with V9. This time I forgot.

I would like to get to the bottom of this. Here is what I did:

   1. Saved your patch to disk in mbox format using Mutt.
   2. git am
   3. ... rebase, rebase, rebase, ...
   4. git format-patch [options] 1234..abcd
   5. Edit cover letter
   6. for x in 00*; do mutt -H $x; done

Git format-patch places the "From: John Stultz <john.stultz@linaro.org>"
line with the other mail headers, and so I guess mutt just faithfully
preserves this.

I don't like having to remember to fix this manually. There must be a
better way...

Sorry,
Richard


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann Jan. 28, 2011, 12:05 p.m. UTC | #3
On Friday 28 January 2011, Richard Cochran wrote:
> I would like to get to the bottom of this. Here is what I did:
> 
>    1. Saved your patch to disk in mbox format using Mutt.
>    2. git am
>    3. ... rebase, rebase, rebase, ...
>    4. git format-patch [options] 1234..abcd
>    5. Edit cover letter
>    6. for x in 00*; do mutt -H $x; done
> 
> Git format-patch places the "From: John Stultz <john.stultz@linaro.org>"
> line with the other mail headers, and so I guess mutt just faithfully
> preserves this.
> 
> I don't like having to remember to fix this manually. There must be a
> better way...

The problem is step 6. The output of git format-patch does not work when
sending with mutt. The easiest solution is to send with git send-email,
which does the same as mutt -H, but gets it right.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peter Zijlstra Jan. 28, 2011, 12:43 p.m. UTC | #4
On Fri, 2011-01-28 at 13:05 +0100, Arnd Bergmann wrote:
> On Friday 28 January 2011, Richard Cochran wrote:
> > I would like to get to the bottom of this. Here is what I did:
> > 
> >    1. Saved your patch to disk in mbox format using Mutt.
> >    2. git am
> >    3. ... rebase, rebase, rebase, ...
> >    4. git format-patch [options] 1234..abcd
> >    5. Edit cover letter
> >    6. for x in 00*; do mutt -H $x; done
> > 
> > Git format-patch places the "From: John Stultz <john.stultz@linaro.org>"
> > line with the other mail headers, and so I guess mutt just faithfully
> > preserves this.
> > 
> > I don't like having to remember to fix this manually. There must be a
> > better way...
> 
> The problem is step 6. The output of git format-patch does not work when
> sending with mutt. The easiest solution is to send with git send-email,
> which does the same as mutt -H, but gets it right.

I use: formail -s sendmail -t < patches.mbox, but then, I use quilt mail
to generate the mbox, not git.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann Jan. 28, 2011, 12:54 p.m. UTC | #5
On Friday 28 January 2011, Peter Zijlstra wrote:
> > 
> > The problem is step 6. The output of git format-patch does not work when
> > sending with mutt. The easiest solution is to send with git send-email,
> > which does the same as mutt -H, but gets it right.
> 
> I use: formail -s sendmail -t < patches.mbox, but then, I use quilt mail
> to generate the mbox, not git.

I think in that case, quilt generates the correct 'From' headers both in
the actual email headers and in the body, so you can use any standard
email client to send it out.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/time.h b/include/linux/time.h
index 1e6d3b5..8863688 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -168,6 +168,7 @@  extern int timekeeping_valid_for_hres(void);
 extern u64 timekeeping_max_deferment(void);
 extern void update_wall_time(void);
 extern void timekeeping_leap_insert(int leapsecond);
+extern int timekeeping_inject_offset(struct timespec *ts);
 
 struct tms;
 extern void do_sys_times(struct tms *);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index d27c756..1e284a5 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -387,6 +387,42 @@  int do_settimeofday(struct timespec *tv)
 
 EXPORT_SYMBOL(do_settimeofday);
 
+
+/**
+ * timekeeping_inject_offset - Adds or subtracts from the current time.
+ * @tv:		pointer to the timespec variable containing the offset
+ *
+ * Adds or subtracts an offset value from the current time.
+ */
+int timekeeping_inject_offset(struct timespec *ts)
+{
+	unsigned long flags;
+
+	if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC)
+		return -EINVAL;
+
+	write_seqlock_irqsave(&xtime_lock, flags);
+
+	timekeeping_forward_now();
+
+	xtime = timespec_add(xtime, *ts);
+	wall_to_monotonic = timespec_sub(wall_to_monotonic, *ts);
+
+	timekeeper.ntp_error = 0;
+	ntp_clear();
+
+	update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
+				timekeeper.mult);
+
+	write_sequnlock_irqrestore(&xtime_lock, flags);
+
+	/* signal hrtimers about time change */
+	clock_was_set();
+
+	return 0;
+}
+EXPORT_SYMBOL(timekeeping_inject_offset);
+
 /**
  * change_clocksource - Swaps clocksources if a new one is available
  *