Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/kernel/itimer.c |
| 3 | * |
| 4 | * Copyright (C) 1992 Darren Senn |
| 5 | */ |
| 6 | |
| 7 | /* These are all the functions necessary to implement itimers */ |
| 8 | |
| 9 | #include <linux/mm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/interrupt.h> |
| 11 | #include <linux/syscalls.h> |
| 12 | #include <linux/time.h> |
Ingo Molnar | 3f07c01 | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 13 | #include <linux/sched/signal.h> |
Ingo Molnar | 32ef551 | 2017-02-05 11:48:36 +0100 | [diff] [blame^] | 14 | #include <linux/sched/cputime.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/posix-timers.h> |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 16 | #include <linux/hrtimer.h> |
Xiao Guangrong | 3f0a525 | 2009-08-10 10:52:30 +0800 | [diff] [blame] | 17 | #include <trace/events/timer.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 19 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 21 | /** |
| 22 | * itimer_get_remtime - get remaining time for the timer |
| 23 | * |
| 24 | * @timer: the timer to read |
| 25 | * |
| 26 | * Returns the delta between the expiry time and now, which can be |
| 27 | * less than zero or 1usec for an pending expired timer |
| 28 | */ |
| 29 | static struct timeval itimer_get_remtime(struct hrtimer *timer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
Thomas Gleixner | 51cbb52 | 2016-01-14 16:54:48 +0000 | [diff] [blame] | 31 | ktime_t rem = __hrtimer_get_remaining(timer, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 33 | /* |
| 34 | * Racy but safe: if the itimer expires after the above |
| 35 | * hrtimer_get_remtime() call but before this condition |
| 36 | * then we return 0 - which is correct. |
| 37 | */ |
| 38 | if (hrtimer_active(timer)) { |
Thomas Gleixner | 2456e85 | 2016-12-25 11:38:40 +0100 | [diff] [blame] | 39 | if (rem <= 0) |
| 40 | rem = NSEC_PER_USEC; |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 41 | } else |
Thomas Gleixner | 2456e85 | 2016-12-25 11:38:40 +0100 | [diff] [blame] | 42 | rem = 0; |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 43 | |
| 44 | return ktime_to_timeval(rem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 47 | static void get_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, |
Stanislaw Gruszka | 8356b5f | 2009-07-29 12:15:27 +0200 | [diff] [blame] | 48 | struct itimerval *const value) |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 49 | { |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 50 | u64 val, interval; |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 51 | struct cpu_itimer *it = &tsk->signal->it[clock_id]; |
| 52 | |
| 53 | spin_lock_irq(&tsk->sighand->siglock); |
| 54 | |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 55 | val = it->expires; |
| 56 | interval = it->incr; |
| 57 | if (val) { |
Frederic Weisbecker | ebd7e7f | 2017-01-31 04:09:34 +0100 | [diff] [blame] | 58 | struct task_cputime cputime; |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 59 | u64 t; |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 60 | |
| 61 | thread_group_cputimer(tsk, &cputime); |
| 62 | if (clock_id == CPUCLOCK_PROF) |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 63 | t = cputime.utime + cputime.stime; |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 64 | else |
| 65 | /* CPUCLOCK_VIRT */ |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 66 | t = cputime.utime; |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 67 | |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 68 | if (val < t) |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 69 | /* about to fire */ |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 70 | val = TICK_NSEC; |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 71 | else |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 72 | val -= t; |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | spin_unlock_irq(&tsk->sighand->siglock); |
| 76 | |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 77 | value->it_value = ns_to_timeval(val); |
| 78 | value->it_interval = ns_to_timeval(interval); |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 79 | } |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | int do_getitimer(int which, struct itimerval *value) |
| 82 | { |
| 83 | struct task_struct *tsk = current; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | switch (which) { |
| 86 | case ITIMER_REAL: |
Thomas Gleixner | bc1978d | 2006-02-01 03:05:08 -0800 | [diff] [blame] | 87 | spin_lock_irq(&tsk->sighand->siglock); |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 88 | value->it_value = itimer_get_remtime(&tsk->signal->real_timer); |
| 89 | value->it_interval = |
| 90 | ktime_to_timeval(tsk->signal->it_real_incr); |
Thomas Gleixner | bc1978d | 2006-02-01 03:05:08 -0800 | [diff] [blame] | 91 | spin_unlock_irq(&tsk->sighand->siglock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | break; |
| 93 | case ITIMER_VIRTUAL: |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 94 | get_cpu_itimer(tsk, CPUCLOCK_VIRT, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | break; |
| 96 | case ITIMER_PROF: |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 97 | get_cpu_itimer(tsk, CPUCLOCK_PROF, value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | break; |
| 99 | default: |
| 100 | return(-EINVAL); |
| 101 | } |
| 102 | return 0; |
| 103 | } |
| 104 | |
Heiko Carstens | b290ebe | 2009-01-14 14:14:06 +0100 | [diff] [blame] | 105 | SYSCALL_DEFINE2(getitimer, int, which, struct itimerval __user *, value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | { |
| 107 | int error = -EFAULT; |
| 108 | struct itimerval get_buffer; |
| 109 | |
| 110 | if (value) { |
| 111 | error = do_getitimer(which, &get_buffer); |
| 112 | if (!error && |
| 113 | copy_to_user(value, &get_buffer, sizeof(get_buffer))) |
| 114 | error = -EFAULT; |
| 115 | } |
| 116 | return error; |
| 117 | } |
| 118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 120 | /* |
| 121 | * The timer is automagically restarted, when interval != 0 |
| 122 | */ |
Thomas Gleixner | c9cb2e3 | 2007-02-16 01:27:49 -0800 | [diff] [blame] | 123 | enum hrtimer_restart it_real_fn(struct hrtimer *timer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | { |
Roman Zippel | 05cfb61 | 2006-03-26 01:38:12 -0800 | [diff] [blame] | 125 | struct signal_struct *sig = |
Daniel Walker | 0719e37 | 2007-10-18 03:06:11 -0700 | [diff] [blame] | 126 | container_of(timer, struct signal_struct, real_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
Xiao Guangrong | 3f0a525 | 2009-08-10 10:52:30 +0800 | [diff] [blame] | 128 | trace_itimer_expire(ITIMER_REAL, sig->leader_pid, 0); |
Oleg Nesterov | fea9d17 | 2008-02-08 04:19:19 -0800 | [diff] [blame] | 129 | kill_pid_info(SIGALRM, SEND_SIG_PRIV, sig->leader_pid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 131 | return HRTIMER_NORESTART; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Stanislaw Gruszka | 8356b5f | 2009-07-29 12:15:27 +0200 | [diff] [blame] | 134 | static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, |
| 135 | const struct itimerval *const value, |
| 136 | struct itimerval *const ovalue) |
| 137 | { |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 138 | u64 oval, nval, ointerval, ninterval; |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 139 | struct cpu_itimer *it = &tsk->signal->it[clock_id]; |
| 140 | |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 141 | nval = timeval_to_ns(&value->it_value); |
| 142 | ninterval = timeval_to_ns(&value->it_interval); |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 143 | |
| 144 | spin_lock_irq(&tsk->sighand->siglock); |
| 145 | |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 146 | oval = it->expires; |
| 147 | ointerval = it->incr; |
| 148 | if (oval || nval) { |
Martin Schwidefsky | 6486163 | 2011-12-15 14:56:09 +0100 | [diff] [blame] | 149 | if (nval > 0) |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 150 | nval += TICK_NSEC; |
| 151 | set_process_cpu_timer(tsk, clock_id, &nval, &oval); |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 152 | } |
| 153 | it->expires = nval; |
| 154 | it->incr = ninterval; |
Xiao Guangrong | 3f0a525 | 2009-08-10 10:52:30 +0800 | [diff] [blame] | 155 | trace_itimer_state(clock_id == CPUCLOCK_VIRT ? |
| 156 | ITIMER_VIRTUAL : ITIMER_PROF, value, nval); |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 157 | |
| 158 | spin_unlock_irq(&tsk->sighand->siglock); |
| 159 | |
| 160 | if (ovalue) { |
Frederic Weisbecker | 858cf3a | 2017-01-31 04:09:35 +0100 | [diff] [blame] | 161 | ovalue->it_value = ns_to_timeval(oval); |
| 162 | ovalue->it_interval = ns_to_timeval(ointerval); |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
Thomas Gleixner | 7d99b7d | 2006-03-25 03:06:35 -0800 | [diff] [blame] | 166 | /* |
Thomas Gleixner | 7d99b7d | 2006-03-25 03:06:35 -0800 | [diff] [blame] | 167 | * Returns true if the timeval is in canonical form |
| 168 | */ |
| 169 | #define timeval_valid(t) \ |
| 170 | (((t)->tv_sec >= 0) && (((unsigned long) (t)->tv_usec) < USEC_PER_SEC)) |
| 171 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue) |
| 173 | { |
| 174 | struct task_struct *tsk = current; |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 175 | struct hrtimer *timer; |
| 176 | ktime_t expires; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | |
Thomas Gleixner | 7d99b7d | 2006-03-25 03:06:35 -0800 | [diff] [blame] | 178 | /* |
| 179 | * Validate the timevals in value. |
Thomas Gleixner | 7d99b7d | 2006-03-25 03:06:35 -0800 | [diff] [blame] | 180 | */ |
Adrian Bunk | 35bab75 | 2007-05-08 00:30:49 -0700 | [diff] [blame] | 181 | if (!timeval_valid(&value->it_value) || |
| 182 | !timeval_valid(&value->it_interval)) |
| 183 | return -EINVAL; |
Thomas Gleixner | 7d99b7d | 2006-03-25 03:06:35 -0800 | [diff] [blame] | 184 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | switch (which) { |
| 186 | case ITIMER_REAL: |
Thomas Gleixner | bc1978d | 2006-02-01 03:05:08 -0800 | [diff] [blame] | 187 | again: |
| 188 | spin_lock_irq(&tsk->sighand->siglock); |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 189 | timer = &tsk->signal->real_timer; |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 190 | if (ovalue) { |
| 191 | ovalue->it_value = itimer_get_remtime(timer); |
| 192 | ovalue->it_interval |
| 193 | = ktime_to_timeval(tsk->signal->it_real_incr); |
Oleg Nesterov | f01b1b0 | 2005-06-28 20:44:47 -0700 | [diff] [blame] | 194 | } |
Thomas Gleixner | a16a1c0 | 2006-02-01 03:05:09 -0800 | [diff] [blame] | 195 | /* We are sharing ->siglock with it_real_fn() */ |
| 196 | if (hrtimer_try_to_cancel(timer) < 0) { |
| 197 | spin_unlock_irq(&tsk->sighand->siglock); |
| 198 | goto again; |
| 199 | } |
Thomas Gleixner | 2ff678b | 2006-01-09 20:52:34 -0800 | [diff] [blame] | 200 | expires = timeval_to_ktime(value->it_value); |
Thomas Gleixner | 2456e85 | 2016-12-25 11:38:40 +0100 | [diff] [blame] | 201 | if (expires != 0) { |
Thomas Gleixner | 8bfd9a7 | 2007-02-16 01:28:12 -0800 | [diff] [blame] | 202 | tsk->signal->it_real_incr = |
| 203 | timeval_to_ktime(value->it_interval); |
Thomas Gleixner | c9cb2e3 | 2007-02-16 01:27:49 -0800 | [diff] [blame] | 204 | hrtimer_start(timer, expires, HRTIMER_MODE_REL); |
Thomas Gleixner | 8bfd9a7 | 2007-02-16 01:28:12 -0800 | [diff] [blame] | 205 | } else |
Thomas Gleixner | 2456e85 | 2016-12-25 11:38:40 +0100 | [diff] [blame] | 206 | tsk->signal->it_real_incr = 0; |
Thomas Gleixner | 8bfd9a7 | 2007-02-16 01:28:12 -0800 | [diff] [blame] | 207 | |
Xiao Guangrong | 3f0a525 | 2009-08-10 10:52:30 +0800 | [diff] [blame] | 208 | trace_itimer_state(ITIMER_REAL, value, 0); |
Thomas Gleixner | bc1978d | 2006-02-01 03:05:08 -0800 | [diff] [blame] | 209 | spin_unlock_irq(&tsk->sighand->siglock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | break; |
| 211 | case ITIMER_VIRTUAL: |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 212 | set_cpu_itimer(tsk, CPUCLOCK_VIRT, value, ovalue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | break; |
| 214 | case ITIMER_PROF: |
Stanislaw Gruszka | 42c4ab4 | 2009-07-29 12:15:26 +0200 | [diff] [blame] | 215 | set_cpu_itimer(tsk, CPUCLOCK_PROF, value, ovalue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | break; |
| 217 | default: |
| 218 | return -EINVAL; |
| 219 | } |
| 220 | return 0; |
| 221 | } |
| 222 | |
Nicolas Pitre | 74ba181 | 2016-11-11 00:10:08 -0500 | [diff] [blame] | 223 | #ifdef __ARCH_WANT_SYS_ALARM |
| 224 | |
Thomas Gleixner | c08b8a4 | 2006-03-25 03:06:33 -0800 | [diff] [blame] | 225 | /** |
| 226 | * alarm_setitimer - set alarm in seconds |
| 227 | * |
| 228 | * @seconds: number of seconds until alarm |
| 229 | * 0 disables the alarm |
| 230 | * |
| 231 | * Returns the remaining time in seconds of a pending timer or 0 when |
| 232 | * the timer is not active. |
| 233 | * |
| 234 | * On 32 bit machines the seconds value is limited to (INT_MAX/2) to avoid |
| 235 | * negative timeval settings which would cause immediate expiry. |
| 236 | */ |
Nicolas Pitre | 74ba181 | 2016-11-11 00:10:08 -0500 | [diff] [blame] | 237 | static unsigned int alarm_setitimer(unsigned int seconds) |
Thomas Gleixner | c08b8a4 | 2006-03-25 03:06:33 -0800 | [diff] [blame] | 238 | { |
| 239 | struct itimerval it_new, it_old; |
| 240 | |
| 241 | #if BITS_PER_LONG < 64 |
| 242 | if (seconds > INT_MAX) |
| 243 | seconds = INT_MAX; |
| 244 | #endif |
| 245 | it_new.it_value.tv_sec = seconds; |
| 246 | it_new.it_value.tv_usec = 0; |
| 247 | it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0; |
| 248 | |
| 249 | do_setitimer(ITIMER_REAL, &it_new, &it_old); |
| 250 | |
| 251 | /* |
| 252 | * We can't return 0 if we have an alarm pending ... And we'd |
| 253 | * better return too much than too little anyway |
| 254 | */ |
| 255 | if ((!it_old.it_value.tv_sec && it_old.it_value.tv_usec) || |
| 256 | it_old.it_value.tv_usec >= 500000) |
| 257 | it_old.it_value.tv_sec++; |
| 258 | |
| 259 | return it_old.it_value.tv_sec; |
| 260 | } |
| 261 | |
Nicolas Pitre | 74ba181 | 2016-11-11 00:10:08 -0500 | [diff] [blame] | 262 | /* |
| 263 | * For backwards compatibility? This can be done in libc so Alpha |
| 264 | * and all newer ports shouldn't need it. |
| 265 | */ |
| 266 | SYSCALL_DEFINE1(alarm, unsigned int, seconds) |
| 267 | { |
| 268 | return alarm_setitimer(seconds); |
| 269 | } |
| 270 | |
| 271 | #endif |
| 272 | |
Heiko Carstens | 362e9c0 | 2009-01-14 14:14:07 +0100 | [diff] [blame] | 273 | SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value, |
| 274 | struct itimerval __user *, ovalue) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | { |
| 276 | struct itimerval set_buffer, get_buffer; |
| 277 | int error; |
| 278 | |
| 279 | if (value) { |
| 280 | if(copy_from_user(&set_buffer, value, sizeof(set_buffer))) |
| 281 | return -EFAULT; |
Sasikantha babu | aa2bf9b | 2012-03-21 20:10:54 +0530 | [diff] [blame] | 282 | } else { |
Thomas Gleixner | 9886f44 | 2012-04-10 10:50:55 +0200 | [diff] [blame] | 283 | memset(&set_buffer, 0, sizeof(set_buffer)); |
| 284 | printk_once(KERN_WARNING "%s calls setitimer() with new_value NULL pointer." |
| 285 | " Misfeature support will be removed\n", |
| 286 | current->comm); |
Sasikantha babu | aa2bf9b | 2012-03-21 20:10:54 +0530 | [diff] [blame] | 287 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
| 289 | error = do_setitimer(which, &set_buffer, ovalue ? &get_buffer : NULL); |
| 290 | if (error || !ovalue) |
| 291 | return error; |
| 292 | |
| 293 | if (copy_to_user(ovalue, &get_buffer, sizeof(get_buffer))) |
Daniel Walker | 0719e37 | 2007-10-18 03:06:11 -0700 | [diff] [blame] | 294 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | return 0; |
| 296 | } |