aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/hrtimer.h96
-rw-r--r--include/linux/init_task.h1
-rw-r--r--include/linux/poll.h8
-rw-r--r--include/linux/prctl.h7
-rw-r--r--include/linux/sched.h6
-rw-r--r--include/linux/thread_info.h8
-rw-r--r--include/linux/time.h4
7 files changed, 125 insertions, 5 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 2f245fe63bda..cb25c1cc2352 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
24struct hrtimer_clock_base; 26struct hrtimer_clock_base;
25struct hrtimer_cpu_base; 27struct hrtimer_cpu_base;
@@ -121,7 +123,8 @@ enum hrtimer_cb_mode {
121 */ 123 */
122struct hrtimer { 124struct hrtimer {
123 struct rb_node node; 125 struct rb_node node;
124 ktime_t expires; 126 ktime_t _expires;
127 ktime_t _softexpires;
125 enum hrtimer_restart (*function)(struct hrtimer *); 128 enum hrtimer_restart (*function)(struct hrtimer *);
126 struct hrtimer_clock_base *base; 129 struct hrtimer_clock_base *base;
127 unsigned long state; 130 unsigned long state;
@@ -207,6 +210,71 @@ struct hrtimer_cpu_base {
207#endif 210#endif
208}; 211};
209 212
213static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
214{
215 timer->_expires = time;
216 timer->_softexpires = time;
217}
218
219static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
220{
221 timer->_softexpires = time;
222 timer->_expires = ktime_add_safe(time, delta);
223}
224
225static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, unsigned long delta)
226{
227 timer->_softexpires = time;
228 timer->_expires = ktime_add_safe(time, ns_to_ktime(delta));
229}
230
231static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
232{
233 timer->_expires.tv64 = tv64;
234 timer->_softexpires.tv64 = tv64;
235}
236
237static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
238{
239 timer->_expires = ktime_add_safe(timer->_expires, time);
240 timer->_softexpires = ktime_add_safe(timer->_softexpires, time);
241}
242
243static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns)
244{
245 timer->_expires = ktime_add_ns(timer->_expires, ns);
246 timer->_softexpires = ktime_add_ns(timer->_softexpires, ns);
247}
248
249static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
250{
251 return timer->_expires;
252}
253
254static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
255{
256 return timer->_softexpires;
257}
258
259static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
260{
261 return timer->_expires.tv64;
262}
263static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
264{
265 return timer->_softexpires.tv64;
266}
267
268static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
269{
270 return ktime_to_ns(timer->_expires);
271}
272
273static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
274{
275 return ktime_sub(timer->_expires, timer->base->get_time());
276}
277
210#ifdef CONFIG_HIGH_RES_TIMERS 278#ifdef CONFIG_HIGH_RES_TIMERS
211struct clock_event_device; 279struct clock_event_device;
212 280
@@ -227,6 +295,8 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
227 return timer->base->cpu_base->hres_active; 295 return timer->base->cpu_base->hres_active;
228} 296}
229 297
298extern void hrtimer_peek_ahead_timers(void);
299
230/* 300/*
231 * The resolution of the clocks. The resolution value is returned in 301 * The resolution of the clocks. The resolution value is returned in
232 * the clock_getres() system call to give application programmers an 302 * the clock_getres() system call to give application programmers an
@@ -249,6 +319,7 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
249 * is expired in the next softirq when the clock was advanced. 319 * is expired in the next softirq when the clock was advanced.
250 */ 320 */
251static inline void clock_was_set(void) { } 321static inline void clock_was_set(void) { }
322static inline void hrtimer_peek_ahead_timers(void) { }
252 323
253static inline void hres_timers_resume(void) { } 324static inline void hres_timers_resume(void) { }
254 325
@@ -270,6 +341,10 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
270extern ktime_t ktime_get(void); 341extern ktime_t ktime_get(void);
271extern ktime_t ktime_get_real(void); 342extern ktime_t ktime_get_real(void);
272 343
344
345DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
346
347
273/* Exported timer functions: */ 348/* Exported timer functions: */
274 349
275/* Initialize timers: */ 350/* Initialize timers: */
@@ -294,12 +369,25 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
294/* Basic timer operations: */ 369/* Basic timer operations: */
295extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, 370extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
296 const enum hrtimer_mode mode); 371 const enum hrtimer_mode mode);
372extern int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
373 unsigned long range_ns, const enum hrtimer_mode mode);
297extern int hrtimer_cancel(struct hrtimer *timer); 374extern int hrtimer_cancel(struct hrtimer *timer);
298extern int hrtimer_try_to_cancel(struct hrtimer *timer); 375extern int hrtimer_try_to_cancel(struct hrtimer *timer);
299 376
377static inline int hrtimer_start_expires(struct hrtimer *timer,
378 enum hrtimer_mode mode)
379{
380 unsigned long delta;
381 ktime_t soft, hard;
382 soft = hrtimer_get_softexpires(timer);
383 hard = hrtimer_get_expires(timer);
384 delta = ktime_to_ns(ktime_sub(hard, soft));
385 return hrtimer_start_range_ns(timer, soft, delta, mode);
386}
387
300static inline int hrtimer_restart(struct hrtimer *timer) 388static inline int hrtimer_restart(struct hrtimer *timer)
301{ 389{
302 return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS); 390 return hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
303} 391}
304 392
305/* Query timers: */ 393/* Query timers: */
@@ -356,6 +444,10 @@ extern long hrtimer_nanosleep_restart(struct restart_block *restart_block);
356extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, 444extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
357 struct task_struct *tsk); 445 struct task_struct *tsk);
358 446
447extern int schedule_hrtimeout_range(ktime_t *expires, unsigned long delta,
448 const enum hrtimer_mode mode);
449extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode);
450
359/* Soft interrupt function to run the hrtimer queues: */ 451/* Soft interrupt function to run the hrtimer queues: */
360extern void hrtimer_run_queues(void); 452extern void hrtimer_run_queues(void);
361extern void hrtimer_run_pending(void); 453extern 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
117extern int do_select(int n, fd_set_bits *fds, s64 *timeout); 117extern int do_select(int n, fd_set_bits *fds, struct timespec *end_time);
118extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds, 118extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds,
119 s64 *timeout); 119 struct timespec *end_time);
120extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, 120extern 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
123extern 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 c226c7b82946..de53c109fd04 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1304,6 +1304,12 @@ struct task_struct {
1304 int latency_record_count; 1304 int latency_record_count;
1305 struct latency_record latency_record[LT_SAVECOUNT]; 1305 struct latency_record latency_record[LT_SAVECOUNT];
1306#endif 1306#endif
1307 /*
1308 * time slack values; these are used to round up poll() and
1309 * select() etc timeout values. These are in nanoseconds.
1310 */
1311 unsigned long timer_slack_ns;
1312 unsigned long default_timer_slack_ns;
1307}; 1313};
1308 1314
1309/* 1315/*
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 51e883df0fa5..c911ef69ea87 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
43static inline int timespec_equal(const struct timespec *a, 45static 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
76extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); 78extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec);
79extern 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