]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
hrtimer: Reverse patch to switch sys_nanosleep to hrtimer
authorTony Lindgren <tony@atomide.com>
Wed, 22 Feb 2006 03:26:44 +0000 (19:26 -0800)
committerTony Lindgren <tony@atomide.com>
Wed, 22 Feb 2006 03:26:44 +0000 (19:26 -0800)
Patch 6ba1b91213e81aa92b5cf7539f7d2a94ff54947c hrtimer: switch
sys_nanosleep to hrtimer breaks dynamic tick. All usleep calls
will fail as the next_timer_interrupt currently does not scan
hrtimer queues. This means the system will be potentially
asleep in the idle mode when the next hrtimer is supposed to
run. Until hrtimer_next_interrupt is implemented, we'll use
the old sys_nanosleep.

kernel/hrtimer.c
kernel/timer.c

index 5ae51f1bc7c80347d091bd4da0df2e8840c0bae4..47a6bc7e7e6bbc2a5641aa7b50b16fbc103275c2 100644 (file)
@@ -727,20 +727,6 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
        return -ERESTART_RESTARTBLOCK;
 }
 
-asmlinkage long
-sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp)
-{
-       struct timespec tu;
-
-       if (copy_from_user(&tu, rqtp, sizeof(tu)))
-               return -EFAULT;
-
-       if (!timespec_valid(&tu))
-               return -EINVAL;
-
-       return hrtimer_nanosleep(&tu, rmtp, HRTIMER_REL, CLOCK_MONOTONIC);
-}
-
 /*
  * Functions related to boot-time initialization:
  */
index fe3a9a9f832849bddbb3bf1be92268af99287aa9..bef6104f071f0d7b15c775506923eb4da15e790f 100644 (file)
@@ -1149,6 +1149,62 @@ asmlinkage long sys_gettid(void)
        return current->pid;
 }
 
+static long __sched nanosleep_restart(struct restart_block *restart)
+{
+       unsigned long expire = restart->arg0, now = jiffies;
+       struct timespec __user *rmtp = (struct timespec __user *) restart->arg1;
+       long ret;
+
+       /* Did it expire while we handled signals? */
+       if (!time_after(expire, now))
+               return 0;
+
+       expire = schedule_timeout_interruptible(expire - now);
+
+       ret = 0;
+       if (expire) {
+               struct timespec t;
+               jiffies_to_timespec(expire, &t);
+
+               ret = -ERESTART_RESTARTBLOCK;
+               if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))
+                       ret = -EFAULT;
+               /* The 'restart' block is already filled in */
+       }
+       return ret;
+}
+
+asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp)
+{
+       struct timespec t;
+       unsigned long expire;
+       long ret;
+
+       if (copy_from_user(&t, rqtp, sizeof(t)))
+               return -EFAULT;
+
+       if ((t.tv_nsec >= 1000000000L) || (t.tv_nsec < 0) || (t.tv_sec < 0))
+               return -EINVAL;
+
+       expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);
+       expire = schedule_timeout_interruptible(expire);
+
+       ret = 0;
+       if (expire) {
+               struct restart_block *restart;
+               jiffies_to_timespec(expire, &t);
+               if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))
+                       return -EFAULT;
+
+               restart = &current_thread_info()->restart_block;
+               restart->fn = nanosleep_restart;
+               restart->arg0 = jiffies + expire;
+               restart->arg1 = (unsigned long) rmtp;
+               ret = -ERESTART_RESTARTBLOCK;
+       }
+       return ret;
+}
+
 /*
  * sys_sysinfo - fill in sysinfo struct
  */