8ec82d42cf2054ad2bf692f28f9a966d900d71a8
[deliverable/linux.git] / 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 static inline unsigned long curr_pageframes_count(void)
126 {
127 return zcache_pageframes_alloced -
128 atomic_read(&zcache_pageframes_freed_atomic) -
129 atomic_read(&zcache_eph_pageframes_atomic) -
130 atomic_read(&zcache_pers_pageframes_atomic);
131 };
132 /* but for the rest of these, counting races are ok */
133 extern ssize_t zcache_flush_total;
134 extern ssize_t zcache_flush_found;
135 extern ssize_t zcache_flobj_total;
136 extern ssize_t zcache_flobj_found;
137 extern ssize_t zcache_failed_eph_puts;
138 extern ssize_t zcache_failed_pers_puts;
139 extern ssize_t zcache_failed_getfreepages;
140 extern ssize_t zcache_failed_alloc;
141 extern ssize_t zcache_put_to_flush;
142 extern ssize_t zcache_compress_poor;
143 extern ssize_t zcache_mean_compress_poor;
144 extern ssize_t zcache_eph_ate_tail;
145 extern ssize_t zcache_eph_ate_tail_failed;
146 extern ssize_t zcache_pers_ate_eph;
147 extern ssize_t zcache_pers_ate_eph_failed;
148 extern ssize_t zcache_evicted_eph_zpages;
149 extern ssize_t zcache_evicted_eph_pageframes;
150
151 extern ssize_t zcache_last_active_file_pageframes;
152 extern ssize_t zcache_last_inactive_file_pageframes;
153 extern ssize_t zcache_last_active_anon_pageframes;
154 extern ssize_t zcache_last_inactive_anon_pageframes;
155 static ssize_t zcache_eph_nonactive_puts_ignored;
156 static ssize_t zcache_pers_nonactive_puts_ignored;
157 #ifdef CONFIG_ZCACHE_WRITEBACK
158 extern ssize_t zcache_writtenback_pages;
159 extern ssize_t zcache_outstanding_writeback_pages;
160 #endif
161
162 static inline void inc_zcache_flush_total(void) { zcache_flush_total ++; };
163 static inline void inc_zcache_flush_found(void) { zcache_flush_found ++; };
164 static inline void inc_zcache_flobj_total(void) { zcache_flobj_total ++; };
165 static inline void inc_zcache_flobj_found(void) { zcache_flobj_found ++; };
166 static inline void inc_zcache_failed_eph_puts(void) { zcache_failed_eph_puts ++; };
167 static inline void inc_zcache_failed_pers_puts(void) { zcache_failed_pers_puts ++; };
168 static inline void inc_zcache_failed_getfreepages(void) { zcache_failed_getfreepages ++; };
169 static inline void inc_zcache_failed_alloc(void) { zcache_failed_alloc ++; };
170 static inline void inc_zcache_put_to_flush(void) { zcache_put_to_flush ++; };
171 static inline void inc_zcache_compress_poor(void) { zcache_compress_poor ++; };
172 static inline void inc_zcache_mean_compress_poor(void) { zcache_mean_compress_poor ++; };
173 static inline void inc_zcache_eph_ate_tail(void) { zcache_eph_ate_tail ++; };
174 static inline void inc_zcache_eph_ate_tail_failed(void) { zcache_eph_ate_tail_failed ++; };
175 static inline void inc_zcache_pers_ate_eph(void) { zcache_pers_ate_eph ++; };
176 static inline void inc_zcache_pers_ate_eph_failed(void) { zcache_pers_ate_eph_failed ++; };
177 static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { zcache_evicted_eph_zpages += zpages; };
178 static inline void inc_zcache_evicted_eph_pageframes(void) { zcache_evicted_eph_pageframes ++; };
179
180 static inline void inc_zcache_eph_nonactive_puts_ignored(void) { zcache_eph_nonactive_puts_ignored ++; };
181 static inline void inc_zcache_pers_nonactive_puts_ignored(void) { zcache_pers_nonactive_puts_ignored ++; };
182
183 int zcache_debugfs_init(void);
184 #else
185 static inline void inc_zcache_obj_count(void) { };
186 static inline void dec_zcache_obj_count(void) { };
187 static inline void inc_zcache_objnode_count(void) { };
188 static inline void dec_zcache_objnode_count(void) { };
189 static inline void inc_zcache_eph_zbytes(unsigned clen) { };
190 static inline void dec_zcache_eph_zbytes(unsigned zsize) { };
191 static inline void inc_zcache_pers_zbytes(unsigned clen) { };
192 static inline void dec_zcache_pers_zbytes(unsigned zsize) { };
193 static inline void inc_zcache_eph_pageframes(void) { };
194 static inline void dec_zcache_eph_pageframes(void) { };
195 static inline void inc_zcache_pers_pageframes(void) { };
196 static inline void dec_zcache_pers_pageframes(void) { };
197 static inline void inc_zcache_pageframes_alloced(void) { };
198 static inline void inc_zcache_pageframes_freed(void) { };
199 static inline void inc_zcache_eph_zpages(void) { };
200 static inline void dec_zcache_eph_zpages(unsigned zpages) { };
201 static inline void inc_zcache_pers_zpages(void) { };
202 static inline void dec_zcache_pers_zpages(unsigned zpages) { };
203 static inline unsigned long curr_pageframes_count(void)
204 {
205 return 0;
206 };
207 static inline int zcache_debugfs_init(void)
208 {
209 return 0;
210 };
211 static inline void inc_zcache_flush_total(void) { };
212 static inline void inc_zcache_flush_found(void) { };
213 static inline void inc_zcache_flobj_total(void) { };
214 static inline void inc_zcache_flobj_found(void) { };
215 static inline void inc_zcache_failed_eph_puts(void) { };
216 static inline void inc_zcache_failed_pers_puts(void) { };
217 static inline void inc_zcache_failed_getfreepages(void) { };
218 static inline void inc_zcache_failed_alloc(void) { };
219 static inline void inc_zcache_put_to_flush(void) { };
220 static inline void inc_zcache_compress_poor(void) { };
221 static inline void inc_zcache_mean_compress_poor(void) { };
222 static inline void inc_zcache_eph_ate_tail(void) { };
223 static inline void inc_zcache_eph_ate_tail_failed(void) { };
224 static inline void inc_zcache_pers_ate_eph(void) { };
225 static inline void inc_zcache_pers_ate_eph_failed(void) { };
226 static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { };
227 static inline void inc_zcache_evicted_eph_pageframes(void) { };
228
229 static inline void inc_zcache_eph_nonactive_puts_ignored(void) { };
230 static inline void inc_zcache_pers_nonactive_puts_ignored(void) { };
231 #endif
This page took 0.219524 seconds and 4 git commands to generate.