tick: Handle broadcast wakeup of multiple cpus
authorThomas Gleixner <tglx@linutronix.de>
Wed, 6 Mar 2013 11:18:35 +0000 (11:18 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 13 Mar 2013 10:39:39 +0000 (11:39 +0100)
commit989dcb645ca715129c5a2b39102c8334a20d9615
tree244553d975af4d64fa033c11e02267e9753376f5
parent26517f3e99248668315aee9460dcea21628cdd7f
tick: Handle broadcast wakeup of multiple cpus

Some brilliant hardware implementations wake multiple cores when the
broadcast timer fires. This leads to the following interesting
problem:

CPU0 CPU1
wakeup from idle wakeup from idle

leave broadcast mode leave broadcast mode
 restart per cpu timer  restart per cpu timer
          go back to idle
handle broadcast
 (empty mask)
enter broadcast mode
programm broadcast device
enter broadcast mode
programm broadcast device

So what happens is that due to the forced reprogramming of the cpu
local timer, we need to set a event in the future. Now if we manage to
go back to idle before the timer fires, we switch off the timer and
arm the broadcast device with an already expired time (covered by
forced mode). So in the worst case we repeat the above ping pong
forever.

Unfortunately we have no information about what caused the wakeup, but
we can check current time against the expiry time of the local cpu. If
the local event is already in the past, we know that the broadcast
timer is about to fire and send an IPI. So we mark ourself as an IPI
target even if we left broadcast mode and avoid the reprogramming of
the local cpu timer.

This still leaves the possibility that a CPU which is not handling the
broadcast interrupt is going to reach idle again before the IPI
arrives. This can't be solved in the core code and will be handled in
follow up patches.

Reported-by: Jason Liu <liu.h.jason@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: LAK <linux-arm-kernel@lists.infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Arjan van de Veen <arjan@infradead.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Link: http://lkml.kernel.org/r/20130306111537.492045206@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/time/tick-broadcast.c