Commit | Line | Data |
---|---|---|
7791c623 KRW |
1 | #include <linux/bug.h> |
2 | ||
95bdaee2 KRW |
3 | #ifdef CONFIG_ZCACHE_DEBUG |
4 | ||
5 | /* we try to keep these statistics SMP-consistent */ | |
90874fc2 | 6 | extern ssize_t zcache_obj_count; |
95bdaee2 | 7 | static atomic_t zcache_obj_atomic = ATOMIC_INIT(0); |
90874fc2 | 8 | extern ssize_t zcache_obj_count_max; |
95bdaee2 KRW |
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 | }; | |
90874fc2 | 20 | extern ssize_t zcache_objnode_count; |
95bdaee2 | 21 | static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0); |
90874fc2 | 22 | extern ssize_t zcache_objnode_count_max; |
95bdaee2 KRW |
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 | }; | |
90874fc2 | 34 | extern u64 zcache_eph_zbytes; |
95bdaee2 | 35 | static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0); |
90874fc2 | 36 | extern u64 zcache_eph_zbytes_max; |
95bdaee2 KRW |
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); | |
90874fc2 | 49 | extern u64 zcache_pers_zbytes_max; |
95bdaee2 KRW |
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); | |
90874fc2 | 62 | extern ssize_t zcache_eph_pageframes_max; |
95bdaee2 KRW |
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); | |
90874fc2 | 75 | extern ssize_t zcache_pers_pageframes_max; |
95bdaee2 KRW |
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 | } | |
90874fc2 | 86 | extern ssize_t zcache_pageframes_alloced; |
95bdaee2 KRW |
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 | }; | |
90874fc2 | 92 | extern ssize_t zcache_pageframes_freed; |
95bdaee2 KRW |
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 | } | |
90874fc2 | 98 | extern ssize_t zcache_eph_zpages; |
95bdaee2 | 99 | static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0); |
90874fc2 | 100 | extern ssize_t zcache_eph_zpages_max; |
95bdaee2 KRW |
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); | |
90874fc2 | 113 | extern ssize_t zcache_pers_zpages_max; |
95bdaee2 KRW |
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 | ||
834e3a1c WL |
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 | } | |
95bdaee2 KRW |
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 */ | |
90874fc2 WL |
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; | |
86d7de66 | 165 | |
95bdaee2 KRW |
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; | |
86d7de66 KRW |
170 | static ssize_t zcache_eph_nonactive_puts_ignored; |
171 | static ssize_t zcache_pers_nonactive_puts_ignored; | |
95bdaee2 KRW |
172 | #ifdef CONFIG_ZCACHE_WRITEBACK |
173 | extern ssize_t zcache_writtenback_pages; | |
174 | extern ssize_t zcache_outstanding_writeback_pages; | |
175 | #endif | |
176 | ||
86d7de66 KRW |
177 | static inline void inc_zcache_flush_total(void) { zcache_flush_total ++; }; |
178 | static inline void inc_zcache_flush_found(void) { zcache_flush_found ++; }; | |
179 | static inline void inc_zcache_flobj_total(void) { zcache_flobj_total ++; }; | |
180 | static inline void inc_zcache_flobj_found(void) { zcache_flobj_found ++; }; | |
181 | static inline void inc_zcache_failed_eph_puts(void) { zcache_failed_eph_puts ++; }; | |
182 | static inline void inc_zcache_failed_pers_puts(void) { zcache_failed_pers_puts ++; }; | |
183 | static inline void inc_zcache_failed_getfreepages(void) { zcache_failed_getfreepages ++; }; | |
184 | static inline void inc_zcache_failed_alloc(void) { zcache_failed_alloc ++; }; | |
185 | static inline void inc_zcache_put_to_flush(void) { zcache_put_to_flush ++; }; | |
186 | static inline void inc_zcache_compress_poor(void) { zcache_compress_poor ++; }; | |
187 | static inline void inc_zcache_mean_compress_poor(void) { zcache_mean_compress_poor ++; }; | |
188 | static inline void inc_zcache_eph_ate_tail(void) { zcache_eph_ate_tail ++; }; | |
189 | static inline void inc_zcache_eph_ate_tail_failed(void) { zcache_eph_ate_tail_failed ++; }; | |
190 | static inline void inc_zcache_pers_ate_eph(void) { zcache_pers_ate_eph ++; }; | |
191 | static inline void inc_zcache_pers_ate_eph_failed(void) { zcache_pers_ate_eph_failed ++; }; | |
192 | static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { zcache_evicted_eph_zpages += zpages; }; | |
193 | static inline void inc_zcache_evicted_eph_pageframes(void) { zcache_evicted_eph_pageframes ++; }; | |
194 | ||
195 | static inline void inc_zcache_eph_nonactive_puts_ignored(void) { zcache_eph_nonactive_puts_ignored ++; }; | |
196 | static inline void inc_zcache_pers_nonactive_puts_ignored(void) { zcache_pers_nonactive_puts_ignored ++; }; | |
197 | ||
95bdaee2 KRW |
198 | int zcache_debugfs_init(void); |
199 | #else | |
200 | static inline void inc_zcache_obj_count(void) { }; | |
201 | static inline void dec_zcache_obj_count(void) { }; | |
202 | static inline void inc_zcache_objnode_count(void) { }; | |
203 | static inline void dec_zcache_objnode_count(void) { }; | |
204 | static inline void inc_zcache_eph_zbytes(unsigned clen) { }; | |
205 | static inline void dec_zcache_eph_zbytes(unsigned zsize) { }; | |
206 | static inline void inc_zcache_pers_zbytes(unsigned clen) { }; | |
207 | static inline void dec_zcache_pers_zbytes(unsigned zsize) { }; | |
208 | static inline void inc_zcache_eph_pageframes(void) { }; | |
209 | static inline void dec_zcache_eph_pageframes(void) { }; | |
210 | static inline void inc_zcache_pers_pageframes(void) { }; | |
211 | static inline void dec_zcache_pers_pageframes(void) { }; | |
212 | static inline void inc_zcache_pageframes_alloced(void) { }; | |
213 | static inline void inc_zcache_pageframes_freed(void) { }; | |
214 | static inline void inc_zcache_eph_zpages(void) { }; | |
215 | static inline void dec_zcache_eph_zpages(unsigned zpages) { }; | |
216 | static inline void inc_zcache_pers_zpages(void) { }; | |
217 | static inline void dec_zcache_pers_zpages(unsigned zpages) { }; | |
834e3a1c WL |
218 | static inline void inc_zcache_zero_filled_pages(void) { }; |
219 | static inline void dec_zcache_zero_filled_pages(void) { }; | |
95bdaee2 KRW |
220 | static inline unsigned long curr_pageframes_count(void) |
221 | { | |
222 | return 0; | |
223 | }; | |
224 | static inline int zcache_debugfs_init(void) | |
225 | { | |
226 | return 0; | |
227 | }; | |
86d7de66 KRW |
228 | static inline void inc_zcache_flush_total(void) { }; |
229 | static inline void inc_zcache_flush_found(void) { }; | |
230 | static inline void inc_zcache_flobj_total(void) { }; | |
231 | static inline void inc_zcache_flobj_found(void) { }; | |
232 | static inline void inc_zcache_failed_eph_puts(void) { }; | |
233 | static inline void inc_zcache_failed_pers_puts(void) { }; | |
234 | static inline void inc_zcache_failed_getfreepages(void) { }; | |
235 | static inline void inc_zcache_failed_alloc(void) { }; | |
236 | static inline void inc_zcache_put_to_flush(void) { }; | |
237 | static inline void inc_zcache_compress_poor(void) { }; | |
238 | static inline void inc_zcache_mean_compress_poor(void) { }; | |
239 | static inline void inc_zcache_eph_ate_tail(void) { }; | |
240 | static inline void inc_zcache_eph_ate_tail_failed(void) { }; | |
241 | static inline void inc_zcache_pers_ate_eph(void) { }; | |
242 | static inline void inc_zcache_pers_ate_eph_failed(void) { }; | |
243 | static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { }; | |
244 | static inline void inc_zcache_evicted_eph_pageframes(void) { }; | |
245 | ||
246 | static inline void inc_zcache_eph_nonactive_puts_ignored(void) { }; | |
247 | static inline void inc_zcache_pers_nonactive_puts_ignored(void) { }; | |
95bdaee2 | 248 | #endif |