[PATCH] hrtimers: pass current time to hrtimer_forward()
authorRoman Zippel <zippel@linux-m68k.org>
Sun, 26 Mar 2006 09:38:06 +0000 (01:38 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 26 Mar 2006 16:57:02 +0000 (08:57 -0800)
Pass current time to hrtimer_forward().  This allows to use the softirq time
in the timer base when the forward function is called from the timer callback.
 Other places pass current time with a call to timer->base->get_time().

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/hrtimer.h
kernel/hrtimer.c
kernel/itimer.c
kernel/posix-timers.c

index 64e2754ca7342614c156e64d230573f29a5616eb..84fc186324e698ca64090919043a0d8613be7e18 100644 (file)
@@ -130,7 +130,8 @@ static inline int hrtimer_active(const struct hrtimer *timer)
 }
 
 /* Forward a hrtimer so it expires after now: */
-extern unsigned long hrtimer_forward(struct hrtimer *timer, ktime_t interval);
+extern unsigned long
+hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval);
 
 /* Precise sleep: */
 extern long hrtimer_nanosleep(struct timespec *rqtp,
index b728cc53452bfae6101e3d6ecda2b593e688f16c..e989c9981a9625f54a98eb21b20125663dd6961e 100644 (file)
@@ -301,18 +301,17 @@ void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
  * hrtimer_forward - forward the timer expiry
  *
  * @timer:     hrtimer to forward
+ * @now:       forward past this time
  * @interval:  the interval to forward
  *
  * Forward the timer expiry so it will expire in the future.
  * Returns the number of overruns.
  */
 unsigned long
-hrtimer_forward(struct hrtimer *timer, ktime_t interval)
+hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
 {
        unsigned long orun = 1;
-       ktime_t delta, now;
-
-       now = timer->base->get_time();
+       ktime_t delta;
 
        delta = ktime_sub(now, timer->expires);
 
index 680e6b70c8726f00d6a5d4dc3888fa5218b498fe..af2ec6b4392c9d0bdf003a56675ab12b3000c77c 100644 (file)
@@ -136,7 +136,8 @@ int it_real_fn(void *data)
 
        if (tsk->signal->it_real_incr.tv64 != 0) {
                hrtimer_forward(&tsk->signal->real_timer,
-                              tsk->signal->it_real_incr);
+                               tsk->signal->real_timer.base->softirq_time,
+                               tsk->signal->it_real_incr);
 
                return HRTIMER_RESTART;
        }
index 9944379360b50b5f9c16b1f289cf1d27da2674ad..255657accf02650198a1520cfa8f8132a6650776 100644 (file)
@@ -251,15 +251,18 @@ __initcall(init_posix_timers);
 
 static void schedule_next_timer(struct k_itimer *timr)
 {
+       struct hrtimer *timer = &timr->it.real.timer;
+
        if (timr->it.real.interval.tv64 == 0)
                return;
 
-       timr->it_overrun += hrtimer_forward(&timr->it.real.timer,
+       timr->it_overrun += hrtimer_forward(timer, timer->base->get_time(),
                                            timr->it.real.interval);
+
        timr->it_overrun_last = timr->it_overrun;
        timr->it_overrun = -1;
        ++timr->it_requeue_pending;
-       hrtimer_restart(&timr->it.real.timer);
+       hrtimer_restart(timer);
 }
 
 /*
@@ -334,6 +337,7 @@ EXPORT_SYMBOL_GPL(posix_timer_event);
 static int posix_timer_fn(void *data)
 {
        struct k_itimer *timr = data;
+       struct hrtimer *timer = &timr->it.real.timer;
        unsigned long flags;
        int si_private = 0;
        int ret = HRTIMER_NORESTART;
@@ -351,7 +355,8 @@ static int posix_timer_fn(void *data)
                 */
                if (timr->it.real.interval.tv64 != 0) {
                        timr->it_overrun +=
-                               hrtimer_forward(&timr->it.real.timer,
+                               hrtimer_forward(timer,
+                                               timer->base->softirq_time,
                                                timr->it.real.interval);
                        ret = HRTIMER_RESTART;
                        ++timr->it_requeue_pending;
@@ -623,7 +628,8 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
        if (timr->it_requeue_pending & REQUEUE_PENDING ||
            (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE) {
                timr->it_overrun +=
-                       hrtimer_forward(timer, timr->it.real.interval);
+                       hrtimer_forward(timer, timer->base->get_time(),
+                                       timr->it.real.interval);
                remaining = hrtimer_get_remaining(timer);
        }
  calci: