<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/time/timekeeping.c, branch v3.13</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v3.13</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.13'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2013-11-22T20:08:11Z</updated>
<entry>
<title>time: Fix 1ns/tick drift w/ GENERIC_TIME_VSYSCALL_OLD</title>
<updated>2013-11-22T20:08:11Z</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2013-11-22T19:44:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4be77398ac9d948773116b6be4a3c91b3d6ea18c'/>
<id>urn:sha1:4be77398ac9d948773116b6be4a3c91b3d6ea18c</id>
<content type='text'>
Since commit 1e75fa8be9f (time: Condense timekeeper.xtime
into xtime_sec - merged in v3.6), there has been an problem
with the error accounting in the timekeeping code, such that
when truncating to nanoseconds, we round up to the next nsec,
but the balancing adjustment to the ntp_error value was dropped.

This causes 1ns per tick drift forward of the clock.

In 3.7, this logic was isolated to only GENERIC_TIME_VSYSCALL_OLD
architectures (s390, ia64, powerpc).

The fix is simply to balance the accounting and to subtract the
added nanosecond from ntp_error. This allows the internal long-term
clock steering to keep the clock accurate.

While this fix removes the regression added in 1e75fa8be9f, the
ideal solution is to move away from GENERIC_TIME_VSYSCALL_OLD
and use the new VSYSCALL method, which avoids entirely the
nanosecond granular rounding, and the resulting short-term clock
adjustment oscillation needed to keep long term accurate time.

[ jstultz: Many thanks to Martin for his efforts identifying this
  	   subtle bug, and providing the fix. ]

Originally-from: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Tony Luck &lt;tony.luck@intel.com&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Cc: Andy Lutomirski &lt;luto@amacapital.net&gt;
Cc: Paul Turner &lt;pjt@google.com&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Richard Cochran &lt;richardcochran@gmail.com&gt;
Cc: Prarit Bhargava &lt;prarit@redhat.com&gt;
Cc: Fenghua Yu &lt;fenghua.yu@intel.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;  #v3.6+
Link: http://lkml.kernel.org/r/1385149491-20307-1-git-send-email-john.stultz@linaro.org
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>timekeeping: Fix some trivial typos in comments</title>
<updated>2013-10-18T23:30:17Z</updated>
<author>
<name>Xie XiuQi</name>
<email>xiexiuqi@huawei.com</email>
</author>
<published>2013-10-18T01:13:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b7bc50e45111e59419474154736f419a555158d9'/>
<id>urn:sha1:b7bc50e45111e59419474154736f419a555158d9</id>
<content type='text'>
Fix some typos in timekeeping comments.

Signed-off-by: Xie XiuQi &lt;xiexiuqi@huawei.com&gt;
[jstultz: Commit message tweaks]
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>timekeeping: Fix HRTICK related deadlock from ntp lock changes</title>
<updated>2013-09-12T05:49:51Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2013-09-11T23:50:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7bd36014460f793c19e7d6c94dab67b0afcfcb7f'/>
<id>urn:sha1:7bd36014460f793c19e7d6c94dab67b0afcfcb7f</id>
<content type='text'>
Gerlando Falauto reported that when HRTICK is enabled, it is
possible to trigger system deadlocks. These were hard to
reproduce, as HRTICK has been broken in the past, but seemed
to be connected to the timekeeping_seq lock.

Since seqlock/seqcount's aren't supported w/ lockdep, I added
some extra spinlock based locking and triggered the following
lockdep output:

[   15.849182] ntpd/4062 is trying to acquire lock:
[   15.849765]  (&amp;(&amp;pool-&gt;lock)-&gt;rlock){..-...}, at: [&lt;ffffffff810aa9b5&gt;] __queue_work+0x145/0x480
[   15.850051]
[   15.850051] but task is already holding lock:
[   15.850051]  (timekeeper_lock){-.-.-.}, at: [&lt;ffffffff810df6df&gt;] do_adjtimex+0x7f/0x100

&lt;snip&gt;

