<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/hrtimer.c, branch v3.9</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.9</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2013-03-26T20:34:57Z</updated>
<entry>
<title>hrtimer: Don't reinitialize a cpu_base lock on CPU_UP</title>
<updated>2013-03-26T20:34:57Z</updated>
<author>
<name>Michael Bohan</name>
<email>mbohan@codeaurora.org</email>
</author>
<published>2013-03-20T02:19:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=84cc8fd2fe65866e49d70b38b3fdf7219dd92fe0'/>
<id>urn:sha1:84cc8fd2fe65866e49d70b38b3fdf7219dd92fe0</id>
<content type='text'>
The current code makes the assumption that a cpu_base lock won't be
held if the CPU corresponding to that cpu_base is offline, which isn't
always true.

If a hrtimer is not queued, then it will not be migrated by
migrate_hrtimers() when a CPU is offlined. Therefore, the hrtimer's
cpu_base may still point to a CPU which has subsequently gone offline
if the timer wasn't enqueued at the time the CPU went down.

Normally this wouldn't be a problem, but a cpu_base's lock is blindly
reinitialized each time a CPU is brought up. If a CPU is brought
online during the period that another thread is performing a hrtimer
operation on a stale hrtimer, then the lock will be reinitialized
under its feet, and a SPIN_BUG() like the following will be observed:

&lt;0&gt;[   28.082085] BUG: spinlock already unlocked on CPU#0, swapper/0/0
&lt;0&gt;[   28.087078]  lock: 0xc4780b40, value 0x0 .magic: dead4ead, .owner: &lt;none&gt;/-1, .owner_cpu: -1
&lt;4&gt;[   42.451150] [&lt;c0014398&gt;] (unwind_backtrace+0x0/0x120) from [&lt;c0269220&gt;] (do_raw_spin_unlock+0x44/0xdc)
&lt;4&gt;[   42.460430] [&lt;c0269220&gt;] (do_raw_spin_unlock+0x44/0xdc) from [&lt;c071b5bc&gt;] (_raw_spin_unlock+0x8/0x30)
&lt;4&gt;[   42.469632] [&lt;c071b5bc&gt;] (_raw_spin_unlock+0x8/0x30) from [&lt;c00a9ce0&gt;] (__hrtimer_start_range_ns+0x1e4/0x4f8)
&lt;4&gt;[   42.479521] [&lt;c00a9ce0&gt;] (__hrtimer_start_range_ns+0x1e4/0x4f8) from [&lt;c00aa014&gt;] (hrtimer_start+0x20/0x28)
&lt;4&gt;[   42.489247] [&lt;c00aa014&gt;] (hrtimer_start+0x20/0x28) from [&lt;c00e6190&gt;] (rcu_idle_enter_common+0x1ac/0x320)
&lt;4&gt;[   42.498709] [&lt;c00e6190&gt;] (rcu_idle_enter_common+0x1ac/0x320) from [&lt;c00e6440&gt;] (rcu_idle_enter+0xa0/0xb8)
&lt;4&gt;[   42.508259] [&lt;c00e6440&gt;] (rcu_idle_enter+0xa0/0xb8) from [&lt;c000f268&gt;] (cpu_idle+0x24/0xf0)
&lt;4&gt;[   42.516503] [&lt;c000f268&gt;] (cpu_idle+0x24/0xf0) from [&lt;c06ed3c0&gt;] (rest_init+0x88/0xa0)
&lt;4&gt;[   42.524319] [&lt;c06ed3c0&gt;] (rest_init+0x88/0xa0) from [&lt;c0c00978&gt;] (start_kernel+0x3d0/0x434)

As an example, this particular crash occurred when hrtimer_start() was
executed on CPU #0. The code locked the hrtimer's current cpu_base
corresponding to CPU #1. CPU #0 then tried to switch the hrtimer's
cpu_base to an optimal CPU which was online. In this case, it selected
the cpu_base corresponding to CPU #3.

