lkml.org 
[lkml]   [2014]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC patch 5/5] timerfd: Expose deferrable mode to user space
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 <tglx@linutronix.de>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
---
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




\
 
 \ /
  Last update: 2014-02-21 19:41    [W:0.101 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site