[   15.850051] Chain exists of: &amp;(&amp;pool-&gt;lock)-&gt;rlock --&gt; &amp;p-&gt;pi_lock --&gt; timekeeper_lock
[   15.850051]  Possible unsafe locking scenario:
[   15.850051]
[   15.850051]        CPU0                    CPU1
[   15.850051]        ----                    ----
[   15.850051]   lock(timekeeper_lock);
[   15.850051]                                lock(&amp;p-&gt;pi_lock);
[   15.850051] lock(timekeeper_lock);
[   15.850051] lock(&amp;(&amp;pool-&gt;lock)-&gt;rlock);
[   15.850051]
[   15.850051]  *** DEADLOCK ***

The deadlock was introduced by 06c017fdd4dc48451a ("timekeeping:
Hold timekeepering locks in do_adjtimex and hardpps") in 3.10

This patch avoids this deadlock, by moving the call to
schedule_delayed_work() outside of the timekeeper lock
critical section.

Reported-by: Gerlando Falauto &lt;gerlando.falauto@keymile.com&gt;
Tested-by: Lin Ming &lt;minggr@gmail.com&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt; #3.11, 3.10
Link: http://lkml.kernel.org/r/1378943457-27314-1-git-send-email-john.stultz@linaro.org
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'timers/posix-cpu-timers-for-tglx' of</title>
<updated>2013-07-04T21:11:22Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2013-07-04T21:11:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2b0f89317e99735bbf32eaede81f707f98ab1b5e'/>
<id>urn:sha1:2b0f89317e99735bbf32eaede81f707f98ab1b5e</id>
<content type='text'>
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks into timers/core

Frederic sayed: "Most of these patches have been hanging around for
several month now, in -mmotm for a significant chunk. They already
missed a few releases."

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>timekeeping: Indicate that clock was set in the pvclock gtod notifier</title>
<updated>2013-06-28T21:15:06Z</updated>
<author>
<name>David Vrabel</name>
<email>david.vrabel@citrix.com</email>
</author>
<published>2013-06-27T10:35:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=780427f0e113b4c77dfff4d258c05a902cdb0eb9'/>
<id>urn:sha1:780427f0e113b4c77dfff4d258c05a902cdb0eb9</id>
<content type='text'>
If the clock was set (stepped), set the action parameter to functions
in the pvclock gtod notifier chain to non-zero.  This allows the
callee to only do work if the clock was stepped.

This will be used on Xen as the synchronization of the Xen wallclock
to the control domain's (dom0) system time will be done with this
notifier and updating on every timer tick is unnecessary and too
expensive.

Signed-off-by: David Vrabel &lt;david.vrabel@citrix.com&gt;
Cc: Konrad Rzeszutek Wilk &lt;konrad.wilk@oracle.com&gt;
Cc: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: &lt;xen-devel@lists.xen.org&gt;
Link: http://lkml.kernel.org/r/1372329348-20841-4-git-send-email-david.vrabel@citrix.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>timekeeping: Pass flags instead of multiple bools to timekeeping_update()</title>
<updated>2013-06-28T21:15:06Z</updated>
<author>
<name>David Vrabel</name>
<email>david.vrabel@citrix.com</email>
</author>
<published>2013-06-27T10:35:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=04397fe94ad65289884b9862b6a0c722ececaadf'/>
<id>urn:sha1:04397fe94ad65289884b9862b6a0c722ececaadf</id>
<content type='text'>
Instead of passing multiple bools to timekeeping_updated(), define
flags and use a single 'action' parameter.  It is then more obvious
what each timekeeping_update() call does.

Signed-off-by: David Vrabel &lt;david.vrabel@citrix.com&gt;
Cc: Konrad Rzeszutek Wilk &lt;konrad.wilk@oracle.com&gt;
Cc: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: &lt;xen-devel@lists.xen.org&gt;
Link: http://lkml.kernel.org/r/1372329348-20841-3-git-send-email-david.vrabel@citrix.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>power: Add option to log time spent in suspend</title>
<updated>2013-05-29T19:57:34Z</updated>
<author>
<name>Colin Cross</name>
<email>ccross@android.com</email>
</author>
<published>2013-05-22T05:32:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5c83545f24ab3dd67e0ae0e2b795fea750f08c34'/>
<id>urn:sha1:5c83545f24ab3dd67e0ae0e2b795fea750f08c34</id>
<content type='text'>
Below is a patch from android kernel that maintains a histogram of
suspend times. Please review and provide feedback.

Statistices on the time spent in suspend are kept in
/sys/kernel/debug/sleep_time.

Cc: Android Kernel Team &lt;kernel-team@android.com&gt;
Cc: Colin Cross &lt;ccross@android.com&gt;
Cc: Todd Poynor &lt;toddpoynor@google.com&gt;
Cc: San Mehat &lt;san@google.com&gt;
Cc: Benoit Goby &lt;benoit@android.com&gt;
Cc: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Colin Cross &lt;ccross@android.com&gt;
Signed-off-by: Todd Poynor &lt;toddpoynor@google.com&gt;
[zoran.markovic@linaro.org: Re-formatted suspend time table to better
fit expected values. Moved accounting of suspend time into timekeeping
core. Removed CONFIG_SUSPEND_TIME flag and made the feature conditional
on CONFIG_DEBUG_FS. Changed the file name to sleep_time to better fit
terminology in timekeeping core. Changed seq_printf to seq_puts. Tweaked
commit message]
Signed-off-by: Zoran Markovic &lt;zoran.markovic@linaro.org&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>timekeeping: Correct run-time detection of persistent_clock.</title>
<updated>2013-05-28T20:45:19Z</updated>
<author>
<name>Zoran Markovic</name>
<email>zoran.markovic@linaro.org</email>
</author>
<published>2013-05-17T18:24:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0d6bd9953f739dad96d9a0de65383e479ab4e10d'/>
<id>urn:sha1:0d6bd9953f739dad96d9a0de65383e479ab4e10d</id>
<content type='text'>
Since commit 31ade30692dc9680bfc95700d794818fa3f754ac, timekeeping_init()
checks for presence of persistent clock by attempting to read a non-zero
time value. This is an issue on platforms where persistent_clock (instead
is implemented as a free-running counter (instead of an RTC) starting
from zero on each boot and running during suspend. Examples are some ARM
platforms (e.g. PandaBoard).

An attempt to read such a clock during timekeeping_init() may return zero
value and falsely declare persistent clock as missing. Additionally, in
the above case suspend times may be accounted twice (once from
timekeeping_resume() and once from rtc_resume()), resulting in a gradual
drift of system time.

This patch does a run-time correction of the issue by doing the same check
during timekeeping_suspend().

A better long-term solution would have to return error when trying to read
non-existing clock and zero when trying to read an uninitialized clock, but
that would require changing all persistent_clock implementations.

This patch addresses the immediate breakage, for now.

Cc: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Feng Tang &lt;feng.tang@intel.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Zoran Markovic &lt;zoran.markovic@linaro.org&gt;
[jstultz: Tweaked commit message and subject]
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
</content>
</entry>
<entry>
<title>clocksource: Add module refcount</title>
<updated>2013-05-16T09:09:14Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2013-04-25T20:31:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=09ac369c825d9d593404306d59062d854b321e9b'/>
<id>urn:sha1:09ac369c825d9d593404306d59062d854b321e9b</id>
<content type='text'>
Add a module refcount, so the current clocksource cannot be removed
unconditionally.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: Magnus Damm &lt;magnus.damm@gmail.com&gt;
Link: http://lkml.kernel.org/r/20130425143435.762417789@linutronix.de
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>clocksource: Let timekeeping_notify return success/error</title>
<updated>2013-05-16T09:09:14Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2013-04-25T20:31:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ba919d1caa2e624eb8c6cae1f2ce0a253e697d45'/>
<id>urn:sha1:ba919d1caa2e624eb8c6cae1f2ce0a253e697d45</id>
<content type='text'>
timekeeping_notify() can fail due cs-&gt;enable() failure. Though the
caller does not notice and happily keeps the wrong clocksource as the
current one.

Let the caller know about failure, so the current clocksource will be
shown correctly in sysfs.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Acked-by: John Stultz &lt;john.stultz@linaro.org&gt;
Cc: Magnus Damm &lt;magnus.damm@gmail.com&gt;
Link: http://lkml.kernel.org/r/20130425143435.696321912@linutronix.de
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
</feed>
