staging: zcache: introduce zero-filled page stat count
[deliverable/linux.git] / drivers / staging / zcache / debug.h
CommitLineData
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 6extern ssize_t zcache_obj_count;
95bdaee2 7static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
90874fc2 8extern ssize_t zcache_obj_count_max;
95bdaee2
KRW
9static 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}
15static 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 20extern ssize_t zcache_objnode_count;
95bdaee2 21static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
90874fc2 22extern ssize_t zcache_objnode_count_max;
95bdaee2
KRW
23static 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};
29static 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 34extern u64 zcache_eph_zbytes;
95bdaee2 35static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
90874fc2 36extern u64 zcache_eph_zbytes_max;
95bdaee2
KRW
37static 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};
43static inline void dec_zcache_eph_zbytes(unsigned zsize)
44{
45 zcache_eph_zbytes = atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
46};
47extern u64 zcache_pers_zbytes;
48static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
90874fc2 49extern u64 zcache_pers_zbytes_max;
95bdaee2
KRW
50static 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}
56static inline void dec_zcache_pers_zbytes(unsigned zsize)
57{
58 zcache_pers_zbytes = atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
59}
60extern ssize_t zcache_eph_pageframes;
61static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
90874fc2 62extern ssize_t zcache_eph_pageframes_max;
95bdaee2
KRW
63static 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};
69static inline void dec_zcache_eph_pageframes(void)
70{
71 zcache_eph_pageframes = atomic_dec_return(&zcache_eph_pageframes_atomic);
72};
73extern ssize_t zcache_pers_pageframes;
74static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
90874fc2 75extern ssize_t zcache_pers_pageframes_max;
95bdaee2
KRW
76static 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}
82static inline void dec_zcache_pers_pageframes(void)
83{
84 zcache_pers_pageframes = atomic_dec_return(&zcache_pers_pageframes_atomic);
85}
90874fc2 86extern ssize_t zcache_pageframes_alloced;
95bdaee2
KRW
87static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
88static inline void inc_zcache_pageframes_alloced(void)
89{
90 zcache_pageframes_alloced = atomic_inc_return(&zcache_pageframes_alloced_atomic);
91};
90874fc2 92extern ssize_t zcache_pageframes_freed;
95bdaee2
KRW
93static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
94static inline void inc_zcache_pageframes_freed(void)
95{
96 zcache_pageframes_freed = atomic_inc_return(&zcache_pageframes_freed_atomic);
97}
90874fc2 98extern ssize_t zcache_eph_zpages;
95bdaee2 99static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
90874fc2 100extern ssize_t zcache_eph_zpages_max;
95bdaee2
KRW
101static 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}
107static inline void dec_zcache_eph_zpages(unsigned zpages)
108{
109 zcache_eph_zpages = atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
110}
111extern ssize_t zcache_pers_zpages;
112static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
90874fc2 113extern ssize_t zcache_pers_zpages_max;
95bdaee2
KRW
114static 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}
120static 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
125extern ssize_t zcache_zero_filled_pages;
126static atomic_t zcache_zero_filled_pages_atomic = ATOMIC_INIT(0);
127extern ssize_t zcache_zero_filled_pages_max;
128static 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}
135static 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
140static 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
148extern ssize_t zcache_flush_total;
149extern ssize_t zcache_flush_found;
150extern ssize_t zcache_flobj_total;
151extern ssize_t zcache_flobj_found;
152extern ssize_t zcache_failed_eph_puts;
153extern ssize_t zcache_failed_pers_puts;
154extern ssize_t zcache_failed_getfreepages;
155extern ssize_t zcache_failed_alloc;
156extern ssize_t zcache_put_to_flush;
157extern ssize_t zcache_compress_poor;
158extern ssize_t zcache_mean_compress_poor;
159extern ssize_t zcache_eph_ate_tail;
160extern ssize_t zcache_eph_ate_tail_failed;
161extern ssize_t zcache_pers_ate_eph;
162extern ssize_t zcache_pers_ate_eph_failed;
163extern ssize_t zcache_evicted_eph_zpages;
164extern ssize_t zcache_evicted_eph_pageframes;
86d7de66 165
95bdaee2
KRW
166extern ssize_t zcache_last_active_file_pageframes;
167extern ssize_t zcache_last_inactive_file_pageframes;
168extern ssize_t zcache_last_active_anon_pageframes;
169extern ssize_t zcache_last_inactive_anon_pageframes;
86d7de66
KRW
170static ssize_t zcache_eph_nonactive_puts_ignored;
171static ssize_t zcache_pers_nonactive_puts_ignored;
95bdaee2
KRW
172#ifdef CONFIG_ZCACHE_WRITEBACK
173extern ssize_t zcache_writtenback_pages;
174extern ssize_t zcache_outstanding_writeback_pages;
175#endif
176
86d7de66
KRW
177static inline void inc_zcache_flush_total(void) { zcache_flush_total ++; };
178static inline void inc_zcache_flush_found(void) { zcache_flush_found ++; };
179static inline void inc_zcache_flobj_total(void) { zcache_flobj_total ++; };
180static inline void inc_zcache_flobj_found(void) { zcache_flobj_found ++; };
181static inline void inc_zcache_failed_eph_puts(void) { zcache_failed_eph_puts ++; };
182static inline void inc_zcache_failed_pers_puts(void) { zcache_failed_pers_puts ++; };
183static inline void inc_zcache_failed_getfreepages(void) { zcache_failed_getfreepages ++; };
184static inline void inc_zcache_failed_alloc(void) { zcache_failed_alloc ++; };
185static inline void inc_zcache_put_to_flush(void) { zcache_put_to_flush ++; };
186static inline void inc_zcache_compress_poor(void) { zcache_compress_poor ++; };
187static inline void inc_zcache_mean_compress_poor(void) { zcache_mean_compress_poor ++; };
188static inline void inc_zcache_eph_ate_tail(void) { zcache_eph_ate_tail ++; };
189static inline void inc_zcache_eph_ate_tail_failed(void) { zcache_eph_ate_tail_failed ++; };
190static inline void inc_zcache_pers_ate_eph(void) { zcache_pers_ate_eph ++; };
191static inline void inc_zcache_pers_ate_eph_failed(void) { zcache_pers_ate_eph_failed ++; };
192static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { zcache_evicted_eph_zpages += zpages; };
193static inline void inc_zcache_evicted_eph_pageframes(void) { zcache_evicted_eph_pageframes ++; };
194
195static inline void inc_zcache_eph_nonactive_puts_ignored(void) { zcache_eph_nonactive_puts_ignored ++; };
196static inline void inc_zcache_pers_nonactive_puts_ignored(void) { zcache_pers_nonactive_puts_ignored ++; };
197
95bdaee2
KRW
198int zcache_debugfs_init(void);
199#else
200static inline void inc_zcache_obj_count(void) { };
201static inline void dec_zcache_obj_count(void) { };
202static inline void inc_zcache_objnode_count(void) { };
203static inline void dec_zcache_objnode_count(void) { };
204static inline void inc_zcache_eph_zbytes(unsigned clen) { };
205static inline void dec_zcache_eph_zbytes(unsigned zsize) { };
206static inline void inc_zcache_pers_zbytes(unsigned clen) { };
207static inline void dec_zcache_pers_zbytes(unsigned zsize) { };
208static inline void inc_zcache_eph_pageframes(void) { };
209static inline void dec_zcache_eph_pageframes(void) { };
210static inline void inc_zcache_pers_pageframes(void) { };
211static inline void dec_zcache_pers_pageframes(void) { };
212static inline void inc_zcache_pageframes_alloced(void) { };
213static inline void inc_zcache_pageframes_freed(void) { };
214static inline void inc_zcache_eph_zpages(void) { };
215static inline void dec_zcache_eph_zpages(unsigned zpages) { };
216static inline void inc_zcache_pers_zpages(void) { };
217static inline void dec_zcache_pers_zpages(unsigned zpages) { };
834e3a1c
WL
218static inline void inc_zcache_zero_filled_pages(void) { };
219static inline void dec_zcache_zero_filled_pages(void) { };
95bdaee2
KRW
220static inline unsigned long curr_pageframes_count(void)
221{
222 return 0;
223};
224static inline int zcache_debugfs_init(void)
225{
226 return 0;
227};
86d7de66
KRW
228static inline void inc_zcache_flush_total(void) { };
229static inline void inc_zcache_flush_found(void) { };
230static inline void inc_zcache_flobj_total(void) { };
231static inline void inc_zcache_flobj_found(void) { };
232static inline void inc_zcache_failed_eph_puts(void) { };
233static inline void inc_zcache_failed_pers_puts(void) { };
234static inline void inc_zcache_failed_getfreepages(void) { };
235static inline void inc_zcache_failed_alloc(void) { };
236static inline void inc_zcache_put_to_flush(void) { };
237static inline void inc_zcache_compress_poor(void) { };
238static inline void inc_zcache_mean_compress_poor(void) { };
239static inline void inc_zcache_eph_ate_tail(void) { };
240static inline void inc_zcache_eph_ate_tail_failed(void) { };
241static inline void inc_zcache_pers_ate_eph(void) { };
242static inline void inc_zcache_pers_ate_eph_failed(void) { };
243static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { };
244static inline void inc_zcache_evicted_eph_pageframes(void) { };
245
246static inline void inc_zcache_eph_nonactive_puts_ignored(void) { };
247static inline void inc_zcache_pers_nonactive_puts_ignored(void) { };
95bdaee2 248#endif
This page took 0.069325 seconds and 5 git commands to generate.