aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/zcache/debug.h
blob: 8088d28f2dceaae4598feecf88b103039a8609f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#include <linux/bug.h>

#ifdef CONFIG_ZCACHE_DEBUG

/* we try to keep these statistics SMP-consistent */
extern ssize_t zcache_obj_count;
static atomic_t zcache_obj_atomic = ATOMIC_INIT(0);
extern ssize_t zcache_obj_count_max;
static inline void inc_zcache_obj_count(void)
{
	zcache_obj_count = atomic_inc_return(&zcache_obj_atomic);
	if (zcache_obj_count > zcache_obj_count_max)
		zcache_obj_count_max = zcache_obj_count;
}
static inline void dec_zcache_obj_count(void)
{
	zcache_obj_count = atomic_dec_return(&zcache_obj_atomic);
	BUG_ON(zcache_obj_count < 0);
};
extern ssize_t zcache_objnode_count;
static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0);
extern ssize_t zcache_objnode_count_max;
static inline void inc_zcache_objnode_count(void)
{
	zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic);
	if (zcache_objnode_count > zcache_objnode_count_max)
		zcache_objnode_count_max = zcache_objnode_count;
};
static inline void dec_zcache_objnode_count(void)
{
	zcache_objnode_count = atomic_dec_return(&zcache_objnode_atomic);
	BUG_ON(zcache_objnode_count < 0);
};
extern u64 zcache_eph_zbytes;
static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0);
extern u64 zcache_eph_zbytes_max;
static inline void inc_zcache_eph_zbytes(unsigned clen)
{
	zcache_eph_zbytes = atomic_long_add_return(clen, &zcache_eph_zbytes_atomic);
	if (zcache_eph_zbytes > zcache_eph_zbytes_max)
		zcache_eph_zbytes_max = zcache_eph_zbytes;
};
static inline void dec_zcache_eph_zbytes(unsigned zsize)
{
	zcache_eph_zbytes = atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic);
};
extern  u64 zcache_pers_zbytes;
static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0);
extern u64 zcache_pers_zbytes_max;
static inline void inc_zcache_pers_zbytes(unsigned clen)
{
	zcache_pers_zbytes = atomic_long_add_return(clen, &zcache_pers_zbytes_atomic);
	if (zcache_pers_zbytes > zcache_pers_zbytes_max)
		zcache_pers_zbytes_max = zcache_pers_zbytes;
}
static inline void dec_zcache_pers_zbytes(unsigned zsize)
{
	zcache_pers_zbytes = atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic);
}
extern ssize_t zcache_eph_pageframes;
static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0);
extern ssize_t zcache_eph_pageframes_max;
static inline void inc_zcache_eph_pageframes(void)
{
	zcache_eph_pageframes = atomic_inc_return(&zcache_eph_pageframes_atomic);
	if (zcache_eph_pageframes > zcache_eph_pageframes_max)
		zcache_eph_pageframes_max = zcache_eph_pageframes;
};
static inline void dec_zcache_eph_pageframes(void)
{
	zcache_eph_pageframes = atomic_dec_return(&zcache_eph_pageframes_atomic);
};
extern ssize_t zcache_pers_pageframes;
static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0);
extern ssize_t zcache_pers_pageframes_max;
static inline void inc_zcache_pers_pageframes(void)
{
	zcache_pers_pageframes = atomic_inc_return(&zcache_pers_pageframes_atomic);
	if (zcache_pers_pageframes > zcache_pers_pageframes_max)
		zcache_pers_pageframes_max = zcache_pers_pageframes;
}
static inline void dec_zcache_pers_pageframes(void)
{
	zcache_pers_pageframes = atomic_dec_return(&zcache_pers_pageframes_atomic);
}
extern ssize_t zcache_pageframes_alloced;
static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0);
static inline void inc_zcache_pageframes_alloced(void)
{
	zcache_pageframes_alloced = atomic_inc_return(&zcache_pageframes_alloced_atomic);
};
extern ssize_t zcache_pageframes_freed;
static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0);
static inline void inc_zcache_pageframes_freed(void)
{
	zcache_pageframes_freed = atomic_inc_return(&zcache_pageframes_freed_atomic);
}
extern ssize_t zcache_eph_zpages;
static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0);
extern ssize_t zcache_eph_zpages_max;
static inline void inc_zcache_eph_zpages(void)
{
	zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic);
	if (zcache_eph_zpages > zcache_eph_zpages_max)
		zcache_eph_zpages_max = zcache_eph_zpages;
}
static inline void dec_zcache_eph_zpages(unsigned zpages)
{
	zcache_eph_zpages = atomic_sub_return(zpages, &zcache_eph_zpages_atomic);
}
extern ssize_t zcache_pers_zpages;
static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0);
extern ssize_t zcache_pers_zpages_max;
static inline void inc_zcache_pers_zpages(void)
{
	zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic);
	if (zcache_pers_zpages > zcache_pers_zpages_max)
		zcache_pers_zpages_max = zcache_pers_zpages;
}
static inline void dec_zcache_pers_zpages(unsigned zpages)
{
	zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
}

