Expose the deferrable timer mode to user space by adding a new
TDF_TIMER_DEFERRABLE flag.

The deferrable mode is available through the syscall timerfd_settime()
by handing in TDF_TIMER_IS_DEFERRABLE via the 'flags' argument.
TFD_TIMER_IS_DEFERRABLE and the other TFD_TIMER_ flags can be ored
together.

If a timer is started with this flag, the expiry of the timer is
relaxed. The timer is guaranteed to not expire before the given expiry
time, but the expiry can be delayed to the point where a non
deferrable timer expires. Deferred timers are not waking up a cpu from
a deep idle period.

Applications using the TFD_TIMER_IS_DEFERRABLE flag work on older kernels
as well, but the timers won't have the deferrable functionality.

Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Michael Kerrisk <[email protected]>
---
 fs/timerfd.c            |    1 +
 include/linux/timerfd.h |    1 +
 2 files changed, 2 insertions(+)

Index: tip/fs/timerfd.c
===================================================================
--- tip.orig/fs/timerfd.c
+++ tip/fs/timerfd.c
@@ -166,6 +166,7 @@ static int timerfd_setup(struct timerfd_
 
        htmode = (flags & TFD_TIMER_ABSTIME) ?
                HRTIMER_MODE_ABS: HRTIMER_MODE_REL;
+       htmode |= (flags & TFD_TIMER_DEFERRABLE) ? HRTIMER_MODE_DEFERRABLE : 0;
 
        texp = timespec_to_ktime(ktmr->it_value);
        ctx->expired = 0;
Index: tip/include/linux/timerfd.h
===================================================================
--- tip.orig/include/linux/timerfd.h
+++ tip/include/linux/timerfd.h
@@ -20,6 +20,7 @@
  */
 #define TFD_TIMER_ABSTIME (1 << 0)
 #define TFD_TIMER_CANCEL_ON_SET (1 << 1)
+#define TFD_TIMER_DEFERRABLE (2 << 1)
 #define TFD_CLOEXEC O_CLOEXEC
 #define TFD_NONBLOCK O_NONBLOCK
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to