<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/time/clocksource.c, branch v2.6.32</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=v2.6.32</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.32'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2009-09-24T20:37:53Z</updated>
<entry>
<title>clocksource: Resume clocksource without taking the clocksource mutex</title>
<updated>2009-09-24T20:37:53Z</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-09-24T15:29:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=89133f93508137231251543d1732da638e6022e1'/>
<id>urn:sha1:89133f93508137231251543d1732da638e6022e1</id>
<content type='text'>
git commit 75c5158f70c065b9 converted the clocksource spinlock to a
mutex. This causes the following BUG:

BUG: sleeping function called from invalid context at
kernel/mutex.c:280 in_atomic(): 0, irqs_disabled(): 1, pid: 2473,
name: pm-suspend 2 locks held by pm-suspend/2473:
 #0:  (&amp;buffer-&gt;mutex){......}, at: [&lt;ffffffff8115ab13&gt;]
sysfs_write_file+0x3c/0x137
 #1:  (pm_mutex){......}, at: [&lt;ffffffff810865b5&gt;]
enter_state+0x39/0x130 Pid: 2473, comm: pm-suspend Not tainted 2.6.31
#1 Call Trace:
 [&lt;ffffffff810792f0&gt;] ? __debug_show_held_locks+0x22/0x24
 [&lt;ffffffff8104a2ef&gt;] __might_sleep+0x107/0x10b
 [&lt;ffffffff8141fca9&gt;] mutex_lock_nested+0x25/0x43
 [&lt;ffffffff81073537&gt;] clocksource_resume+0x1c/0x60
 [&lt;ffffffff81072902&gt;] timekeeping_resume+0x1e/0x1c8
 [&lt;ffffffff812aee62&gt;] __sysdev_resume+0x25/0xcf
 [&lt;ffffffff812aef79&gt;] sysdev_resume+0x6d/0xae
 [&lt;ffffffff810864f8&gt;] suspend_devices_and_enter+0x12b/0x1af
 [&lt;ffffffff8108665b&gt;] enter_state+0xdf/0x130
 [&lt;ffffffff81085dc3&gt;] state_store+0xb6/0xd3
 [&lt;ffffffff81204c73&gt;] kobj_attr_store+0x17/0x19
 [&lt;ffffffff8115abd2&gt;] sysfs_write_file+0xfb/0x137
 [&lt;ffffffff811057d2&gt;] vfs_write+0xae/0x10b
 [&lt;ffffffff81208392&gt;] ? __up_read+0x1a/0x7f
 [&lt;ffffffff811058ef&gt;] sys_write+0x4a/0x6e
 [&lt;ffffffff81011b82&gt;] system_call_fastpath+0x16/0x1b

clocksource_resume is called early in the resume process, there is
only one cpu, no processes are running and the interrupts are
disabled. It is therefore possible to resume the clocksources
without taking the clocksource mutex.

Reported-by: Xiaotian Feng &lt;xtfeng@gmail.com&gt;
Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Tested-by: Michal Schmidt &lt;mschmidt@redhat.com&gt;
Cc: Xiaotian Feng &lt;xtfeng@gmail.com&gt;
Cc: John Stultz &lt;johnstul@us.ibm.com&gt;
LKML-Reference: &lt;20090924172952.49697825@mschwide.boeblingen.de.ibm.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>clocksource: Delay clocksource down rating to late boot</title>
<updated>2009-09-14T19:59:32Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-09-14T17:49:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=54a6bc0b071c50150bc6d1da16c2cd9a963e288c'/>
<id>urn:sha1:54a6bc0b071c50150bc6d1da16c2cd9a963e288c</id>
<content type='text'>
The down rating of clock sources in the early boot process via the
clock source watchdog mechanism can happen way before the per cpu
event queues are initialized. This leads to a boot crash on x86 when
the TSC is marked unstable in the SMP bring up.

The selection of a clock source for time keeping happens in the late
boot process so we can safely delay the list manipulation until
clocksource_done_booting() is called.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
LKML-Reference: &lt;new-submission&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
</content>
</entry>
<entry>
<title>clocksource: clocksource_select must be called with mutex locked</title>
<updated>2009-09-14T19:59:32Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-09-14T17:51:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e6c733050faa93ce616bfedccd279ab12cffdd7b'/>
<id>urn:sha1:e6c733050faa93ce616bfedccd279ab12cffdd7b</id>
<content type='text'>
The callers of clocksource_select must hold clocksource_mutex to
protect the clocksource_list.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
LKML-Reference: &lt;new-submission&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
</content>
</entry>
<entry>
<title>clocksource: Resolve cpu hotplug dead lock with TSC unstable, fix crash</title>
<updated>2009-09-11T18:17:18Z</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-09-11T13:33:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f79e0258ea1f04d63db499479b5fb855dff6dbc5'/>
<id>urn:sha1:f79e0258ea1f04d63db499479b5fb855dff6dbc5</id>
<content type='text'>
The watchdog timer is started after the watchdog clocksource
and at least one watched clocksource have been registered. The
clocksource work element watchdog_work is initialized just
before the clocksource timer is started. This is too late for
the clocksource_mark_unstable call from native_cpu_up. To fix
this use a static initializer for watchdog_work.

