net: fix sk_mem_reclaim_partial()
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / posix-timers.h
CommitLineData
1da177e4
LT
1#ifndef _linux_POSIX_TIMERS_H
2#define _linux_POSIX_TIMERS_H
3
4#include <linux/spinlock.h>
5#include <linux/list.h>
6#include <linux/sched.h>
f1f1d5eb 7#include <linux/timex.h>
9a7adcf5 8#include <linux/alarmtimer.h>
1da177e4
LT
9
10union cpu_time_count {
11 cputime_t cpu;
12 unsigned long long sched;
13};
14
15struct cpu_timer_list {
16 struct list_head entry;
17 union cpu_time_count expires, incr;
18 struct task_struct *task;
19 int firing;
20};
21
81e294cb
RC
22/*
23 * Bit fields within a clockid:
24 *
25 * The most significant 29 bits hold either a pid or a file descriptor.
26 *
27 * Bit 2 indicates whether a cpu clock refers to a thread or a process.
28 *
29 * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.
30 *
31 * A clockid is invalid if bits 2, 1, and 0 are all set.
32 */
1da177e4
LT
33#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))
34#define CPUCLOCK_PERTHREAD(clock) \
35 (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)
0606f422 36
1da177e4
LT
37#define CPUCLOCK_PERTHREAD_MASK 4
38#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)
39#define CPUCLOCK_CLOCK_MASK 3
40#define CPUCLOCK_PROF 0
41#define CPUCLOCK_VIRT 1
42#define CPUCLOCK_SCHED 2
43#define CPUCLOCK_MAX 3
81e294cb
RC
44#define CLOCKFD CPUCLOCK_MAX
45#define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK)
1da177e4
LT
46
47#define MAKE_PROCESS_CPUCLOCK(pid, clock) \
48 ((~(clockid_t) (pid) << 3) | (clockid_t) (clock))
49#define MAKE_THREAD_CPUCLOCK(tid, clock) \
50 MAKE_PROCESS_CPUCLOCK((tid), (clock) | CPUCLOCK_PERTHREAD_MASK)
51
0606f422
RC
52#define FD_TO_CLOCKID(fd) ((~(clockid_t) (fd) << 3) | CLOCKFD)
53#define CLOCKID_TO_FD(clk) ((unsigned int) ~((clk) >> 3))
54
1da177e4
LT
55/* POSIX.1b interval timer structure. */
56struct k_itimer {
57 struct list_head list; /* free/ allocate list */
5ed67f05 58 struct hlist_node t_hash;
1da177e4
LT
59 spinlock_t it_lock;
60 clockid_t it_clock; /* which timer type */
61 timer_t it_id; /* timer id */
62 int it_overrun; /* overrun on pending signal */
63 int it_overrun_last; /* overrun on last delivered signal */
2a698971 64 int it_requeue_pending; /* waiting to requeue this timer */
1da177e4
LT
65#define REQUEUE_PENDING 1
66 int it_sigev_notify; /* notify word of sigevent struct */
27af4245
ON
67 struct signal_struct *it_signal;
68 union {
69 struct pid *it_pid; /* pid of process to send signal to */
70 struct task_struct *it_process; /* for clock_nanosleep */
71 };
1da177e4
LT
72 struct sigqueue *sigq; /* signal queue entry. */
73 union {
74 struct {
becf8b5d
TG
75 struct hrtimer timer;
76 ktime_t interval;
1da177e4
LT
77 } real;
78 struct cpu_timer_list cpu;
79 struct {
80 unsigned int clock;
81 unsigned int node;
82 unsigned long incr;
83 unsigned long expires;
84 } mmtimer;
9e264762
JS
85 struct {
86 struct alarm alarmtimer;
87 ktime_t interval;
88 } alarm;
8af08871 89 struct rcu_head rcu;
1da177e4
LT
90 } it;
91};
92
1da177e4 93struct k_clock {
a924b04d 94 int (*clock_getres) (const clockid_t which_clock, struct timespec *tp);
1e6d7679
RC
95 int (*clock_set) (const clockid_t which_clock,
96 const struct timespec *tp);
a924b04d 97 int (*clock_get) (const clockid_t which_clock, struct timespec * tp);
f1f1d5eb 98 int (*clock_adj) (const clockid_t which_clock, struct timex *tx);
1da177e4 99 int (*timer_create) (struct k_itimer *timer);
2a698971 100 int (*nsleep) (const clockid_t which_clock, int flags,
97735f25 101 struct timespec *, struct timespec __user *);
1711ef38 102 long (*nsleep_restart) (struct restart_block *restart_block);
1da177e4
LT
103 int (*timer_set) (struct k_itimer * timr, int flags,
104 struct itimerspec * new_setting,
105 struct itimerspec * old_setting);
106 int (*timer_del) (struct k_itimer * timr);
107#define TIMER_RETRY 1
108 void (*timer_get) (struct k_itimer * timr,
109 struct itimerspec * cur_setting);
110};
111
1976945e 112extern struct k_clock clock_posix_cpu;
0606f422 113extern struct k_clock clock_posix_dynamic;
1976945e 114
52708737 115void posix_timers_register_clock(const clockid_t clock_id, struct k_clock *new_clock);
1da177e4 116
1da177e4
LT
117/* function to call to trigger timer event */
118int posix_timer_event(struct k_itimer *timr, int si_private);
119
2a698971
TG
120void posix_cpu_timer_schedule(struct k_itimer *timer);
121
122void run_posix_cpu_timers(struct task_struct *task);
123void posix_cpu_timers_exit(struct task_struct *task);
124void posix_cpu_timers_exit_group(struct task_struct *task);
125
555347f6
FW
126bool posix_cpu_timers_can_stop_tick(struct task_struct *tsk);
127
2a698971
TG
128void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
129 cputime_t *newval, cputime_t *oldval);
1da177e4 130
1711ef38
TA
131long clock_nanosleep_restart(struct restart_block *restart_block);
132
5ab46b34 133void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
f06febc9 134
1da177e4 135#endif