]> Pileus Git - ~andy/linux/blob - drivers/staging/zcache/debug.c
Merge tag 'for-v3.10-fixes' of git://git.infradead.org/battery-2.6
[~andy/linux] / drivers / staging / zcache / debug.c
1 #include <linux/atomic.h>
2 #include "debug.h"
3
4 #ifdef CONFIG_ZCACHE_DEBUG
5 #include <linux/debugfs.h>
6
7 ssize_t zcache_obj_count;
8 ssize_t zcache_obj_count_max;
9 ssize_t zcache_objnode_count;
10 ssize_t zcache_objnode_count_max;
11 u64 zcache_eph_zbytes;
12 u64 zcache_eph_zbytes_max;
13 u64 zcache_pers_zbytes_max;
14 ssize_t zcache_eph_pageframes_max;
15 ssize_t zcache_pers_pageframes_max;
16 ssize_t zcache_pageframes_alloced;
17 ssize_t zcache_pageframes_freed;
18 ssize_t zcache_eph_zpages;
19 ssize_t zcache_eph_zpages_max;
20 ssize_t zcache_pers_zpages_max;
21 ssize_t zcache_flush_total;
22 ssize_t zcache_flush_found;
23 ssize_t zcache_flobj_total;
24 ssize_t zcache_flobj_found;
25 ssize_t zcache_failed_eph_puts;
26 ssize_t zcache_failed_pers_puts;
27 ssize_t zcache_failed_getfreepages;
28 ssize_t zcache_failed_alloc;
29 ssize_t zcache_put_to_flush;
30 ssize_t zcache_compress_poor;
31 ssize_t zcache_mean_compress_poor;
32 ssize_t zcache_eph_ate_tail;
33 ssize_t zcache_eph_ate_tail_failed;
34 ssize_t zcache_pers_ate_eph;
35 ssize_t zcache_pers_ate_eph_failed;
36 ssize_t zcache_evicted_eph_zpages;
37 ssize_t zcache_evicted_eph_pageframes;
38 ssize_t zcache_zero_filled_pages;
39 ssize_t zcache_zero_filled_pages_max;
40
41 #define ATTR(x)  { .name = #x, .val = &zcache_##x, }
42 static 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),
58         ATTR(pers_pageframes), ATTR(pers_pageframes_max),
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),
67         ATTR(zero_filled_pages),
68 #ifdef CONFIG_ZCACHE_WRITEBACK
69         ATTR(outstanding_writeback_pages),
70         ATTR(writtenback_pages),
71 #endif
72 };
73 #undef ATTR
74 int zcache_debugfs_init(void)
75 {
76         unsigned int i;
77         struct dentry *root = debugfs_create_dir("zcache", NULL);
78         if (root == NULL)
79                 return -ENXIO;
80
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);
89
90         return 0;
91 out:
92         return -ENODEV;
93 }
94
95 /* developers can call this in case of ooms, e.g. to find memory leaks */
96 void zcache_dump(void)
97 {
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);
106 }
107 #endif