This source file includes following definitions.
- delayacct_is_task_waiting_on_io
- delayacct_set_flag
- delayacct_clear_flag
- delayacct_tsk_init
- delayacct_tsk_free
- delayacct_blkio_start
- delayacct_blkio_end
- delayacct_add_tsk
- delayacct_blkio_ticks
- delayacct_freepages_start
- delayacct_freepages_end
- delayacct_thrashing_start
- delayacct_thrashing_end
- delayacct_set_flag
- delayacct_clear_flag
- delayacct_init
- delayacct_tsk_init
- delayacct_tsk_free
- delayacct_blkio_start
- delayacct_blkio_end
- delayacct_add_tsk
- delayacct_blkio_ticks
- delayacct_is_task_waiting_on_io
- delayacct_freepages_start
- delayacct_freepages_end
- delayacct_thrashing_start
- delayacct_thrashing_end
1
2
3
4
5
6
7 #ifndef _LINUX_DELAYACCT_H
8 #define _LINUX_DELAYACCT_H
9
10 #include <uapi/linux/taskstats.h>
11
12
13
14
15
16
17 #define DELAYACCT_PF_SWAPIN 0x00000001
18 #define DELAYACCT_PF_BLKIO 0x00000002
19
20 #ifdef CONFIG_TASK_DELAY_ACCT
21 struct task_delay_info {
22 raw_spinlock_t lock;
23 unsigned int flags;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 u64 blkio_start;
41 u64 blkio_delay;
42 u64 swapin_delay;
43 u32 blkio_count;
44
45 u32 swapin_count;
46
47
48 u64 freepages_start;
49 u64 freepages_delay;
50
51 u64 thrashing_start;
52 u64 thrashing_delay;
53
54 u32 freepages_count;
55 u32 thrashing_count;
56 };
57 #endif
58
59 #include <linux/sched.h>
60 #include <linux/slab.h>
61
62 #ifdef CONFIG_TASK_DELAY_ACCT
63 extern int delayacct_on;
64 extern struct kmem_cache *delayacct_cache;
65 extern void delayacct_init(void);
66 extern void __delayacct_tsk_init(struct task_struct *);
67 extern void __delayacct_tsk_exit(struct task_struct *);
68 extern void __delayacct_blkio_start(void);
69 extern void __delayacct_blkio_end(struct task_struct *);
70 extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
71 extern __u64 __delayacct_blkio_ticks(struct task_struct *);
72 extern void __delayacct_freepages_start(void);
73 extern void __delayacct_freepages_end(void);
74 extern void __delayacct_thrashing_start(void);
75 extern void __delayacct_thrashing_end(void);
76
77 static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
78 {
79 if (p->delays)
80 return (p->delays->flags & DELAYACCT_PF_BLKIO);
81 else
82 return 0;
83 }
84
85 static inline void delayacct_set_flag(int flag)
86 {
87 if (current->delays)
88 current->delays->flags |= flag;
89 }
90
91 static inline void delayacct_clear_flag(int flag)
92 {
93 if (current->delays)
94 current->delays->flags &= ~flag;
95 }
96
97 static inline void delayacct_tsk_init(struct task_struct *tsk)
98 {
99
100 tsk->delays = NULL;
101 if (delayacct_on)
102 __delayacct_tsk_init(tsk);
103 }
104
105
106
107
108 static inline void delayacct_tsk_free(struct task_struct *tsk)
109 {
110 if (tsk->delays)
111 kmem_cache_free(delayacct_cache, tsk->delays);
112 tsk->delays = NULL;
113 }
114
115 static inline void delayacct_blkio_start(void)
116 {
117 delayacct_set_flag(DELAYACCT_PF_BLKIO);
118 if (current->delays)
119 __delayacct_blkio_start();
120 }
121
122 static inline void delayacct_blkio_end(struct task_struct *p)
123 {
124 if (p->delays)
125 __delayacct_blkio_end(p);
126 delayacct_clear_flag(DELAYACCT_PF_BLKIO);
127 }
128
129 static inline int delayacct_add_tsk(struct taskstats *d,
130 struct task_struct *tsk)
131 {
132 if (!delayacct_on || !tsk->delays)
133 return 0;
134 return __delayacct_add_tsk(d, tsk);
135 }
136
137 static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
138 {
139 if (tsk->delays)
140 return __delayacct_blkio_ticks(tsk);
141 return 0;
142 }
143
144 static inline void delayacct_freepages_start(void)
145 {
146 if (current->delays)
147 __delayacct_freepages_start();
148 }
149
150 static inline void delayacct_freepages_end(void)
151 {
152 if (current->delays)
153 __delayacct_freepages_end();
154 }
155
156 static inline void delayacct_thrashing_start(void)
157 {
158 if (current->delays)
159 __delayacct_thrashing_start();
160 }
161
162 static inline void delayacct_thrashing_end(void)
163 {
164 if (current->delays)
165 __delayacct_thrashing_end();
166 }
167
168 #else
169 static inline void delayacct_set_flag(int flag)
170 {}
171 static inline void delayacct_clear_flag(int flag)
172 {}
173 static inline void delayacct_init(void)
174 {}
175 static inline void delayacct_tsk_init(struct task_struct *tsk)
176 {}
177 static inline void delayacct_tsk_free(struct task_struct *tsk)
178 {}
179 static inline void delayacct_blkio_start(void)
180 {}
181 static inline void delayacct_blkio_end(struct task_struct *p)
182 {}
183 static inline int delayacct_add_tsk(struct taskstats *d,
184 struct task_struct *tsk)
185 { return 0; }
186 static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
187 { return 0; }
188 static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
189 { return 0; }
190 static inline void delayacct_freepages_start(void)
191 {}
192 static inline void delayacct_freepages_end(void)
193 {}
194 static inline void delayacct_thrashing_start(void)
195 {}
196 static inline void delayacct_thrashing_end(void)
197 {}
198
199 #endif
200
201 #endif