hrtimer: Handle remaining time proper for TIME_LOW_RES
authorThomas Gleixner <tglx@linutronix.de>
Thu, 14 Jan 2016 16:54:46 +0000 (16:54 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 27 Feb 2016 14:28:41 +0000 (14:28 +0000)
commite7989996ab9554b314dd8425c5f1d64a5b8a0a9b
treebdbdda9b0ca38ea8780f205b9d3f6fd040c46bc8
parent94bca3f746b5a8c236bbbb0bdff713d021cbf273
hrtimer: Handle remaining time proper for TIME_LOW_RES

commit 203cbf77de59fc8f13502dcfd11350c6d4a5c95f upstream.

If CONFIG_TIME_LOW_RES is enabled we add a jiffie to the relative timeout to
prevent short sleeps, but we do not account for that in interfaces which
retrieve the remaining time.

Helge observed that timerfd can return a remaining time larger than the
relative timeout. That's not expected and breaks userland test programs.

Store the information that the timer was armed relative and provide functions
to adjust the remaining time. To avoid bloating the hrtimer struct make state
a u8, which as a bonus results in better code on x86 at least.

Reported-and-tested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: linux-m68k@lists.linux-m68k.org
Cc: dhowells@redhat.com
Link: http://lkml.kernel.org/r/20160114164159.273328486@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[bwh: Backported to 3.2:
 - Use #ifdef instead of IS_ENABLED() as that doesn't work for config
   symbols that don't exist on the current architecture
 - Use KTIME_LOW_RES directly instead of hrtimer_resolution
 - Use ktime_sub() instead of modifying ktime::tv64 directly
 - Adjust filename, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/linux/hrtimer.h
kernel/hrtimer.c
kernel/time/timer_list.c