]> Pileus Git - ~andy/linux/blob - drivers/staging/zcache/debug.h
Merge tag 'f2fs-for-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
[~andy/linux] / drivers / staging / zcache / debug.h
1 #include <linux/bug.h>
2
3 #ifdef CONFIG_ZCACHE_DEBUG
4
5 /* we try to keep these statistics SMP-consistent */
6 extern ssize_t zcache_obj_count;
7 static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
8 extern ssize_t zcache_obj_count_max;
9 static inline void inc_zcache_obj_count(void)
10 {
11         zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
12         if (zcache_obj_count > zcache_obj_count_max)
13                 zcache_obj_count_max = zcache_obj_count;
14 }
15 static inline void dec_zcache_obj_count(void)
16 {
17         zcache_obj_count = atomic_dec_return(&zcache_obj_atomic);
18         BUG_ON(zcache_obj_count < 0);
19 };
20 extern ssize_t zcache_objnode_count;
21 static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
22 extern ssize_t zcache_objnode_count_max;
23 static inline void inc_zcache_objnode_count(void)
24 {
25         zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
26         if (zcache_objnode_count > zcache_objnode_count_max)
27                 zcache_objnode_count_max = zcache_objnode_count;
28 };
29 static inline void dec_zcache_objnode_count(void)
30 {
31         zcache_objnode_count = atomic_dec_return(&zcache_objnode_atomic);
32         BUG_ON(zcache_objnode_count < 0);
33 };
34 extern u64 zcache_eph_zbytes;
35 static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
36 extern u64 zcache_eph_zbytes_max;
37 static inline void inc_zcache_eph_zbytes(unsigned clen)
38 {
39         zcache_eph_zbytes = atomic_long_add_return(clen, &zcache_eph_zbytes_atomic);
40         if (zcache_eph_zbytes > zcache_eph_zbytes_max)
41                 zcache_eph_zbytes_max = zcache_eph_zbytes;
42 };
43 static inline void dec_zcache_eph_zbytes(unsigned zsize)
44 {
45         zcache_eph_zbytes = atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
46 };
47 extern  u64 zcache_pers_zbytes;
48 static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
49 extern u64 zcache_pers_zbytes_max;
50 static inline void inc_zcache_pers_zbytes(unsigned clen)
51 {
52         zcache_pers_zbytes = atomic_long_add_return(clen, &zcache_pers_zbytes_atomic);
53         if (zcache_pers_zbytes > zcache_pers_zbytes_max)
54                 zcache_pers_zbytes_max = zcache_pers_zbytes;
55 }
56 static inline void dec_zcache_pers_zbytes(unsigned zsize)
57 {
58         zcache_pers_zbytes = atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
59 }
60 extern ssize_t zcache_eph_pageframes;
61 static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
62 extern ssize_t zcache_eph_pageframes_max;
63 static inline void inc_zcache_eph_pageframes(void)
64 {
65         zcache_eph_pageframes = atomic_inc_return(&zcache_eph_pageframes_atomic);
66         if (zcache_eph_pageframes > zcache_eph_pageframes_max)
67                 zcache_eph_pageframes_max = zcache_eph_pageframes;
68 };
69 static inline void dec_zcache_eph_pageframes(void)
70 {
71         zcache_eph_pageframes = atomic_dec_return(&zcache_eph_pageframes_atomic);
72 };
73 extern ssize_t zcache_pers_pageframes;
74 static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
75 extern ssize_t zcache_pers_pageframes_max;
76 static inline void inc_zcache_pers_pageframes(void)
77 {
78         zcache_pers_pageframes = atomic_inc_return(&zcache_pers_pageframes_atomic);
79         if (zcache_pers_pageframes > zcache_pers_pageframes_max)
80                 zcache_pers_pageframes_max = zcache_pers_pageframes;
81 }
82 static inline void dec_zcache_pers_pageframes(void)
83 {
84         zcache_pers_pageframes = atomic_dec_return(&zcache_pers_pageframes_atomic);
85 }
86 extern ssize_t zcache_pageframes_alloced;
87 static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
88 static inline void inc_zcache_pageframes_alloced(void)
89 {
90         zcache_pageframes_alloced = atomic_inc_return(&zcache_pageframes_alloced_atomic);
91 };
92 extern ssize_t zcache_pageframes_freed;
93 static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
94 static inline void inc_zcache_pageframes_freed(void)
95 {
96         zcache_pageframes_freed = atomic_inc_return(&zcache_pageframes_freed_atomic);
97 }
98 extern ssize_t zcache_eph_zpages;
99 static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
100 extern ssize_t zcache_eph_zpages_max;
101 static inline void inc_zcache_eph_zpages(void)
102 {
103         zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
104         if (zcache_eph_zpages > zcache_eph_zpages_max)
105                 zcache_eph_zpages_max = zcache_eph_zpages;
106 }
107 static inline void dec_zcache_eph_zpages(unsigned zpages)
108 {
109         zcache_eph_zpages = atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
110 }
111 extern ssize_t zcache_pers_zpages;
112 static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
113 extern ssize_t zcache_pers_zpages_max;
114 static inline void inc_zcache_pers_zpages(void)
115 {
116         zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
117         if (zcache_pers_zpages > zcache_pers_zpages_max)
118                 zcache_pers_zpages_max = zcache_pers_zpages;
119 }
120 static inline void dec_zcache_pers_zpages(unsigned zpages)
121 {
122         zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
123 }
124
125 extern ssize_t zcache_zero_filled_pages;
126 static atomic_t zcache_zero_filled_pages_atomic = ATOMIC_INIT(0);
127 extern ssize_t zcache_zero_filled_pages_max;
128 static inline void inc_zcache_zero_filled_pages(void)
129 {
130         zcache_zero_filled_pages = atomic_inc_return(
131                                         &zcache_zero_filled_pages_atomic);
132         if (zcache_zero_filled_pages > zcache_zero_filled_pages_max)
133                 zcache_zero_filled_pages_max = zcache_zero_filled_pages;
134 }
135 static inline void dec_zcache_zero_filled_pages(void)
136 {
137         zcache_zero_filled_pages = atomic_dec_return(
138                                         &zcache_zero_filled_pages_atomic);
139 }
140 static inline unsigned long curr_pageframes_count(void)
141 {
142         return zcache_pageframes_alloced -
143                 atomic_read(&zcache_pageframes_freed_atomic) -
144                 atomic_read(&zcache_eph_pageframes_atomic) -
145                 atomic_read(&zcache_pers_pageframes_atomic);
146 };
147 /* but for the rest of these, counting races are ok */
148 extern ssize_t zcache_flush_total;
149 extern ssize_t zcache_flush_found;
150 extern ssize_t zcache_flobj_total;
151 extern ssize_t zcache_flobj_found;
152 extern ssize_t zcache_failed_eph_puts;
153 extern ssize_t zcache_failed_pers_puts;
154 extern ssize_t zcache_failed_getfreepages;
155 extern ssize_t zcache_failed_alloc;
156 extern ssize_t zcache_put_to_flush;
157 extern ssize_t zcache_compress_poor;
158 extern ssize_t zcache_mean_compress_poor;
159 extern ssize_t zcache_eph_ate_tail;
160 extern ssize_t zcache_eph_ate_tail_failed;
161 extern ssize_t zcache_pers_ate_eph;
162 extern ssize_t zcache_pers_ate_eph_failed;
163 extern ssize_t zcache_evicted_eph_zpages;
164 extern ssize_t zcache_evicted_eph_pageframes;
165
166 extern ssize_t zcache_last_active_file_pageframes;
167 extern ssize_t zcache_last_inactive_file_pageframes;
168 extern ssize_t zcache_last_active_anon_pageframes;
169 extern ssize_t zcache_last_inactive_anon_pageframes;
170 static ssize_t zcache_eph_nonactive_puts_ignored;
171 static ssize_t zcache_pers_nonactive_puts_ignored;
172 #ifdef CONFIG_ZCACHE_WRITEBACK
173 extern ssize_t zcache_writtenback_pages;
174 extern ssize_t zcache_outstanding_writeback_pages;
175 #endif
176
177 static inline void inc_zcache_flush_total(void)
178 {
179         zcache_flush_total++;
180 };
181 static inline void inc_zcache_flush_found(void)
182 {
183         zcache_flush_found++;
184 };
185 static inline void inc_zcache_flobj_total(void)
186 {
187         zcache_flobj_total++;
188 };
189 static inline void inc_zcache_flobj_found(void)
190 {
191         zcache_flobj_found++;
192 };
193 static inline void inc_zcache_failed_eph_puts(void)
194 {
195         zcache_failed_eph_puts++;
196 };
197 static inline void inc_zcache_failed_pers_puts(void)
198 {
199         zcache_failed_pers_puts++;
200 };
201 static inline void inc_zcache_failed_getfreepages(void)
202 {
203         zcache_failed_getfreepages++;
204 };
205 static inline void inc_zcache_failed_alloc(void)
206 {
207         zcache_failed_alloc++;
208 };
209 static inline void inc_zcache_put_to_flush(void)
210 {
211         zcache_put_to_flush++;
212 };
213 static inline void inc_zcache_compress_poor(void)
214 {
215         zcache_compress_poor++;
216 };
217 static inline void inc_zcache_mean_compress_poor(void)
218 {
219         zcache_mean_compress_poor++;
220 };
221 static inline void inc_zcache_eph_ate_tail(void)
222 {
223         zcache_eph_ate_tail++;
224 };
225 static inline void inc_zcache_eph_ate_tail_failed(void)
226 {
227         zcache_eph_ate_tail_failed++;
228 };
229 static inline void inc_zcache_pers_ate_eph(void)
230 {
231         zcache_pers_ate_eph++;
232 };
233 static inline void inc_zcache_pers_ate_eph_failed(void)
234 {
235         zcache_pers_ate_eph_failed++;
236 };
237 static inline void inc_zcache_evicted_eph_zpages(unsigned zpages)
238 {
239         zcache_evicted_eph_zpages += zpages;
240 };
241 static inline void inc_zcache_evicted_eph_pageframes(void)
242 {
243         zcache_evicted_eph_pageframes++;
244 };
245
246 static inline void inc_zcache_eph_nonactive_puts_ignored(void)
247 {
248         zcache_eph_nonactive_puts_ignored++;
249 };
250 static inline void inc_zcache_pers_nonactive_puts_ignored(void)
251 {
252         zcache_pers_nonactive_puts_ignored++;
253 };
254
255 int zcache_debugfs_init(void);
256 #else
257 static inline void inc_zcache_obj_count(void) { };
258 static inline void dec_zcache_obj_count(void) { };
259 static inline void inc_zcache_objnode_count(void) { };
260 static inline void dec_zcache_objnode_count(void) { };
261 static inline void inc_zcache_eph_zbytes(unsigned clen) { };
262 static inline void dec_zcache_eph_zbytes(unsigned zsize) { };
263 static inline void inc_zcache_pers_zbytes(unsigned clen) { };
264 static inline void dec_zcache_pers_zbytes(unsigned zsize) { };
265 static inline void inc_zcache_eph_pageframes(void) { };
266 static inline void dec_zcache_eph_pageframes(void) { };
267 static inline void inc_zcache_pers_pageframes(void) { };
268 static inline void dec_zcache_pers_pageframes(void) { };
269 static inline void inc_zcache_pageframes_alloced(void) { };
270 static inline void inc_zcache_pageframes_freed(void) { };
271 static inline void inc_zcache_eph_zpages(void) { };
272 static inline void dec_zcache_eph_zpages(unsigned zpages) { };
273 static inline void inc_zcache_pers_zpages(void) { };
274 static inline void dec_zcache_pers_zpages(unsigned zpages) { };
275 static inline void inc_zcache_zero_filled_pages(void) { };
276 static inline void dec_zcache_zero_filled_pages(void) { };
277 static inline unsigned long curr_pageframes_count(void)
278 {
279         return 0;
280 };
281 static inline int zcache_debugfs_init(void)
282 {
283         return 0;
284 };
285 static inline void inc_zcache_flush_total(void) { };
286 static inline void inc_zcache_flush_found(void) { };
287 static inline void inc_zcache_flobj_total(void) { };
288 static inline void inc_zcache_flobj_found(void) { };
289 static inline void inc_zcache_failed_eph_puts(void) { };
290 static inline void inc_zcache_failed_pers_puts(void) { };
291 static inline void inc_zcache_failed_getfreepages(void) { };
292 static inline void inc_zcache_failed_alloc(void) { };
293 static inline void inc_zcache_put_to_flush(void) { };
294 static inline void inc_zcache_compress_poor(void) { };
295 static inline void inc_zcache_mean_compress_poor(void) { };
296 static inline void inc_zcache_eph_ate_tail(void) { };
297 static inline void inc_zcache_eph_ate_tail_failed(void) { };
298 static inline void inc_zcache_pers_ate_eph(void) { };
299 static inline void inc_zcache_pers_ate_eph_failed(void) { };
300 static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { };
301 static inline void inc_zcache_evicted_eph_pageframes(void) { };
302
303 static inline void inc_zcache_eph_nonactive_puts_ignored(void) { };
304 static inline void inc_zcache_pers_nonactive_puts_ignored(void) { };
305 #endif