This resolves a boot crash reported by multiple people.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Jens Axboe &lt;jens.axboe@oracle.com&gt;
Cc: John Stultz &lt;johnstul@us.ibm.com&gt;
LKML-Reference: &lt;20090911153305.3fe9a361@skybase&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>clocksource: Resolve cpu hotplug dead lock with TSC unstable</title>
<updated>2009-08-28T18:25:24Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-08-28T18:25:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7285dd7fd375763bfb8ab1ac9cf3f1206f503c16'/>
<id>urn:sha1:7285dd7fd375763bfb8ab1ac9cf3f1206f503c16</id>
<content type='text'>
Martin Schwidefsky analyzed it:
To register a clocksource the clocksource_mutex is acquired and if
necessary timekeeping_notify is called to install the clocksource as
the timekeeper clock. timekeeping_notify uses stop_machine which needs
to take cpu_add_remove_lock mutex.
Starting a new cpu is done with the cpu_add_remove_lock mutex held.
native_cpu_up checks the tsc of the new cpu and if the tsc is no good
clocksource_change_rating is called. Which needs the clocksource_mutex
and the deadlock is complete.

The solution is to replace the TSC via the clocksource watchdog
mechanism. Mark the TSC as unstable and schedule the watchdog work so
it gets removed in the watchdog thread context.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
LKML-Reference: &lt;new-submission&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: John Stultz &lt;johnstul@us.ibm.com&gt;
</content>
</entry>
<entry>
<title>clocksource: Avoid clocksource watchdog circular locking dependency</title>
<updated>2009-08-19T10:00:56Z</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-18T15:09:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=01548f4d3e8e94caf323a4f664eb347fd34a34ab'/>
<id>urn:sha1:01548f4d3e8e94caf323a4f664eb347fd34a34ab</id>
<content type='text'>
stop_machine from a multithreaded workqueue is not allowed because
of a circular locking dependency between cpu_down and the workqueue
execution. Use a kernel thread to do the clocksource downgrade.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: john stultz &lt;johnstul@us.ibm.com&gt;
LKML-Reference: &lt;20090818170942.3ab80c91@skybase&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;

</content>
</entry>
<entry>
<title>clocksource: Protect the watchdog rating changes with clocksource_mutex</title>
<updated>2009-08-19T09:42:48Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-08-19T09:26:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d0981a1b21a03866c8da7f44e35e389c2e0d6061'/>
<id>urn:sha1:d0981a1b21a03866c8da7f44e35e389c2e0d6061</id>
<content type='text'>
Martin pointed out that commit 6ea41d2529 (clocksource: Call
clocksource_change_rating() outside of watchdog_lock) has a
theoretical reference count problem. The calls to
clocksource_change_rating() are now done outside of the clocksource
mutex and outside of the watchdog lock. A concurrent
clocksource_unregister() could remove the clock.

Split out the code which changes the rating from
clocksource_change_rating() into __clocksource_change_rating().

Protect the clocksource_watchdog_work() code sequence with the
clocksource_mutex() and call __clocksource_change_rating().

LKML-Reference: &lt;alpine.LFD.2.00.0908171038420.2782@localhost.localdomain&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
</content>
</entry>
<entry>
<title>clocksource: Call clocksource_change_rating() outside of watchdog_lock</title>
<updated>2009-08-15T11:20:42Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2009-08-15T11:20:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6ea41d252f35465a2308a4038a323b6b07de06f6'/>
<id>urn:sha1:6ea41d252f35465a2308a4038a323b6b07de06f6</id>
<content type='text'>
The changes to the watchdog logic introduced a lock inversion between
watchdog_lock and clocksource_mutex. Change the rating outside of
watchdog_lock to avoid it.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>timekeeping: Update clocksource with stop_machine</title>
<updated>2009-08-15T08:55:46Z</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-14T13:47:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=75c5158f70c065b9704b924503d96e8297838f79'/>
<id>urn:sha1:75c5158f70c065b9704b924503d96e8297838f79</id>
<content type='text'>
update_wall_time calls change_clocksource HZ times per second to check
if a new clock source is available. In close to 100% of all calls
there is no new clock. Replace the tick based check by an update done
with stop_machine.

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134810.711836357@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>timekeeping: Introduce struct timekeeper</title>
<updated>2009-08-15T08:55:46Z</updated>
<author>
<name>Martin Schwidefsky</name>
<email>schwidefsky@de.ibm.com</email>
</author>
<published>2009-08-14T13:47:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=155ec60226ae0ae2aadaa57c951a58a359331030'/>
<id>urn:sha1:155ec60226ae0ae2aadaa57c951a58a359331030</id>
<content type='text'>
Add struct timekeeper to keep the internal values timekeeping.c needs
in regard to the currently selected clock source. This moves the
timekeeping intervals, xtime_nsec and the ntp error value from struct
clocksource to struct timekeeper. The raw_time is removed from the
clocksource as well. It gets treated like xtime as a global variable.
Eventually xtime raw_time should be moved to struct timekeeper.

[ tglx: minor cleanup ]

Signed-off-by: Martin Schwidefsky &lt;schwidefsky@de.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Acked-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Cc: Daniel Walker &lt;dwalker@fifo99.com&gt;
LKML-Reference: &lt;20090814134809.613209842@de.ibm.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
</feed>
