zcache/debug: Coalesce all debug under CONFIG_ZCACHE_DEBUG
[linux-2.6/btrfs-unstable.git] / drivers / staging / zcache / debug.c
blobe951c64a13dc7c46c0c70be09fe4d08efafe188e
1 #include <linux/atomic.h>
2 #include "debug.h"
4 #ifdef CONFIG_ZCACHE_DEBUG
5 #include <linux/debugfs.h>
7 #define ATTR(x) { .name = #x, .val = &zcache_##x, }
8 static struct debug_entry {
9 const char *name;
10 ssize_t *val;
11 } attrs[] = {
12 ATTR(obj_count), ATTR(obj_count_max),
13 ATTR(objnode_count), ATTR(objnode_count_max),
14 ATTR(flush_total), ATTR(flush_found),
15 ATTR(flobj_total), ATTR(flobj_found),
16 ATTR(failed_eph_puts), ATTR(failed_pers_puts),
17 ATTR(failed_getfreepages), ATTR(failed_alloc),
18 ATTR(put_to_flush),
19 ATTR(compress_poor), ATTR(mean_compress_poor),
20 ATTR(eph_ate_tail), ATTR(eph_ate_tail_failed),
21 ATTR(pers_ate_eph), ATTR(pers_ate_eph_failed),
22 ATTR(evicted_eph_zpages), ATTR(evicted_eph_pageframes),
23 ATTR(eph_pageframes), ATTR(eph_pageframes_max),
24 ATTR(eph_zpages), ATTR(eph_zpages_max),
25 ATTR(pers_zpages), ATTR(pers_zpages_max),
26 ATTR(last_active_file_pageframes),
27 ATTR(last_inactive_file_pageframes),
28 ATTR(last_active_anon_pageframes),
29 ATTR(last_inactive_anon_pageframes),
30 ATTR(eph_nonactive_puts_ignored),
31 ATTR(pers_nonactive_puts_ignored),
32 #ifdef CONFIG_ZCACHE_WRITEBACK
33 ATTR(zcache_outstanding_writeback_pages),
34 ATTR(zcache_writtenback_pages),
35 #endif
37 #undef ATTR
38 int zcache_debugfs_init(void)
40 unsigned int i;
41 struct dentry *root = debugfs_create_dir("zcache", NULL);
42 if (root == NULL)
43 return -ENXIO;
45 for (i = 0; i < ARRAY_SIZE(attrs); i++)
46 if (!debugfs_create_size_t(attrs[i].name, S_IRUGO, root, attrs[i].val))
47 goto out;
49 debugfs_create_u64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes);
50 debugfs_create_u64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max);
51 debugfs_create_u64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes);
52 debugfs_create_u64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max);
54 return 0;
55 out:
56 return -ENODEV;
59 /* developers can call this in case of ooms, e.g. to find memory leaks */
60 void zcache_dump(void)
62 unsigned int i;
63 for (i = 0; i < ARRAY_SIZE(attrs); i++)
64 pr_debug("zcache: %s=%zu\n", attrs[i].name, *attrs[i].val);
66 pr_debug("zcache: eph_zbytes=%llu\n", (unsigned long long)zcache_eph_zbytes);
67 pr_debug("zcache: eph_zbytes_max=%llu\n", (unsigned long long)zcache_eph_zbytes_max);
68 pr_debug("zcache: pers_zbytes=%llu\n", (unsigned long long)zcache_pers_zbytes);
69 pr_debug("zcache: pers_zbytes_max=%llu\n", (unsigned long long)zcache_pers_zbytes_max);
71 #endif