[PATCH v4 5/6] timerfd: Add support for deferrable timers

From: Alexey Perevalov
Date: Thu Feb 20 2014 - 11:25:25 EST


From: Anton Vorontsov <anton@xxxxxxxxxx>

This patch implements a userland-side API for generic deferrable timers,
per linux/timer.h:

* A deferrable timer will work normally when the system is busy, but
* will not cause a CPU to come out of idle just to service it; instead,
* the timer will be serviced when the CPU eventually wakes up with a
* subsequent non-deferrable timer.

These timers are crucial for power saving, i.e. periodic tasks that want
to work in background when the system is under use, but don't want to
cause wakeups themselves.

Currently, the implementation is based on high resolution timers. It
provides the same overrun count as for none deferrable timers. What's why
it doesn't not bring any new functionality into timerfd implementation,
except clockid validation.

Signed-off-by: Anton Vorontsov <anton.vorontsov@xxxxxxxxxx>
Signed-off-by: Alexey Perevalov <a.perevalov@xxxxxxxxxxx>
---
fs/timerfd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/timerfd.c b/fs/timerfd.c
index 4a349cb..c132fd2 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -326,7 +326,10 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
(clockid != CLOCK_MONOTONIC &&
clockid != CLOCK_REALTIME &&
clockid != CLOCK_REALTIME_ALARM &&
- clockid != CLOCK_BOOTTIME_ALARM))
+ clockid != CLOCK_BOOTTIME_ALARM &&
+ clockid != CLOCK_REALTIME_DEFERRABLE &&
+ clockid != CLOCK_MONOTONIC_DEFERRABLE &&
+ clockid != CLOCK_BOOTTIME_DEFERRABLE))
return -EINVAL;

ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -354,7 +357,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
return ufd;
}

-static int do_timerfd_settime(int ufd, int flags,
+static int do_timerfd_settime(int ufd, int flags,
const struct itimerspec *new,
struct itimerspec *old)
{
--
1.7.9.5

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