Before it could proceed, CPU #1 came online and reinitialized the
spinlock corresponding to its cpu_base. Thus now CPU #0 held a lock
which was reinitialized. When CPU #0 finally ended up unlocking the
old cpu_base corresponding to CPU #1 so that it could switch to CPU
#3, we hit this SPIN_BUG() above while in switch_hrtimer_base().

CPU #0                            CPU #1
----                              ----
...                               &lt;offline&gt;
hrtimer_start()
lock_hrtimer_base(base #1)
...                               init_hrtimers_cpu()
switch_hrtimer_base()             ...
...                               raw_spin_lock_init(&amp;cpu_base-&gt;lock)
raw_spin_unlock(&amp;cpu_base-&gt;lock)  ...
&lt;spin_bug&gt;

Solve this by statically initializing the lock.

Signed-off-by: Michael Bohan &lt;mbohan@codeaurora.org&gt;
Link: http://lkml.kernel.org/r/1363745965-23475-1-git-send-email-mbohan@codeaurora.org
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip</title>
<updated>2013-02-20T03:05:45Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2013-02-20T03:05:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=266d7ad7f4fe2f44b91561f5b812115c1b3018ab'/>
<id>urn:sha1:266d7ad7f4fe2f44b91561f5b812115c1b3018ab</id>
<content type='text'>
Pull timer changes from Ingo Molnar:
 "Main changes:

   - ntp: Add CONFIG_RTC_SYSTOHC: a generic RTC driver facility
     complementing the existing CONFIG_RTC_HCTOSYS, which uses NTP to
     keep the hardware clock updated.

   - posix-timers: Fix clock_adjtime to always return timex data on
     success.  This is changing the ABI, but no breakage was expected
     and found - caution is warranted nevertheless.

   - platform persistent clock improvements/cleanups.

   - clockevents: refactor timer broadcast handling to be more generic
     and less duplicated with matching architecture code (mostly ARM
     motivated.)

   - various fixes and cleanups"

* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  timers/x86/hpet: Use HPET_COUNTER to specify the hpet counter in vread_hpet()
  posix-cpu-timers: Fix nanosleep task_struct leak
  clockevents: Fix generic broadcast for FEAT_C3STOP
  time, Fix setting of hardware clock in NTP code
  hrtimer: Prevent hrtimer_enqueue_reprogram race
  clockevents: Add generic timer broadcast function
  clockevents: Add generic timer broadcast receiver
  timekeeping: Switch HAS_PERSISTENT_CLOCK to ALWAYS_USE_PERSISTENT_CLOCK
  x86/time/rtc: Don't print extended CMOS year when reading RTC
  x86: Select HAS_PERSISTENT_CLOCK on x86
  timekeeping: Add CONFIG_HAS_PERSISTENT_CLOCK option
  rtc: Skip the suspend/resume handling if persistent clock exist
  timekeeping: Add persistent_clock_exist flag
  posix-timers: Fix clock_adjtime to always return timex data on success
  Round the calculated scale factor in set_cyc2ns_scale()
  NTP: Add a CONFIG_RTC_SYSTOHC configuration
  MAINTAINERS: Update John Stultz's email
  time: create __getnstimeofday for WARNless calls
</content>
</entry>
<entry>
<title>sched/rt: Move rt specific bits into new header file</title>
<updated>2013-02-07T19:51:08Z</updated>
<author>
<name>Clark Williams</name>
<email>williams@redhat.com</email>
</author>
<published>2013-02-07T15:47:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8bd75c77b7c6a3954140dd2e20346aef3efe4a35'/>
<id>urn:sha1:8bd75c77b7c6a3954140dd2e20346aef3efe4a35</id>
<content type='text'>
Move rt scheduler definitions out of include/linux/sched.h into
new file include/linux/sched/rt.h

Signed-off-by: Clark Williams &lt;williams@redhat.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Link: http://lkml.kernel.org/r/20130207094707.7b9f825f@riff.lan
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>sched: Move sched.h sysctl bits into separate header</title>
<updated>2013-02-07T19:50:54Z</updated>
<author>
<name>Clark Williams</name>
<email>williams@redhat.com</email>
</author>
<published>2013-02-07T15:46:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=cf4aebc292fac7f34f8345664320e9d4a42ca76c'/>
<id>urn:sha1:cf4aebc292fac7f34f8345664320e9d4a42ca76c</id>
<content type='text'>
Move the sysctl-related bits from include/linux/sched.h into
a new file: include/linux/sched/sysctl.h. Then update source
files requiring access to those bits by including the new
header file.

Signed-off-by: Clark Williams &lt;williams@redhat.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Link: http://lkml.kernel.org/r/20130207094659.06dced96@riff.lan
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</content>
</entry>
<entry>
<title>hrtimer: Prevent hrtimer_enqueue_reprogram race</title>
<updated>2013-02-05T10:52:41Z</updated>
<author>
<name>Leonid Shatz</name>
<email>leonid.shatz@ravellosystems.com</email>
</author>
<published>2013-02-04T12:33:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b22affe0aef429d657bc6505aacb1c569340ddd2'/>
<id>urn:sha1:b22affe0aef429d657bc6505aacb1c569340ddd2</id>
<content type='text'>
hrtimer_enqueue_reprogram contains a race which could result in
timer.base switch during unlock/lock sequence.

hrtimer_enqueue_reprogram is releasing the lock protecting the timer
base for calling raise_softirq_irqsoff() due to a lock ordering issue
versus rq-&gt;lock.

If during that time another CPU calls __hrtimer_start_range_ns() on
the same hrtimer, the timer base might switch, before the current CPU
can lock base-&gt;lock again and therefor the unlock_timer_base() call
will unlock the wrong lock.

[ tglx: Added comment and massaged changelog ]

Signed-off-by: Leonid Shatz &lt;leonid.shatz@ravellosystems.com&gt;
Signed-off-by: Izik Eidus &lt;izik.eidus@ravellosystems.com&gt;
Cc: Andrea Arcangeli &lt;aarcange@redhat.com&gt;
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1359981217-389-1-git-send-email-izik.eidus@ravellosystems.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>hrtimer: Update hrtimer base offsets each hrtimer_interrupt</title>
<updated>2012-07-11T21:34:39Z</updated>
<author>
<name>John Stultz</name>
<email>johnstul@us.ibm.com</email>
</author>
<published>2012-07-10T22:43:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5baefd6d84163443215f4a99f6a20f054ef11236'/>
<id>urn:sha1:5baefd6d84163443215f4a99f6a20f054ef11236</id>
<content type='text'>
The update of the hrtimer base offsets on all cpus cannot be made
atomically from the timekeeper.lock held and interrupt disabled region
as smp function calls are not allowed there.

clock_was_set(), which enforces the update on all cpus, is called
either from preemptible process context in case of do_settimeofday()
or from the softirq context when the offset modification happened in
the timer interrupt itself due to a leap second.

In both cases there is a race window for an hrtimer interrupt between
dropping timekeeper lock, enabling interrupts and clock_was_set()
issuing the updates. Any interrupt which arrives in that window will
see the new time but operate on stale offsets.

So we need to make sure that an hrtimer interrupt always sees a
consistent state of time and offsets.

ktime_get_update_offsets() allows us to get the current monotonic time
and update the per cpu hrtimer base offsets from hrtimer_interrupt()
to capture a consistent state of monotonic time and the offsets. The
function replaces the existing ktime_get() calls in hrtimer_interrupt().

The overhead of the new function vs. ktime_get() is minimal as it just
adds two store operations.

This ensures that any changes to realtime or boottime offsets are
noticed and stored into the per-cpu hrtimer base structures, prior to
any hrtimer expiration and guarantees that timers are not expired early.

Signed-off-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Reviewed-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Acked-by: Prarit Bhargava &lt;prarit@redhat.com&gt;
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1341960205-56738-8-git-send-email-johnstul@us.ibm.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>hrtimers: Move lock held region in hrtimer_interrupt()</title>
<updated>2012-07-11T21:34:38Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2012-07-10T22:43:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=196951e91262fccda81147d2bcf7fdab08668b40'/>
<id>urn:sha1:196951e91262fccda81147d2bcf7fdab08668b40</id>
<content type='text'>
We need to update the base offsets from this code and we need to do
that under base-&gt;lock. Move the lock held region around the
ktime_get() calls. The ktime_get() calls are going to be replaced with
a function which gets the time and the offsets atomically.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Acked-by: Prarit Bhargava &lt;prarit@redhat.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Link: http://lkml.kernel.org/r/1341960205-56738-6-git-send-email-johnstul@us.ibm.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>hrtimer: Provide clock_was_set_delayed()</title>
<updated>2012-07-11T21:34:37Z</updated>
<author>
<name>John Stultz</name>
<email>johnstul@us.ibm.com</email>
</author>
<published>2012-07-10T22:43:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f55a6faa384304c89cfef162768e88374d3312cb'/>
<id>urn:sha1:f55a6faa384304c89cfef162768e88374d3312cb</id>
<content type='text'>
clock_was_set() cannot be called from hard interrupt context because
it calls on_each_cpu().

For fixing the widely reported leap seconds issue it is necessary to
call it from hard interrupt context, i.e. the timer tick code, which
does the timekeeping updates.

Provide a new function which denotes it in the hrtimer cpu base
structure of the cpu on which it is called and raise the hrtimer
softirq. We then execute the clock_was_set() notificiation from
softirq context in run_hrtimer_softirq(). The hrtimer softirq is
rarely used, so polling the flag there is not a performance issue.

[ tglx: Made it depend on CONFIG_HIGH_RES_TIMERS. We really should get
  rid of all this ifdeffery ASAP ]

Signed-off-by: John Stultz &lt;johnstul@us.ibm.com&gt;
Reported-by: Jan Engelhardt &lt;jengelh@inai.de&gt;
Reviewed-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Acked-by: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Acked-by: Prarit Bhargava &lt;prarit@redhat.com&gt;
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1341960205-56738-2-git-send-email-johnstul@us.ibm.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
<entry>
<title>Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip</title>
<updated>2011-11-28T16:43:52Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2011-11-28T16:43:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c28800a9c3caaf387d85ac665a25ebe99e480295'/>
<id>urn:sha1:c28800a9c3caaf387d85ac665a25ebe99e480295</id>
<content type='text'>
* 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  hrtimer: Fix extra wakeups from __remove_hrtimer()
  timekeeping: add arch_offset hook to ktime_get functions
  clocksource: Avoid selecting mult values that might overflow when adjusted
  time: Improve documentation of timekeeeping_adjust()
</content>
</entry>
<entry>
<title>hrtimer: Fix extra wakeups from __remove_hrtimer()</title>
<updated>2011-11-19T11:17:37Z</updated>
<author>
<name>Jeff Ohlstein</name>
<email>johlstei@codeaurora.org</email>
</author>
<published>2011-11-18T23:47:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=27c9cd7e601632b3794e1c3344d37b86917ffb43'/>
<id>urn:sha1:27c9cd7e601632b3794e1c3344d37b86917ffb43</id>
<content type='text'>
__remove_hrtimer() attempts to reprogram the clockevent device when
the timer being removed is the next to expire. However,
__remove_hrtimer() reprograms the clockevent *before* removing the
timer from the timerqueue and thus when hrtimer_force_reprogram()
finds the next timer to expire it finds the timer we're trying to
remove.

This is especially noticeable when the system switches to NOHz mode
and the system tick is removed. The timer tick is removed from the
system but the clockevent is programmed to wakeup in another HZ
anyway.

Silence the extra wakeup by removing the timer from the timerqueue
before calling hrtimer_force_reprogram() so that we actually program
the clockevent for the next timer to expire.

This was broken by 998adc3 "hrtimers: Convert hrtimers to use
timerlist infrastructure".

Signed-off-by: Jeff Ohlstein &lt;johlstei@codeaurora.org&gt;
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1321660030-8520-1-git-send-email-johlstei@codeaurora.org
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
</content>
</entry>
</feed>
