3 further range-hrtimer patches
Hi,
as reply to this email I have 3 further patches for the range-hrtimer patchkit:
Patch 1 and 2 change the futex and nanosleep code to also use range-hrtimers with the per process slack
Patch 3 adds a "peek-a-timer" capability; this is used from the cpuidle loop to run any soft-expired timers just before looking at how long we'll be idle (for determining the C-state etc); that way we'll have a longer idle period.
I'll add these patches to the git tree in a day or two, adjusted for comments based on this posting
Signature · 3 lines
Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
PATCH 1/3 hrtimer: make the futex() system call use the per process slack value
From: Arjan van de Ven <[email protected]>
Subject: [PATCH] hrtimer: make the futex() system call use the per process slack value
This patch makes the futex() system call use the per process slack value; with this users are able to externally control existing applications to reduce the wakeup rate.
--- kernel/futex.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
kernel/futex.c +5 -1
@@ -1296,10 +1296,14 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,if (!abs_time)schedule ();else { +unsigned long slack; + slack = current->timer_slack_ns; +if (rt_task (current)) + slack =0 ;hrtimer_init_on_stack (&t.timer,CLOCK_MONOTONIC ,HRTIMER_MODE_ABS );hrtimer_init_sleeper (&t, current); -hrtimer_set_expires (&t.timer, *abs_time); +hrtimer_set_expires_range_ns (&t.timer, *abs_time, slack);hrtimer_start_expires (&t.timer,HRTIMER_MODE_ABS );if (!hrtimer_active (&t.timer))
Signature · 8 lines
1.5.5.1 -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
PATCH 2/3 hrtimer: make the nanosleep() syscall use the per process slack
In reply to Arjan van de VenFrom: Arjan van de Ven <[email protected]>
Subject: [PATCH] hrtimer: make the nanosleep() syscall use the per process slack
This patch makes the nanosleep() system call use the per process slack value; with this users are able to externally control existing applications to reduce the wakeup rate.
--- kernel/hrtimer.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/hrtimer.c +6 -1
@@ -1563,9 +1563,14 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,struct restart_block *restart;struct hrtimer_sleeper t;int ret =0 ; +unsigned long slack; + + slack = current->timer_slack_ns; +if (rt_task (current)) + slack =0 ;hrtimer_init_on_stack (&t.timer, clockid, mode); -hrtimer_set_expires (&t.timer,timespec_to_ktime (*rqtp)); +hrtimer_set_expires_range_ns (&t.timer,timespec_to_ktime (*rqtp), slack);if (do_nanosleep (&t, mode)) goto out;
Signature · 8 lines
1.5.5.1 -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
PATCH 3/3 hrtimer: peek at the timer queue just before going idle
In reply to Arjan van de VenFrom: Arjan van de Ven <[email protected]>
Subject: [PATCH] hrtimer: peek at the timer queue just before going idle
As part of going idle, we already look at the time of the next timer event to determine which C-state to select etc.
This patch adds functionality that causes the timers that are past their soft expire time, to fire at this time, before we calculate the next wakeup time. This functionality will thus avoid wakeups by running timers before going idle rather than specially waking up for it.
--- drivers/cpuidle/cpuidle.c | 7 +++++++ include/linux/hrtimer.h | 5 +++++ kernel/hrtimer.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 0 deletions(-)
drivers/cpuidle/cpuidle.c +7 -0
@@ -16,6 +16,7 @@#include <linux/cpu.h> #include <linux/cpuidle.h> #include <linux/ktime.h> +#include <linux/hrtimer.h> #include "cpuidle.h"
@@ -60,6 +61,12 @@ static void cpuidle_idle_call(void)return ; } +/* +* run any timers that can be run now, at this point +* before calculating the idle duration etc. +*/ +hrtimer_peek_ahead_timers (); +/* ask the governor for the next state */ next_state = cpuidle_curr_governor->select (dev);if (need_resched ())
include/linux/hrtimer.h +5 -0
@@ -326,6 +326,11 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)extern ktime_t ktime_get (void );extern ktime_t ktime_get_real (void ); + +DECLARE_PER_CPU(struct tick_device, tick_cpu_device); +extern void hrtimer_peek_ahead_timers (void ); + +/* Exported timer functions: */ /* Initialize timers: */
kernel/hrtimer.c +30 -0
@@ -1381,6 +1381,36 @@ void hrtimer_interrupt(struct clock_event_device *dev)raise_softirq (HRTIMER_SOFTIRQ ); } +/** +* hrtimer_peek_ahead_timers -- run soft-expired timers now +* +* hrtimer_peek_ahead_timers will peek at the timer queue of +* the current cpu and check if there are any timers for which +* the soft expires time has passed. If any such timers exist, +* they are run immediately and then removed from the timer queue. +* +*/ +void hrtimer_peek_ahead_timers (void ) +{ +unsigned long flags; +struct tick_device *td; +struct clock_event_device *dev; + +if (hrtimer_hres_active ()) +return ; + +local_irq_save (flags); + td = &__get_cpu_var (tick_cpu_device); +if (!td) + goto out; + dev = td->evtdev; +if (!dev) + goto out; +hrtimer_interrupt (dev); +out: +local_irq_restore (flags); +} +static void run_hrtimer_softirq (struct softirq_action *h) {run_hrtimer_pending (&__get_cpu_var (hrtimer_bases));
Signature · 7 lines
1.5.5.1 -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org