diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2008-10-22 03:48:06 -0400 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2008-10-22 03:48:06 -0400 |
| commit | 268a3dcfea2077fca60d3715caa5c96f9b5e6ea7 (patch) | |
| tree | c2232774508424e677e27f296090a68c775e4669 /include | |
| parent | c4bd822e7b12a9008241d76db45b665f2fef180c (diff) | |
| parent | 592aa999d6a272856c9bfbdaac0cfba1bb37c24c (diff) | |
Merge branch 'timers/range-hrtimers' into v28-range-hrtimers-for-linus-v2
Conflicts:
kernel/time/tick-sched.c
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/hrtimer.h | 105 | ||||
| -rw-r--r-- | include/linux/init_task.h | 1 | ||||
| -rw-r--r-- | include/linux/poll.h | 8 | ||||
| -rw-r--r-- | include/linux/prctl.h | 7 | ||||
| -rw-r--r-- | include/linux/sched.h | 6 | ||||
| -rw-r--r-- | include/linux/thread_info.h | 8 | ||||
| -rw-r--r-- | include/linux/time.h | 4 |
7 files changed, 132 insertions, 7 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 9a4e35cd5f79..2b3645b1acf4 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h | |||
| @@ -20,6 +20,8 @@ | |||
| 20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
| 22 | #include <linux/wait.h> | 22 | #include <linux/wait.h> |
| 23 | #include <linux/percpu.h> | ||
| 24 | |||
| 23 | 25 | ||
| 24 | struct hrtimer_clock_base; | 26 | struct hrtimer_clock_base; |
| 25 | struct hrtimer_cpu_base; | 27 | struct hrtimer_cpu_base; |
| @@ -101,9 +103,14 @@ enum hrtimer_cb_mode { | |||
| 101 | /** | 103 | /** |
| 102 | * struct hrtimer - the basic hrtimer structure | 104 | * struct hrtimer - the basic hrtimer structure |
| 103 | * @node: red black tree node for time ordered insertion | 105 | * @node: red black tree node for time ordered insertion |
| 104 | * @expires: the absolute expiry time in the hrtimers internal | 106 | * @_expires: the absolute expiry time in the hrtimers internal |
| 105 | * representation. The time is related to the clock on | 107 | * representation. The time is related to the clock on |
| 106 | * which the timer is based. | 108 | * which the timer is based. Is setup by adding |
| 109 | * slack to the _softexpires value. For non range timers | ||
| 110 | * identical to _softexpires. | ||
| 111 | * @_softexpires: the absolute earliest expiry time of the hrtimer. | ||
| 112 | * The time which was given as expiry time when the timer | ||
| 113 | * was armed. | ||
| 107 | * @function: timer expiry callback function | 114 | * @function: timer expiry callback function |
| 108 | * @base: pointer to the timer base (per cpu and per clock) | 115 | * @base: pointer to the timer base (per cpu and per clock) |
| 109 | * @state: state information (See bit values above) | 116 | * @state: state information (See bit values above) |
| @@ -121,7 +128,8 @@ enum hrtimer_cb_mode { | |||
| 121 | */ | 128 | */ |
| 122 | struct hrtimer { | 129 | struct hrtimer { |
| 123 | struct rb_node node; | 130 | struct rb_node node; |
| 124 | ktime_t expires; | 131 | ktime_t _expires; |
| 132 | ktime_t _softexpires; | ||
| 125 | enum hrtimer_restart (*function)(struct hrtimer *); | 133 | enum hrtimer_restart (*function)(struct hrtimer *); |
| 126 | struct hrtimer_clock_base *base; | 134 | struct hrtimer_clock_base *base; |
| 127 | unsigned long state; | 135 | unsigned long state; |
| @@ -201,6 +209,71 @@ struct hrtimer_cpu_base { | |||
| 201 | #endif | 209 | #endif |
| 202 | }; | 210 | }; |
| 203 | 211 | ||
| 212 | static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) | ||
| 213 | { | ||
| 214 | timer->_expires = time; | ||
| 215 | timer->_softexpires = time; | ||
| 216 | } | ||
| 217 | |||
| 218 | static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta) | ||
| 219 | { | ||
| 220 | timer->_softexpires = time; | ||
| 221 | timer->_expires = ktime_add_safe(time, delta); | ||
| 222 | } | ||
| 223 | |||
| 224 | static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, unsigned long delta) | ||
| 225 | { | ||
| 226 | timer->_softexpires = time; | ||
| 227 | timer->_expires = ktime_add_safe(time, ns_to_ktime(delta)); | ||
| 228 | } | ||
| 229 | |||
| 230 | static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64) | ||
| 231 | { | ||
| 232 | timer->_expires.tv64 = tv64; | ||
| 233 | timer->_softexpires.tv64 = tv64; | ||
| 234 | } | ||
| 235 | |||
| 236 | static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time) | ||
| 237 | { | ||
| 238 | timer->_expires = ktime_add_safe(timer->_expires, time); | ||
| 239 | timer->_softexpires = ktime_add_safe(timer->_softexpires, time); | ||
| 240 | } | ||
| 241 | |||
| 242 | static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns) | ||
| 243 | { | ||
| 244 | timer->_expires = ktime_add_ns(timer->_expires, ns); | ||
| 245 | timer->_softexpires = ktime_add_ns(timer->_softexpires, ns); | ||
| 246 | } | ||
| 247 | |||
| 248 | static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer) | ||
| 249 | { | ||
| 250 | return timer->_expires; | ||
| 251 | } | ||
| 252 | |||
| 253 | static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer) | ||
| 254 | { | ||
| 255 | return timer->_softexpires; | ||
| 256 | } | ||
| 257 | |||
| 258 | static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer) | ||
| 259 | { | ||
| 260 | return timer->_expires.tv64; | ||
| 261 | } | ||
| 262 | static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer) | ||
| 263 | { | ||
| 264 | return timer->_softexpires.tv64; | ||
| 265 | } | ||
| 266 | |||
| 267 | static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer) | ||
| 268 | { | ||
| 269 | return ktime_to_ns(timer->_expires); | ||
| 270 | } | ||
| 271 | |||
| 272 | static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer) | ||
| 273 | { | ||
| 274 | return ktime_sub(timer->_expires, timer->base->get_time()); | ||
| 275 | } | ||
| 276 | |||
| 204 | #ifdef CONFIG_HIGH_RES_TIMERS | 277 | #ifdef CONFIG_HIGH_RES_TIMERS |
| 205 | struct clock_event_device; | 278 | struct clock_event_device; |
| 206 | 279 | ||
| @@ -221,6 +294,8 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer) | |||
| 221 | return timer->base->cpu_base->hres_active; | 294 | return timer->base->cpu_base->hres_active; |
| 222 | } | 295 | } |
| 223 | 296 | ||
| 297 | extern void hrtimer_peek_ahead_timers(void); | ||
| 298 | |||
| 224 | /* | 299 | /* |
| 225 | * The resolution of the clocks. The resolution value is returned in | 300 | * The resolution of the clocks. The resolution value is returned in |
| 226 | * the clock_getres() system call to give application programmers an | 301 | * the clock_getres() system call to give application programmers an |
| @@ -243,6 +318,7 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer) | |||
| 243 | * is expired in the next softirq when the clock was advanced. | 318 | * is expired in the next softirq when the clock was advanced. |
| 244 | */ | 319 | */ |
| 245 | static inline void clock_was_set(void) { } | 320 | static inline void clock_was_set(void) { } |
| 321 | static inline void hrtimer_peek_ahead_timers(void) { } | ||
| 246 | 322 | ||
| 247 | static inline void hres_timers_resume(void) { } | 323 | static inline void hres_timers_resume(void) { } |
| 248 | 324 | ||
| @@ -264,6 +340,10 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer) | |||
| 264 | extern ktime_t ktime_get(void); | 340 | extern ktime_t ktime_get(void); |
| 265 | extern ktime_t ktime_get_real(void); | 341 | extern ktime_t ktime_get_real(void); |
| 266 | 342 | ||
| 343 | |||
| 344 | DECLARE_PER_CPU(struct tick_device, tick_cpu_device); | ||
| 345 | |||
| 346 | |||
| 267 | /* Exported timer functions: */ | 347 | /* Exported timer functions: */ |
| 268 | 348 | ||
| 269 | /* Initialize timers: */ | 349 | /* Initialize timers: */ |
| @@ -288,12 +368,25 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { } | |||
| 288 | /* Basic timer operations: */ | 368 | /* Basic timer operations: */ |
| 289 | extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, | 369 | extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, |
| 290 | const enum hrtimer_mode mode); | 370 | const enum hrtimer_mode mode); |
| 371 | extern int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, | ||
| 372 | unsigned long range_ns, const enum hrtimer_mode mode); | ||
| 291 | extern int hrtimer_cancel(struct hrtimer *timer); | 373 | extern int hrtimer_cancel(struct hrtimer *timer); |
| 292 | extern int hrtimer_try_to_cancel(struct hrtimer *timer); | 374 | extern int hrtimer_try_to_cancel(struct hrtimer *timer); |
| 293 | 375 | ||
| 376 | static inline int hrtimer_start_expires(struct hrtimer *timer, | ||
| 377 | enum hrtimer_mode mode) | ||
| 378 | { | ||
| 379 | unsigned long delta; | ||
| 380 | ktime_t soft, hard; | ||
| 381 | soft = hrtimer_get_softexpires(timer); | ||
| 382 | hard = hrtimer_get_expires(timer); | ||
| 383 | delta = ktime_to_ns(ktime_sub(hard, soft)); | ||
| 384 | return hrtimer_start_range_ns(timer, soft, delta, mode); | ||
| 385 | } | ||
| 386 | |||
| 294 | static inline int hrtimer_restart(struct hrtimer *timer) | 387 | static inline int hrtimer_restart(struct hrtimer *timer) |
| 295 | { | 388 | { |
| 296 | return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS); | 389 | return hrtimer_start_expires(timer, HRTIMER_MODE_ABS); |
| 297 | } | 390 | } |
| 298 | 391 | ||
| 299 | /* Query timers: */ | 392 | /* Query timers: */ |
| @@ -350,6 +443,10 @@ extern long hrtimer_nanosleep_restart(struct restart_block *restart_block); | |||
| 350 | extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, | 443 | extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, |
| 351 | struct task_struct *tsk); | 444 | struct task_struct *tsk); |
| 352 | 445 | ||
| 446 | extern int schedule_hrtimeout_range(ktime_t *expires, unsigned long delta, | ||
| 447 | const enum hrtimer_mode mode); | ||
| 448 | extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode); | ||
| 449 | |||
| 353 | /* Soft interrupt function to run the hrtimer queues: */ | 450 | /* Soft interrupt function to run the hrtimer queues: */ |
| 354 | extern void hrtimer_run_queues(void); | 451 | extern void hrtimer_run_queues(void); |
| 355 | extern void hrtimer_run_pending(void); | 452 | extern void hrtimer_run_pending(void); |
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 021d8e720c79..23fd8909b9e5 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
| @@ -170,6 +170,7 @@ extern struct group_info init_groups; | |||
| 170 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ | 170 | .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
| 171 | .fs_excl = ATOMIC_INIT(0), \ | 171 | .fs_excl = ATOMIC_INIT(0), \ |
| 172 | .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ | 172 | .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \ |
| 173 | .timer_slack_ns = 50000, /* 50 usec default slack */ \ | ||
| 173 | .pids = { \ | 174 | .pids = { \ |
| 174 | [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \ | 175 | [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \ |
| 175 | [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \ | 176 | [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \ |
diff --git a/include/linux/poll.h b/include/linux/poll.h index ef453828877a..badd98ab06f6 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h | |||
| @@ -114,11 +114,13 @@ void zero_fd_set(unsigned long nr, unsigned long *fdset) | |||
| 114 | 114 | ||
| 115 | #define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1) | 115 | #define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1) |
| 116 | 116 | ||
| 117 | extern int do_select(int n, fd_set_bits *fds, s64 *timeout); | 117 | extern int do_select(int n, fd_set_bits *fds, struct timespec *end_time); |
| 118 | extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds, | 118 | extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds, |
| 119 | s64 *timeout); | 119 | struct timespec *end_time); |
| 120 | extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, | 120 | extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, |
| 121 | fd_set __user *exp, s64 *timeout); | 121 | fd_set __user *exp, struct timespec *end_time); |
| 122 | |||
| 123 | extern int poll_select_set_timeout(struct timespec *to, long sec, long nsec); | ||
| 122 | 124 | ||
| 123 | #endif /* KERNEL */ | 125 | #endif /* KERNEL */ |
| 124 | 126 | ||
diff --git a/include/linux/prctl.h b/include/linux/prctl.h index 5ad79198d6f9..48d887e3c6e7 100644 --- a/include/linux/prctl.h +++ b/include/linux/prctl.h | |||
| @@ -78,4 +78,11 @@ | |||
| 78 | #define PR_GET_SECUREBITS 27 | 78 | #define PR_GET_SECUREBITS 27 |
| 79 | #define PR_SET_SECUREBITS 28 | 79 | #define PR_SET_SECUREBITS 28 |
| 80 | 80 | ||
| 81 | /* | ||
| 82 | * Get/set the timerslack as used by poll/select/nanosleep | ||
| 83 | * A value of 0 means "use default" | ||
| 84 | */ | ||
| 85 | #define PR_SET_TIMERSLACK 29 | ||
| 86 | #define PR_GET_TIMERSLACK 30 | ||
| 87 | |||
| 81 | #endif /* _LINUX_PRCTL_H */ | 88 | #endif /* _LINUX_PRCTL_H */ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 5c38db536e07..9ee3bed0ff06 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -1346,6 +1346,12 @@ struct task_struct { | |||
| 1346 | int latency_record_count; | 1346 | int latency_record_count; |
| 1347 | struct latency_record latency_record[LT_SAVECOUNT]; | 1347 | struct latency_record latency_record[LT_SAVECOUNT]; |
| 1348 | #endif | 1348 | #endif |
| 1349 | /* | ||
| 1350 | * time slack values; these are used to round up poll() and | ||
| 1351 | * select() etc timeout values. These are in nanoseconds. | ||
| 1352 | */ | ||
| 1353 | unsigned long timer_slack_ns; | ||
| 1354 | unsigned long default_timer_slack_ns; | ||
| 1349 | }; | 1355 | }; |
| 1350 | 1356 | ||
| 1351 | /* | 1357 | /* |
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index 38a56477f27a..e6b820f8b56b 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h | |||
| @@ -38,6 +38,14 @@ struct restart_block { | |||
| 38 | #endif | 38 | #endif |
| 39 | u64 expires; | 39 | u64 expires; |
| 40 | } nanosleep; | 40 | } nanosleep; |
| 41 | /* For poll */ | ||
| 42 | struct { | ||
| 43 | struct pollfd __user *ufds; | ||
| 44 | int nfds; | ||
| 45 | int has_timeout; | ||
| 46 | unsigned long tv_sec; | ||
| 47 | unsigned long tv_nsec; | ||
| 48 | } poll; | ||
| 41 | }; | 49 | }; |
| 42 | }; | 50 | }; |
| 43 | 51 | ||
diff --git a/include/linux/time.h b/include/linux/time.h index 4f1c9db57707..ce321ac5c8f8 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
| @@ -40,6 +40,8 @@ extern struct timezone sys_tz; | |||
| 40 | #define NSEC_PER_SEC 1000000000L | 40 | #define NSEC_PER_SEC 1000000000L |
| 41 | #define FSEC_PER_SEC 1000000000000000L | 41 | #define FSEC_PER_SEC 1000000000000000L |
| 42 | 42 | ||
| 43 | #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) | ||
| 44 | |||
| 43 | static inline int timespec_equal(const struct timespec *a, | 45 | static inline int timespec_equal(const struct timespec *a, |
| 44 | const struct timespec *b) | 46 | const struct timespec *b) |
| 45 | { | 47 | { |
| @@ -74,6 +76,8 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, | |||
| 74 | const unsigned int min, const unsigned int sec); | 76 | const unsigned int min, const unsigned int sec); |
| 75 | 77 | ||
| 76 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); | 78 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); |
| 79 | extern struct timespec timespec_add_safe(const struct timespec lhs, | ||
| 80 | const struct timespec rhs); | ||
| 77 | 81 | ||
| 78 | /* | 82 | /* |
| 79 | * sub = lhs - rhs, in normalized form | 83 | * sub = lhs - rhs, in normalized form |
