staging: zcache: introduce zero-filled page stat count
[deliverable/linux.git] / drivers / staging / zcache / debug.c
CommitLineData
95bdaee2
KRW
1#include <linux/atomic.h>
2#include "debug.h"
3
67e2cba4 4#ifdef CONFIG_ZCACHE_DEBUG
95bdaee2 5#include <linux/debugfs.h>
9c0ad59e 6
90874fc2
WL
7ssize_t zcache_obj_count;
8ssize_t zcache_obj_count_max;
9ssize_t zcache_objnode_count;
10ssize_t zcache_objnode_count_max;
11u64 zcache_eph_zbytes;
12u64 zcache_eph_zbytes_max;
13u64 zcache_pers_zbytes_max;
14ssize_t zcache_eph_pageframes_max;
15ssize_t zcache_pers_pageframes_max;
16ssize_t zcache_pageframes_alloced;
17ssize_t zcache_pageframes_freed;
18ssize_t zcache_eph_zpages;
19ssize_t zcache_eph_zpages_max;
20ssize_t zcache_pers_zpages_max;
21ssize_t zcache_flush_total;
22ssize_t zcache_flush_found;
23ssize_t zcache_flobj_total;
24ssize_t zcache_flobj_found;
25ssize_t zcache_failed_eph_puts;
26ssize_t zcache_failed_pers_puts;
27ssize_t zcache_failed_getfreepages;
28ssize_t zcache_failed_alloc;
29ssize_t zcache_put_to_flush;
30ssize_t zcache_compress_poor;
31ssize_t zcache_mean_compress_poor;
32ssize_t zcache_eph_ate_tail;
33ssize_t zcache_eph_ate_tail_failed;
34ssize_t zcache_pers_ate_eph;
35ssize_t zcache_pers_ate_eph_failed;
36ssize_t zcache_evicted_eph_zpages;
37ssize_t zcache_evicted_eph_pageframes;
834e3a1c
WL
38ssize_t zcache_zero_filled_pages;
39ssize_t zcache_zero_filled_pages_max;
90874fc2 40
9c0ad59e
KRW
41#define ATTR(x) { .name = #x, .val = &zcache_##x, }
42static struct debug_entry {
43 const char *name;
44 ssize_t *val;
45} attrs[] = {
46 ATTR(obj_count), ATTR(obj_count_max),
47 ATTR(objnode_count), ATTR(objnode_count_max),
48 ATTR(flush_total), ATTR(flush_found),
49 ATTR(flobj_total), ATTR(flobj_found),
50 ATTR(failed_eph_puts), ATTR(failed_pers_puts),
51 ATTR(failed_getfreepages), ATTR(failed_alloc),
52 ATTR(put_to_flush),
53 ATTR(compress_poor), ATTR(mean_compress_poor),
54 ATTR(eph_ate_tail), ATTR(eph_ate_tail_failed),
55 ATTR(pers_ate_eph), ATTR(pers_ate_eph_failed),
56 ATTR(evicted_eph_zpages), ATTR(evicted_eph_pageframes),
57 ATTR(eph_pageframes), ATTR(eph_pageframes_max),
380cb19e 58 ATTR(pers_pageframes), ATTR(pers_pageframes_max),
9c0ad59e
KRW
59 ATTR(eph_zpages), ATTR(eph_zpages_max),
60 ATTR(pers_zpages), ATTR(pers_zpages_max),
61 ATTR(last_active_file_pageframes),
62 ATTR(last_inactive_file_pageframes),
63 ATTR(last_active_anon_pageframes),
64 ATTR(last_inactive_anon_pageframes),
65 ATTR(eph_nonactive_puts_ignored),
66 ATTR(pers_nonactive_puts_ignored),
834e3a1c 67 ATTR(zero_filled_pages),
9c0ad59e 68#ifdef CONFIG_ZCACHE_WRITEBACK
eee53d92
WL
69 ATTR(outstanding_writeback_pages),
70 ATTR(writtenback_pages),
9c0ad59e
KRW
71#endif
72};
73#undef ATTR
95bdaee2
KRW
74int zcache_debugfs_init(void)
75{
9c0ad59e 76 unsigned int i;
95bdaee2
KRW
77 struct dentry *root = debugfs_create_dir("zcache", NULL);
78 if (root == NULL)
79 return -ENXIO;
80
9c0ad59e
KRW
81 for (i = 0; i < ARRAY_SIZE(attrs); i++)
82 if (!debugfs_create_size_t(attrs[i].name, S_IRUGO, root, attrs[i].val))
83 goto out;
84
85 debugfs_create_u64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes);
86 debugfs_create_u64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max);
87 debugfs_create_u64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes);
88 debugfs_create_u64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max);
95bdaee2
KRW
89
90 return 0;
9c0ad59e
KRW
91out:
92 return -ENODEV;
95bdaee2 93}
95bdaee2
KRW
94
95/* developers can call this in case of ooms, e.g. to find memory leaks */
96void zcache_dump(void)
97{
9c0ad59e
KRW
98 unsigned int i;
99 for (i = 0; i < ARRAY_SIZE(attrs); i++)
100 pr_debug("zcache: %s=%zu\n", attrs[i].name, *attrs[i].val);
101
102 pr_debug("zcache: eph_zbytes=%llu\n", (unsigned long long)zcache_eph_zbytes);
103 pr_debug("zcache: eph_zbytes_max=%llu\n", (unsigned long long)zcache_eph_zbytes_max);
104 pr_debug("zcache: pers_zbytes=%llu\n", (unsigned long long)zcache_pers_zbytes);
105 pr_debug("zcache: pers_zbytes_max=%llu\n", (unsigned long long)zcache_pers_zbytes_max);
95bdaee2
KRW
106}
107#endif
This page took 0.044364 seconds and 5 git commands to generate.