]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/posix-timers.c
[PATCH] posix-timers: fix requeue accounting when signal is ignored
[linux-2.6-omap-h63xx.git] / kernel / posix-timers.c
index 9e66e614862afd20acb0d1190dcb12f9a2101488..fa895fc2ecf555daad851fceea816659fdeddf30 100644 (file)
@@ -192,11 +192,9 @@ static inline int common_clock_set(const clockid_t which_clock,
        return do_sys_settimeofday(tp, NULL);
 }
 
-static inline int common_timer_create(struct k_itimer *new_timer)
+static int common_timer_create(struct k_itimer *new_timer)
 {
-       hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock);
-       new_timer->it.real.timer.data = new_timer;
-       new_timer->it.real.timer.function = posix_timer_fn;
+       hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
        return 0;
 }
 
@@ -290,7 +288,8 @@ void do_schedule_next_timer(struct siginfo *info)
                info->si_overrun = timr->it_overrun_last;
        }
 
-       unlock_timer(timr, flags);
+       if (timr)
+               unlock_timer(timr, flags);
 }
 
 int posix_timer_event(struct k_itimer *timr,int si_private)
@@ -354,6 +353,7 @@ static int posix_timer_fn(void *data)
                                hrtimer_forward(&timr->it.real.timer,
                                                timr->it.real.interval);
                        ret = HRTIMER_RESTART;
+                       ++timr->it_requeue_pending;
                }
        }
 
@@ -361,7 +361,7 @@ static int posix_timer_fn(void *data)
        return ret;
 }
 
-static inline struct task_struct * good_sigevent(sigevent_t * event)
+static struct task_struct * good_sigevent(sigevent_t * event)
 {
        struct task_struct *rtn = current->group_leader;
 
@@ -687,11 +687,12 @@ sys_timer_getoverrun(timer_t timer_id)
 
 /* Set a POSIX.1b interval timer. */
 /* timr->it_lock is taken. */
-static inline int
+static int
 common_timer_set(struct k_itimer *timr, int flags,
                 struct itimerspec *new_setting, struct itimerspec *old_setting)
 {
        struct hrtimer *timer = &timr->it.real.timer;
+       enum hrtimer_mode mode;
 
        if (old_setting)
                common_timer_get(timr, old_setting);
@@ -713,14 +714,10 @@ common_timer_set(struct k_itimer *timr, int flags,
        if (!new_setting->it_value.tv_sec && !new_setting->it_value.tv_nsec)
                return 0;
 
-       /* Posix madness. Only absolute CLOCK_REALTIME timers
-        * are affected by clock sets. So we must reiniatilize
-        * the timer.
-        */
-       if (timr->it_clock == CLOCK_REALTIME && (flags & TIMER_ABSTIME))
-               hrtimer_rebase(timer, CLOCK_REALTIME);
-       else
-               hrtimer_rebase(timer, CLOCK_MONOTONIC);
+       mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
+       hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
+       timr->it.real.timer.data = timr;
+       timr->it.real.timer.function = posix_timer_fn;
 
        timer->expires = timespec_to_ktime(new_setting->it_value);
 
@@ -728,11 +725,15 @@ common_timer_set(struct k_itimer *timr, int flags,
        timr->it.real.interval = timespec_to_ktime(new_setting->it_interval);
 
        /* SIGEV_NONE timers are not queued ! See common_timer_get */
-       if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
+       if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
+               /* Setup correct expiry time for relative timers */
+               if (mode == HRTIMER_REL)
+                       timer->expires = ktime_add(timer->expires,
+                                                  timer->base->get_time());
                return 0;
+       }
 
-       hrtimer_start(timer, timer->expires, (flags & TIMER_ABSTIME) ?
-                     HRTIMER_ABS : HRTIMER_REL);
+       hrtimer_start(timer, timer->expires, mode);
        return 0;
 }
 
@@ -829,7 +830,7 @@ retry_delete:
 /*
  * return timer owned by the process, used by exit_itimers
  */
-static inline void itimer_delete(struct k_itimer *timer)
+static void itimer_delete(struct k_itimer *timer)
 {
        unsigned long flags;
 
@@ -875,12 +876,6 @@ int do_posix_clock_nosettime(const clockid_t clockid, struct timespec *tp)
 }
 EXPORT_SYMBOL_GPL(do_posix_clock_nosettime);
 
-int do_posix_clock_notimer_create(struct k_itimer *timer)
-{
-       return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(do_posix_clock_notimer_create);
-
 int do_posix_clock_nonanosleep(const clockid_t clock, int flags,
                               struct timespec *t, struct timespec __user *r)
 {
@@ -947,21 +942,8 @@ sys_clock_getres(const clockid_t which_clock, struct timespec __user *tp)
 static int common_nsleep(const clockid_t which_clock, int flags,
                         struct timespec *tsave, struct timespec __user *rmtp)
 {
-       int mode = flags & TIMER_ABSTIME ? HRTIMER_ABS : HRTIMER_REL;
-       int clockid = which_clock;
-
-       switch (which_clock) {
-       case CLOCK_REALTIME:
-               /* Posix madness. Only absolute timers on clock realtime
-                  are affected by clock set. */
-               if (mode != HRTIMER_ABS)
-                       clockid = CLOCK_MONOTONIC;
-       case CLOCK_MONOTONIC:
-               break;
-       default:
-               return -EINVAL;
-       }
-       return hrtimer_nanosleep(tsave, rmtp, mode, clockid);
+       return hrtimer_nanosleep(tsave, rmtp, flags & TIMER_ABSTIME ?
+                                HRTIMER_ABS : HRTIMER_REL, which_clock);
 }
 
 asmlinkage long