aboutsummaryrefslogtreecommitdiff
path: root/kernel/time
AgeCommit message (Collapse)AuthorFilesLines
2017-06-14time: Move compat_gettimeofday()/settimeofday() to nativeAl Viro1-0/+41
Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14time: Move compat_time()/stime() to nativeAl Viro1-0/+41
Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14posix-timers: Move compat_timer_create() to native, get rid of set_fs()Al Viro2-18/+42
Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14posix-timers: Move compat versions of clock_gettime/settime/getresAl Viro2-4/+115
Move them to the native implementations and get rid of the set_fs() hackery. Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14itimers: Move compat itimer syscalls to native onesAl Viro2-0/+40
get rid of set_fs(), sanitize compat copyin/copyout. Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14posix-timers: Take compat timer_gettime(2) to native oneAl Viro2-9/+35
... and get rid of set_fs() in there Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14posix-timers: Take compat timer_settime(2) to native oneAl Viro2-24/+64
... and get rid of set_fs() in there Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14ntp: Move adjtimex related compat syscalls to native counterpartsAl Viro3-1/+52
Get rid of set_fs() mess and sanitize compat_{get,put}_timex(), while we are at it. Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14posix-timers: Kill ->nsleep_restart()Al Viro4-12/+1
No more users. Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14hrtimers/posix-timers: Merge nanosleep timespec copyout logics into a new helperAl Viro3-29/+23
Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14time/posix-timers: Move the compat copyouts to the nanosleep implementationsAl Viro5-36/+129
Turn restart_block.nanosleep.{rmtp,compat_rmtp} into a tagged union (kind = 1 -> native, kind = 2 -> compat, kind = 0 -> nothing) and make the places doing actual copyout handle compat as well as native (that will become a helper in the next commit). Result: compat wrappers, messing with reassignments, etc. are gone. [ tglx: Folded in a variant of Peter Zijlstras enum patch ] Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14posix-timers: Store rmtp into restart_block in sys_clock_nanosleep()Al Viro4-22/+10
... instead of doing that in every ->nsleep() instance Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14hrtimer: Move copyout of remaining time to do_nanosleep()Al Viro1-42/+20
The hrtimer nanosleep() implementation can be simplified by moving the copy out of the remaining time to do_nanosleep() which is shared between the real nanosleep function and the restart function. The pointer to the timespec64 which is updated is already stored in the restart block at the call site, so the seperate handling of nanosleep and restart function can be avoided. [ tglx: Added changelog ] Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14hrtimer_nanosleep(): Pass rmtp in restart_blockAl Viro3-7/+14
Store the pointer to the timespec which gets updated with the remaining time in the restart block and remove the function argument. [ tglx: Added changelog ] Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14alarmtimer: Move copyout and freeze handling into alarmtimer_do_nsleep()Al Viro1-70/+32
The alarmtimer nanosleep() implementation can be simplified by moving the copy out of the remaining time to alarmtimer_do_nsleep() which is shared between the real nanosleep function and the restart function. The pointer to the timespec64 which is updated has to be stored in the restart block anyway. Instead of storing it only in the restart case, store it before calling alarmtimer_do_nsleep() and copy the remaining time in the signal exit path. [ tglx: Added changelog ] Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-14posix-cpu-timers: Move copyout of timespec into do_cpu_nanosleep()Al Viro1-35/+28
The posix-cpu-timer nanosleep() implementation can be simplified by moving the copy out of the remaining time to do_cpu_nanosleep() which is shared between the real nanosleep function and the restart function. The pointer to the timespec64 which is updated has to be stored in the restart block anyway. Instead of storing it only in the restart case, store it before calling do_cpu_nanosleep() and copy the remaining time in the signal exit path. [ tglx: Added changelog ] Signed-off-by: Al Viro <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: John Stultz <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-13nohz: Fix spurious warning when hrtimer and clockevent get out of syncFrederic Weisbecker1-2/+4
The sanity check ensuring that the tick expiry cache (ts->next_tick) is actually in sync with the hardware clock (dev->next_event) makes the wrong assumption that the clock can't be programmed later than the hrtimer deadline. In fact the clock hardware can be programmed later on some conditions such as: * The hrtimer deadline is already in the past. * The hrtimer deadline is earlier than the minimum delay supported by the hardware. Such conditions can be met when we program the tick, for example if the last jiffies update hasn't been seen by the current CPU yet, we may program the hrtimer to a deadline that is earlier than ktime_get() because last_jiffies_update is our timestamp base to compute the next tick. As a result, we can randomly observe such warning: WARNING: CPU: 5 PID: 0 at kernel/time/tick-sched.c:794 tick_nohz_stop_sched_tick kernel/time/tick-sched.c:791 [inline] Call Trace: tick_nohz_irq_exit tick_irq_exit irq_exit exiting_irq smp_call_function_interrupt smp_call_function_single_interrupt call_function_single_interrupt Therefore, let's rather make sure that the tick expiry cache is sync'ed with the tick hrtimer deadline, against which it is not supposed to drift away. The clock hardware instead has its own will and can't be used as a reliable comparison point. Reported-and-tested-by: Sasha Levin <[email protected]> Reported-and-tested-by: Abdul Haleem <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Cc: James Hartsock <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Tim Wright <[email protected]> Link: http://lkml.kernel.org/r/[email protected] [ Minor readability edit. ] Signed-off-by: Ingo Molnar <[email protected]>
2017-06-12posix-timers: Handle relative posix-timers correctlyThomas Gleixner1-0/+13
The recent rework of the posix timer internals broke the magic posix mechanism, which requires that relative timers are not affected by modifications of the underlying clock. That means relative CLOCK_REALTIME timers cannot use CLOCK_REALTIME, because that can be set and adjusted. The underlying hrtimer switches the clock for these timers to CLOCK_MONOTONIC. That still works, but reading the remaining time of such a timer has been broken in the rework. The old code used the hrtimer internals directly and avoided the posix clock callbacks. Now common_timer_get() uses the underlying kclock->timer_get() callback, which is still CLOCK_REALTIME based. So the remaining time of such a timer is calculated against the wrong time base. Handle it by switching the k_itimer->kclock pointer according to the resulting hrtimer mode. k_itimer->it_clock still contains CLOCK_REALTIME because the timer might be set with ABSTIME later and then it needs to switch back to the realtime posix clock implementation. Fixes: eae1c4ae275f ("posix-timers: Make use of cancel/arm callbacks") Reported-by: Andrei Vagin <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Cc: Cyrill Gorcunov <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-12posix-timers: Zero out oldval itimerspecThomas Gleixner1-0/+2
The recent posix timer rework moved the clearing of the itimerspec to the real syscall implementation, but forgot that the kclock->timer_get() is used by timer_settime() as well. That results in an uninitialized variable and bogus values returned to user space. Add the missing memset to timer_settime(). Fixes: eabdec043853 ("posix-timers: Zero settings value in common code") Reported-by: Andrei Vagin <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Cc: Cyrill Gorcunov <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-12tick/broadcast: Make tick_broadcast_setup_oneshot() staticStephen Boyd2-3/+3
This function isn't used outside of tick-broadcast.c, so let's mark it static. Signed-off-by: Stephen Boyd <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
2017-06-12posix-timers: Fix inverted SIGEV_NONE logic in common_timer_get()Thomas Gleixner1-1/+1
The refactoring of the posix-timer core to allow better code sharing introduced inverted logic vs. SIGEV_NONE timers in common_timer_get(). That causes hrtimer_forward() to be called on active timers, which rightfully triggers the warning hrtimer_forward(). Make sig_none what it says: signal mode == SIGEV_NONE. Fixes: 91d57bae0868 ("posix-timers: Make use of forward/remaining callbacks") Reported-by: Ye Xiaolong <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-08rcu: Remove nohz_full full-system-idle state machinePaul E. McKenney1-50/+0
The NO_HZ_FULL_SYSIDLE full-system-idle capability was added in 2013 by commit 0edd1b1784cb ("nohz_full: Add full-system-idle state machine"), but has not been used. This commit therefore removes it. If it turns out to be needed later, this commit can always be reverted. Signed-off-by: Paul E. McKenney <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Ingo Molnar <[email protected]> Acked-by: Linus Torvalds <[email protected]>
2017-06-05nohz: Fix buggy tick delay on IRQ stormsFrederic Weisbecker1-19/+2
When the tick is stopped and we reach the dynticks evaluation code on IRQ exit, we perform a soft tick restart if we observe an expired timer from there. It means we program the nearest possible tick but we stay in dynticks mode (ts->tick_stopped = 1) because we may need to stop the tick again after that expired timer is handled. Now this solution works most of the time but if we suffer an IRQ storm and those interrupts trigger faster than the hardware clockevents min delay, our tick won't fire until that IRQ storm is finished. Here is the problem: on IRQ exit we reprog the timer to at least NOW() + min_clockevents_delay. Another IRQ fires before the tick so we reschedule again to NOW() + min_clockevents_delay, etc... The tick is eternally rescheduled min_clockevents_delay ahead. A solution is to simply remove this soft tick restart. After all the normal dynticks evaluation path can handle 0 delay just fine. And by doing that we benefit from the optimization branch which avoids clock reprogramming if the clockevents deadline hasn't changed since the last reprog. This fixes our issue because we don't do repetitive clock reprog that always add hardware min delay. As a side effect it should even optimize the 0 delay path in general. Reported-and-tested-by: Octavian Purdila <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
2017-06-04alarmtimer: Switch over to generic set/get/rearm routineThomas Gleixner3-110/+29
All required callbacks are in place. Switch the alarm timer based posix interval timer callbacks to the common implementation and remove the incorrect private implementation. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04alarmtimer: Implement arm callbackThomas Gleixner1-0/+22
Preparatory change to utilize the common posix timer mechanisms. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04alarmtimer: Implement try_to_cancel callbackThomas Gleixner1-0/+10
Preparatory change to utilize the common posix timer mechanisms. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04alarmtimer: Implement remaining callbackThomas Gleixner1-9/+22
Preparatory change to utilize the common posix timer mechanisms. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04alarmtimer: Implement forward callbackThomas Gleixner1-0/+13
Preparatory change to utilize the common posix timer mechanisms. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04alarmtimer: Implement timer_rearm() callbackThomas Gleixner1-1/+14
Preparatory change to utilize the common posix timer mechanisms. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Make use of cancel/arm callbacksThomas Gleixner1-81/+100
Replace the hrtimer calls by calls to the new try_to_cancel()/arm() kclock callbacks and move the hrtimer specific implementation into the corresponding callback functions. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Add cancel/arm callbacksThomas Gleixner1-0/+3
Add timer_try_to_cancel() and timer_arm() callbacks to kclock which allow to make common_timer_set() usable by both hrtimer and alarmtimer based clocks. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Zero settings value in common codeThomas Gleixner2-6/+2
Zero out the settings struct in the common code so the callbacks do not have to do it themself. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Make use of forward/remaining callbacksThomas Gleixner1-15/+49
Replace the hrtimer calls by calls to the new forward/remaining kclock callbacks and move the hrtimer specific implementation into the corresponding callback functions. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Add forward/remaining callbacksThomas Gleixner1-0/+2
Add two callbacks to kclock which allow using common_)timer_get() for both hrtimer and alarm timer based clocks. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Add active flag to k_itimerThomas Gleixner1-1/+7
Keep track of the activation state of posix timers. This is a preparatory change for making common_timer_get() usable by both hrtimer and alarm timer implementations. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Use timer_rearm() callback in posixtimer_rearm()Thomas Gleixner3-10/+11
Use the new timer_rearm() callback to replace the conditional hardcoded calls into the hrtimer and cpu timer code. This allows later to bring the same logic to alarmtimers. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Rename do_schedule_next_timerThomas Gleixner2-6/+6
That function is a misnomer. Rename it with a proper prefix to posixtimer_rearm(). Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Add timer_rearm() callbackThomas Gleixner1-15/+18
Add a timer_rearm() callback which is used to make the rescheduling of posix interval timers independent of the underlying clock implementation. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Store k_clock pointer in k_itimerThomas Gleixner2-3/+6
Having the k_clock pointer in the k_itimer struct avoids the lookup in several code pathes and makes the next steps of unification of the hrtimer and alarmtimer based posix timers simpler. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Move interval out of the unionThomas Gleixner2-17/+16
Preparatory patch to unify the alarm timer and hrtimer based posix interval timer handling. The interval is used as a criteria for rearming decisions so moving it out of the clock specific data structures allows later unification. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Unify overrun/requeue_pending handlingThomas Gleixner2-18/+15
hrtimer based posix-timers and posix-cpu-timers handle the update of the rearming and overflow related status fields differently. Move that update to the common rearming code. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Move posix-timer internals to coreThomas Gleixner5-0/+36
None of these declarations is required outside of kernel/time. Move them to an internal header. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Cc: Christoph Hellwig <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Avoid gazillions of forward declarationsThomas Gleixner1-101/+89
Move it below the actual implementations as there are new callbacks coming which would require even more forward declarations. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-clocks: Remove interval timer facility and mmap/fasync callbacksThomas Gleixner1-113/+0
The only user of this facility is ptp_clock, which does not implement any of those functions. Remove them to prevent accidental users. Especially the interval timer interfaces are now more or less impossible to implement because the necessary infrastructure has been confined to the core code. Aside of that it's really complex to make these callbacks implemented according to spec as the alarm timer implementation demonstrates. If at all then a nanosleep callback might be a reasonable extension. For now keep just what ptp_clock needs. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04posix-timers: Remove unused export of posix_timer_event()Thomas Gleixner1-1/+0
Since the removal of the mmtimer driver the export is not longer needed. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04alarmtimer: Remove pointless config conditionalThomas Gleixner1-2/+1
Having a IF_ENABLED(CONFIG_POSIX_TIMERS) inside of a #ifdef CONFIG_POSIX_TIMERS section is pointless. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: John Stultz <[email protected]> Link: http://lkml.kernel.org/r/[email protected]
2017-06-04Merge branch 'timers/urgent' into WIP.timersThomas Gleixner2-11/+27
Pick up urgent fixes to avoid conflicts.
2017-06-04alarmtimer: Rate limit periodic intervalsThomas Gleixner1-0/+8
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 <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kostya Serebryany <[email protected]> Cc: syzkaller <[email protected]> Cc: John Stultz <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected]
2017-06-04alarmtimer: Prevent overflow of relative timersThomas Gleixner1-3/+3
Andrey reported a alartimer related RCU stall while fuzzing the kernel with syzkaller. The reason for this is an overflow in ktime_add() which brings the resulting time into negative space and causes immediate expiry of the timer. The following rearm with a small interval does not bring the timer back into positive space due to the same issue. This results in a permanent firing alarmtimer which hogs the CPU. Use ktime_add_safe() instead which detects the overflow and clamps the result to KTIME_SEC_MAX. Reported-by: Andrey Konovalov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kostya Serebryany <[email protected]> Cc: syzkaller <[email protected]> Cc: John Stultz <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected]
2017-05-30nohz: Reset next_tick cache even when the timer has no regsFrederic Weisbecker1-0/+2
Handle tick interrupts whose regs are NULL, out of general paranoia. It happens when hrtimer_interrupt() is called from non-interrupt contexts, such as hotplug CPU down events. Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>