linux-imx/kernel/time
Thomas Gleixner fff508b0d4 alarmtimer: Rate limit periodic intervals
commit ff86bf0c65 upstream.

The alarmtimer code has another source of potentially rearming itself too
fast. Interval timers with a very samll interval have a similar CPU hog
effect as the previously fixed overflow issue.

The reason is that alarmtimers do not implement the normal protection
against this kind of problem which the other posix timer use:

  timer expires -> queue signal -> deliver signal -> rearm timer

This scheme brings the rearming under scheduler control and prevents
permanently firing timers which hog the CPU.

Bringing this scheme to the alarm timer code is a major overhaul because it
lacks all the necessary mechanisms completely.

So for a quick fix limit the interval to one jiffie. This is not
problematic in practice as alarmtimers are usually backed by an RTC for
suspend which have 1 second resolution. It could be therefor argued that
the resolution of this clock should be set to 1 second in general, but
that's outside the scope of this fix.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Kostya Serebryany <kcc@google.com>
Cc: syzkaller <syzkaller@googlegroups.com>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Dmitry Vyukov <dvyukov@google.com>
Link: http://lkml.kernel.org/r/20170530211655.896767100@linutronix.de
[bwh: Backported to 3.2:
 - Use ktime_to_ns()/ktime_set() as ktime_t is not scalar
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2017-09-15 18:30:49 +01:00
..
alarmtimer.c alarmtimer: Rate limit periodic intervals 2017-09-15 18:30:49 +01:00
clockevents.c Revert "clockevents: Set noop handler in clockevents_exchange_device()" 2011-12-30 13:24:40 -08:00
clocksource.c clocksource: Fix abs() usage w/ 64bit values 2015-11-17 15:54:41 +00:00
jiffies.c time: Fix overflow when HZ is smaller than 60 2014-04-02 00:58:49 +01:00
Kconfig clockevents: Make minimum delay adjustments configurable 2011-09-08 11:10:56 +02:00
Makefile timers: Introduce in-kernel alarm-timer interface 2011-04-26 14:01:44 -07:00
ntp.c ntp: Fixup adjtimex freq validation on 32-bit systems 2015-03-06 00:39:20 +00:00
posix-clock.c posix-clock: Fix return code on the poll method's error path 2016-02-13 10:34:06 +00:00
tick-broadcast.c clockevents: Set dummy handler on CPU_DEAD shutdown 2013-05-13 15:02:26 +01:00
tick-common.c clockevents: Set dummy handler on CPU_DEAD shutdown 2013-05-13 15:02:26 +01:00
tick-internal.h clockevents: Make minimum delay adjustments configurable 2011-09-08 11:10:56 +02:00
tick-oneshot.c clockevents: Make minimum delay adjustments configurable 2011-09-08 11:10:56 +02:00
tick-sched.c nohz: Fix another inconsistency between CONFIG_NO_HZ=n and nohz=off 2014-08-06 18:07:39 +01:00
timecompare.c time: Use ARRAY_SIZE macro in timecompare.c 2010-10-21 17:30:06 +02:00
timeconv.c time: add function to convert between calendar time and broken-down time for universal use 2009-09-24 07:20:56 -07:00
timekeeping.c timekeeping: fix 32-bit overflow in get_monotonic_boottime 2014-04-02 00:59:00 +01:00
timer_list.c hrtimer: Handle remaining time proper for TIME_LOW_RES 2016-02-27 14:28:41 +00:00
timer_stats.c locking, timer_stats: Annotate table_lock as raw 2011-09-13 11:12:00 +02:00