extern ssize_t zcache_zero_filled_pages;
static atomic_t zcache_zero_filled_pages_atomic = ATOMIC_INIT(0);
extern ssize_t zcache_zero_filled_pages_max;
static inline void inc_zcache_zero_filled_pages(void)
{
	zcache_zero_filled_pages = atomic_inc_return(
					&zcache_zero_filled_pages_atomic);
	if (zcache_zero_filled_pages > zcache_zero_filled_pages_max)
		zcache_zero_filled_pages_max = zcache_zero_filled_pages;
}
static inline void dec_zcache_zero_filled_pages(void)
{
	zcache_zero_filled_pages = atomic_dec_return(
					&zcache_zero_filled_pages_atomic);
}
static inline unsigned long curr_pageframes_count(void)
{
	return zcache_pageframes_alloced -
		atomic_read(&zcache_pageframes_freed_atomic) -
		atomic_read(&zcache_eph_pageframes_atomic) -
		atomic_read(&zcache_pers_pageframes_atomic);
};
/* but for the rest of these, counting races are ok */
extern ssize_t zcache_flush_total;
extern ssize_t zcache_flush_found;
extern ssize_t zcache_flobj_total;
extern ssize_t zcache_flobj_found;
extern ssize_t zcache_failed_eph_puts;
extern ssize_t zcache_failed_pers_puts;
extern ssize_t zcache_failed_getfreepages;
extern ssize_t zcache_failed_alloc;
extern ssize_t zcache_put_to_flush;
extern ssize_t zcache_compress_poor;
extern ssize_t zcache_mean_compress_poor;
extern ssize_t zcache_eph_ate_tail;
extern ssize_t zcache_eph_ate_tail_failed;
extern ssize_t zcache_pers_ate_eph;
extern ssize_t zcache_pers_ate_eph_failed;
extern ssize_t zcache_evicted_eph_zpages;
extern ssize_t zcache_evicted_eph_pageframes;

extern ssize_t zcache_last_active_file_pageframes;
extern ssize_t zcache_last_inactive_file_pageframes;
extern ssize_t zcache_last_active_anon_pageframes;
extern ssize_t zcache_last_inactive_anon_pageframes;
static ssize_t zcache_eph_nonactive_puts_ignored;
static ssize_t zcache_pers_nonactive_puts_ignored;
#ifdef CONFIG_ZCACHE_WRITEBACK
extern ssize_t zcache_writtenback_pages;
extern ssize_t zcache_outstanding_writeback_pages;
#endif

