Deferrable timers support for timerfd API
Get series with b4
b4 am 20120902054335.GA12741@lizardVersions newest first
- v1 Latest4 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | kernel/time: Add new helpers to convert ktime to/from jiffiesinclude/ include/ kernel/ | +28 | 0 replies | |
| 2/4 | timerfd: Move repeated logic into timefd_rearm()fs/ | +10 | 0 replies | |
| 3/4 | timerfd: Factor out timer-type unspecific timerfd_expire()fs/ | +6 | 0 replies | |
| 4/4 | timerfd: Add support for deferrable timersfs/ include/ | +65 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH/RFC 0/4] Deferrable timers support for timerfd API
Hi all,
This patch set 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.
The deferred timers are somewhat orthogonal to high-res external timers, since the deferred timer is tied to the system load, not just to some external decrementer source.
So, currently, the implementation has a HZ precision, and the maximum interval is jiffies resolution (i.e. with HZ=1000, on 32 bit that would be around max 49 days). Of course we can implement longer timeouts by rearming the timer, although it probably wouldn't make much sense in real world, so we keep it simple and just return E2BIG if we don't like the interval.
Note that the code is still using time calculation that is done by the hrtimer routines, so we pretty much reuse everything except for the timer events themselves (i.e. we use calculation results of hrtimer_forward_now() and hrtimer_expires_remaining(), but never start the hrtimer). So the code path is pretty much the same for both hrtimers and deferrable timers.
We will use the timers to periodically read /proc/vmstat without forcibly waking up the system; but let's see, maybe there are other use cases that might be interesting for PM folks.
Thanks!
Anton.
--
fs/timerfd.c | 87 +++++++++++++++++++++++++++++++++++++++++++------ include/linux/jiffies.h | 3 ++ include/linux/ktime.h | 3 +- include/linux/timerfd.h | 4 ++- kernel/time.c | 23 +++++++++++++ 5 files changed, 108 insertions(+), 12 deletions(-)