aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/compat.c
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2007-10-15 17:13:56 -0400
committerThomas Gleixner <tglx@linutronix.de>2007-10-18 16:54:18 -0400
commitc70878b4e0b6cf8d2f1e46319e48e821ef4a8aba (patch)
treea05d3dc9f2dfe2a0f18819b4eb60ba7f9d7833f6 /kernel/compat.c
parent04c227140fed77587432667a574b14736a06dd7f (diff)
hrtimer: hook compat_sys_nanosleep up to high res timer code
Now we have high res timers on ppc64 I thought Id test them. It turns out compat_sys_nanosleep hasnt been converted to the hrtimer code and so is limited to HZ resolution. The follow patch converts compat_sys_nanosleep to use high res timers. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/compat.c')
-rw-r--r--kernel/compat.c57
1 files changed, 11 insertions, 46 deletions
diff --git a/kernel/compat.c b/kernel/compat.c
index 3bae3742c2aa..252a446fb0d0 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -40,62 +40,27 @@ int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user
40 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; 40 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
41} 41}
42 42
43static long compat_nanosleep_restart(struct restart_block *restart)
44{
45 unsigned long expire = restart->arg0, now = jiffies;
46 struct compat_timespec __user *rmtp;
47
48 /* Did it expire while we handled signals? */
49 if (!time_after(expire, now))
50 return 0;
51
52 expire = schedule_timeout_interruptible(expire - now);
53 if (expire == 0)
54 return 0;
55
56 rmtp = (struct compat_timespec __user *)restart->arg1;
57 if (rmtp) {
58 struct compat_timespec ct;
59 struct timespec t;
60
61 jiffies_to_timespec(expire, &t);
62 ct.tv_sec = t.tv_sec;
63 ct.tv_nsec = t.tv_nsec;
64 if (copy_to_user(rmtp, &ct, sizeof(ct)))
65 return -EFAULT;
66 }
67 /* The 'restart' block is already filled in */
68 return -ERESTART_RESTARTBLOCK;
69}
70
71asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, 43asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
72 struct compat_timespec __user *rmtp) 44 struct compat_timespec __user *rmtp)
73{ 45{
74 struct timespec t; 46 struct timespec tu, rmt;
75 struct restart_block *restart; 47 long ret;
76 unsigned long expire;
77 48
78 if (get_compat_timespec(&t, rqtp)) 49 if (get_compat_timespec(&tu, rqtp))
79 return -EFAULT; 50 return -EFAULT;
80 51
81 if ((t.tv_nsec >= 1000000000L) || (t.tv_nsec < 0) || (t.tv_sec < 0)) 52 if (!timespec_valid(&tu))
82 return -EINVAL; 53 return -EINVAL;
83 54
84 expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec); 55 ret = hrtimer_nanosleep(&tu, rmtp ? &rmt : NULL, HRTIMER_MODE_REL,
85 expire = schedule_timeout_interruptible(expire); 56 CLOCK_MONOTONIC);
86 if (expire == 0)
87 return 0;
88 57
89 if (rmtp) { 58 if (ret && rmtp) {
90 jiffies_to_timespec(expire, &t); 59 if (put_compat_timespec(&rmt, rmtp))
91 if (put_compat_timespec(&t, rmtp))
92 return -EFAULT; 60 return -EFAULT;
93 } 61 }
94 restart = &current_thread_info()->restart_block; 62
95 restart->fn = compat_nanosleep_restart; 63 return ret;
96 restart->arg0 = jiffies + expire;
97 restart->arg1 = (unsigned long) rmtp;
98 return -ERESTART_RESTARTBLOCK;
99} 64}
100 65
101static inline long get_compat_itimerval(struct itimerval *o, 66static inline long get_compat_itimerval(struct itimerval *o,