3 #ifdef CONFIG_ZCACHE_DEBUG
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)
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
;
15 static inline void dec_zcache_obj_count(void)
17 zcache_obj_count
= atomic_dec_return(&zcache_obj_atomic
);
18 BUG_ON(zcache_obj_count
< 0);
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)
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
;
29 static inline void dec_zcache_objnode_count(void)
31 zcache_objnode_count
= atomic_dec_return(&zcache_objnode_atomic
);
32 BUG_ON(zcache_objnode_count
< 0);
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
)
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
;
43 static inline void dec_zcache_eph_zbytes(unsigned zsize
)
45 zcache_eph_zbytes
= atomic_long_sub_return(zsize
, &zcache_eph_zbytes_atomic
);
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
)
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
;
56 static inline void dec_zcache_pers_zbytes(unsigned zsize
)
58 zcache_pers_zbytes
= atomic_long_sub_return(zsize
, &zcache_pers_zbytes_atomic
);
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)
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
;
69 static inline void dec_zcache_eph_pageframes(void)
71 zcache_eph_pageframes
= atomic_dec_return(&zcache_eph_pageframes_atomic
);
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)
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
;
82 static inline void dec_zcache_pers_pageframes(void)
84 zcache_pers_pageframes
= atomic_dec_return(&zcache_pers_pageframes_atomic
);
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)
90 zcache_pageframes_alloced
= atomic_inc_return(&zcache_pageframes_alloced_atomic
);
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)
96 zcache_pageframes_freed
= atomic_inc_return(&zcache_pageframes_freed_atomic
);
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)
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
;
107 static inline void dec_zcache_eph_zpages(unsigned zpages
)
109 zcache_eph_zpages
= atomic_sub_return(zpages
, &zcache_eph_zpages_atomic
);
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)
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
;
120 static inline void dec_zcache_pers_zpages(unsigned zpages
)
122 zcache_pers_zpages
= atomic_sub_return(zpages
, &zcache_pers_zpages_atomic
);
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)
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
;
135 static inline void dec_zcache_zero_filled_pages(void)
137 zcache_zero_filled_pages
= atomic_dec_return(
138 &zcache_zero_filled_pages_atomic
);
140 static inline unsigned long curr_pageframes_count(void)
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
);
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
;
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
;
177 static inline void inc_zcache_flush_total(void)
179 zcache_flush_total
++;
181 static inline void inc_zcache_flush_found(void)
183 zcache_flush_found
++;
185 static inline void inc_zcache_flobj_total(void)
187 zcache_flobj_total
++;
189 static inline void inc_zcache_flobj_found(void)
191 zcache_flobj_found
++;
193 static inline void inc_zcache_failed_eph_puts(void)
195 zcache_failed_eph_puts
++;
197 static inline void inc_zcache_failed_pers_puts(void)
199 zcache_failed_pers_puts
++;
201 static inline void inc_zcache_failed_getfreepages(void)
203 zcache_failed_getfreepages
++;
205 static inline void inc_zcache_failed_alloc(void)
207 zcache_failed_alloc
++;
209 static inline void inc_zcache_put_to_flush(void)
211 zcache_put_to_flush
++;
213 static inline void inc_zcache_compress_poor(void)
215 zcache_compress_poor
++;
217 static inline void inc_zcache_mean_compress_poor(void)
219 zcache_mean_compress_poor
++;
221 static inline void inc_zcache_eph_ate_tail(void)
223 zcache_eph_ate_tail
++;
225 static inline void inc_zcache_eph_ate_tail_failed(void)
227 zcache_eph_ate_tail_failed
++;
229 static inline void inc_zcache_pers_ate_eph(void)
231 zcache_pers_ate_eph
++;
233 static inline void inc_zcache_pers_ate_eph_failed(void)
235 zcache_pers_ate_eph_failed
++;
237 static inline void inc_zcache_evicted_eph_zpages(unsigned zpages
)
239 zcache_evicted_eph_zpages
+= zpages
;
241 static inline void inc_zcache_evicted_eph_pageframes(void)
243 zcache_evicted_eph_pageframes
++;
246 static inline void inc_zcache_eph_nonactive_puts_ignored(void)
248 zcache_eph_nonactive_puts_ignored
++;
250 static inline void inc_zcache_pers_nonactive_puts_ignored(void)
252 zcache_pers_nonactive_puts_ignored
++;
255 int zcache_debugfs_init(void);
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)
281 static inline int zcache_debugfs_init(void)
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) { };
303 static inline void inc_zcache_eph_nonactive_puts_ignored(void) { };
304 static inline void inc_zcache_pers_nonactive_puts_ignored(void) { };