• Thomas Gleixner's avatar
    timerfd: Allow timers to be cancelled when clock was set · 99ee5315
    Thomas Gleixner authored
    Some applications must be aware of clock realtime being set
    backward. A simple example is a clock applet which arms a timer for
    the next minute display. If clock realtime is set backward then the
    applet displays a stale time for the amount of time which the clock
    was set backwards. Due to that applications poll the time because we
    don't have an interface.
    
    Extend the timerfd interface by adding a flag which puts the timer
    onto a different internal realtime clock. All timers on this clock are
    expired whenever the clock was set.
    
    The timerfd core records the monotonic offset when the timer is
    created. When the timer is armed, then the current offset is compared
    to the previous recorded offset. When it has changed, then
    timerfd_settime returns -ECANCELED. When a timer is read the offset is
    compared and if it changed -ECANCELED returned to user space. Periodic
    timers are not rearmed in the cancelation case.
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Acked-by: default avatarJohn Stultz <johnstul@us.ibm.com>
    Cc: Chris Friesen <chris.friesen@genband.com>
    Tested-by: default avatarKay Sievers <kay.sievers@vrfy.org>
    Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Davide Libenzi <davidel@xmailserver.org>
    Reviewed-by: default avatarAlexander Shishkin <virtuoso@slind.org>
    Link: http://lkml.kernel.org/r/%3Calpine.LFD.2.02.1104271359580.3323%40ionos%3ESigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    99ee5315
timekeeping.c 28.7 KB