static inline void inc_zcache_flush_total(void)
{
	zcache_flush_total++;
};
static inline void inc_zcache_flush_found(void)
{
	zcache_flush_found++;
};
static inline void inc_zcache_flobj_total(void)
{
	zcache_flobj_total++;
};
static inline void inc_zcache_flobj_found(void)
{
	zcache_flobj_found++;
};
static inline void inc_zcache_failed_eph_puts(void)
{
	zcache_failed_eph_puts++;
};
static inline void inc_zcache_failed_pers_puts(void)
{
	zcache_failed_pers_puts++;
};
static inline void inc_zcache_failed_getfreepages(void)
{
	zcache_failed_getfreepages++;
};
static inline void inc_zcache_failed_alloc(void)
{
	zcache_failed_alloc++;
};
static inline void inc_zcache_put_to_flush(void)
{
	zcache_put_to_flush++;
};
static inline void inc_zcache_compress_poor(void)
{
	zcache_compress_poor++;
};
static inline void inc_zcache_mean_compress_poor(void)
{
	zcache_mean_compress_poor++;
};
static inline void inc_zcache_eph_ate_tail(void)
{
	zcache_eph_ate_tail++;
};
static inline void inc_zcache_eph_ate_tail_failed(void)
{
	zcache_eph_ate_tail_failed++;
};
static inline void inc_zcache_pers_ate_eph(void)
{
	zcache_pers_ate_eph++;
};
static inline void inc_zcache_pers_ate_eph_failed(void)
{
	zcache_pers_ate_eph_failed++;
};
static inline void inc_zcache_evicted_eph_zpages(unsigned zpages)
{
	zcache_evicted_eph_zpages += zpages;
};
static inline void inc_zcache_evicted_eph_pageframes(void)
{
	zcache_evicted_eph_pageframes++;
};

static inline void inc_zcache_eph_nonactive_puts_ignored(void)
{
	zcache_eph_nonactive_puts_ignored++;
};
static inline void inc_zcache_pers_nonactive_puts_ignored(void)
{
	zcache_pers_nonactive_puts_ignored++;
};

int zcache_debugfs_init(void);
#else
static inline void inc_zcache_obj_count(void) { };
static inline void dec_zcache_obj_count(void) { };
static inline void inc_zcache_objnode_count(void) { };
static inline void dec_zcache_objnode_count(void) { };
static inline void inc_zcache_eph_zbytes(unsigned clen) { };
static inline void dec_zcache_eph_zbytes(unsigned zsize) { };
static inline void inc_zcache_pers_zbytes(unsigned clen) { };
static inline void dec_zcache_pers_zbytes(unsigned zsize) { };
static inline void inc_zcache_eph_pageframes(void) { };
static inline void dec_zcache_eph_pageframes(void) { };
static inline void inc_zcache_pers_pageframes(void) { };
static inline void dec_zcache_pers_pageframes(void) { };
static inline void inc_zcache_pageframes_alloced(void) { };
static inline void inc_zcache_pageframes_freed(void) { };
static inline void inc_zcache_eph_zpages(void) { };
static inline void dec_zcache_eph_zpages(unsigned zpages) { };
static inline void inc_zcache_pers_zpages(void) { };
static inline void dec_zcache_pers_zpages(unsigned zpages) { };
static inline void inc_zcache_zero_filled_pages(void) { };
static inline void dec_zcache_zero_filled_pages(void) { };
static inline unsigned long curr_pageframes_count(void)
{
	return 0;
};
static inline int zcache_debugfs_init(void)
{
	return 0;
};
static inline void inc_zcache_flush_total(void) { };
static inline void inc_zcache_flush_found(void) { };
static inline void inc_zcache_flobj_total(void) { };
static inline void inc_zcache_flobj_found(void) { };
static inline void inc_zcache_failed_eph_puts(void) { };
static inline void inc_zcache_failed_pers_puts(void) { };
static inline void inc_zcache_failed_getfreepages(void) { };
static inline void inc_zcache_failed_alloc(void) { };
static inline void inc_zcache_put_to_flush(void) { };
static inline void inc_zcache_compress_poor(void) { };
static inline void inc_zcache_mean_compress_poor(void) { };
static inline void inc_zcache_eph_ate_tail(void) { };
static inline void inc_zcache_eph_ate_tail_failed(void) { };
static inline void inc_zcache_pers_ate_eph(void) { };
static inline void inc_zcache_pers_ate_eph_failed(void) { };
static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { };
static inline void inc_zcache_evicted_eph_pageframes(void) { };

static inline void inc_zcache_eph_nonactive_puts_ignored(void) { };
static inline void inc_zcache_pers_nonactive_puts_ignored(void) { };
#endif