Merge branch 'topic/hda' into for-linus
[linux-2.6] / fs / fscache / stats.c
1 /* FS-Cache statistics
2  *
3  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version
9  * 2 of the License, or (at your option) any later version.
10  */
11
12 #define FSCACHE_DEBUG_LEVEL THREAD
13 #include <linux/module.h>
14 #include <linux/proc_fs.h>
15 #include <linux/seq_file.h>
16 #include "internal.h"
17
18 /*
19  * operation counters
20  */
21 atomic_t fscache_n_op_pend;
22 atomic_t fscache_n_op_run;
23 atomic_t fscache_n_op_enqueue;
24 atomic_t fscache_n_op_requeue;
25 atomic_t fscache_n_op_deferred_release;
26 atomic_t fscache_n_op_release;
27 atomic_t fscache_n_op_gc;
28
29 atomic_t fscache_n_attr_changed;
30 atomic_t fscache_n_attr_changed_ok;
31 atomic_t fscache_n_attr_changed_nobufs;
32 atomic_t fscache_n_attr_changed_nomem;
33 atomic_t fscache_n_attr_changed_calls;
34
35 atomic_t fscache_n_allocs;
36 atomic_t fscache_n_allocs_ok;
37 atomic_t fscache_n_allocs_wait;
38 atomic_t fscache_n_allocs_nobufs;
39 atomic_t fscache_n_alloc_ops;
40 atomic_t fscache_n_alloc_op_waits;
41
42 atomic_t fscache_n_retrievals;
43 atomic_t fscache_n_retrievals_ok;
44 atomic_t fscache_n_retrievals_wait;
45 atomic_t fscache_n_retrievals_nodata;
46 atomic_t fscache_n_retrievals_nobufs;
47 atomic_t fscache_n_retrievals_intr;
48 atomic_t fscache_n_retrievals_nomem;
49 atomic_t fscache_n_retrieval_ops;
50 atomic_t fscache_n_retrieval_op_waits;
51
52 atomic_t fscache_n_stores;
53 atomic_t fscache_n_stores_ok;
54 atomic_t fscache_n_stores_again;
55 atomic_t fscache_n_stores_nobufs;
56 atomic_t fscache_n_stores_oom;
57 atomic_t fscache_n_store_ops;
58 atomic_t fscache_n_store_calls;
59
60 atomic_t fscache_n_marks;
61 atomic_t fscache_n_uncaches;
62
63 atomic_t fscache_n_acquires;
64 atomic_t fscache_n_acquires_null;
65 atomic_t fscache_n_acquires_no_cache;
66 atomic_t fscache_n_acquires_ok;
67 atomic_t fscache_n_acquires_nobufs;
68 atomic_t fscache_n_acquires_oom;
69
70 atomic_t fscache_n_updates;
71 atomic_t fscache_n_updates_null;
72 atomic_t fscache_n_updates_run;
73
74 atomic_t fscache_n_relinquishes;
75 atomic_t fscache_n_relinquishes_null;
76 atomic_t fscache_n_relinquishes_waitcrt;
77
78 atomic_t fscache_n_cookie_index;
79 atomic_t fscache_n_cookie_data;
80 atomic_t fscache_n_cookie_special;
81
82 atomic_t fscache_n_object_alloc;
83 atomic_t fscache_n_object_no_alloc;
84 atomic_t fscache_n_object_lookups;
85 atomic_t fscache_n_object_lookups_negative;
86 atomic_t fscache_n_object_lookups_positive;
87 atomic_t fscache_n_object_created;
88 atomic_t fscache_n_object_avail;
89 atomic_t fscache_n_object_dead;
90
91 atomic_t fscache_n_checkaux_none;
92 atomic_t fscache_n_checkaux_okay;
93 atomic_t fscache_n_checkaux_update;
94 atomic_t fscache_n_checkaux_obsolete;
95
96 /*
97  * display the general statistics
98  */
99 static int fscache_stats_show(struct seq_file *m, void *v)
100 {
101         seq_puts(m, "FS-Cache statistics\n");
102
103         seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
104                    atomic_read(&fscache_n_cookie_index),
105                    atomic_read(&fscache_n_cookie_data),
106                    atomic_read(&fscache_n_cookie_special));
107
108         seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
109                    atomic_read(&fscache_n_object_alloc),
110                    atomic_read(&fscache_n_object_no_alloc),
111                    atomic_read(&fscache_n_object_avail),
112                    atomic_read(&fscache_n_object_dead));
113         seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
114                    atomic_read(&fscache_n_checkaux_none),
115                    atomic_read(&fscache_n_checkaux_okay),
116                    atomic_read(&fscache_n_checkaux_update),
117                    atomic_read(&fscache_n_checkaux_obsolete));
118
119         seq_printf(m, "Pages  : mrk=%u unc=%u\n",
120                    atomic_read(&fscache_n_marks),
121                    atomic_read(&fscache_n_uncaches));
122
123         seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
124                    " oom=%u\n",
125                    atomic_read(&fscache_n_acquires),
126                    atomic_read(&fscache_n_acquires_null),
127                    atomic_read(&fscache_n_acquires_no_cache),
128                    atomic_read(&fscache_n_acquires_ok),
129                    atomic_read(&fscache_n_acquires_nobufs),
130                    atomic_read(&fscache_n_acquires_oom));
131
132         seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u\n",
133                    atomic_read(&fscache_n_object_lookups),
134                    atomic_read(&fscache_n_object_lookups_negative),
135                    atomic_read(&fscache_n_object_lookups_positive),
136                    atomic_read(&fscache_n_object_created));
137
138         seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
139                    atomic_read(&fscache_n_updates),
140                    atomic_read(&fscache_n_updates_null),
141                    atomic_read(&fscache_n_updates_run));
142
143         seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u\n",
144                    atomic_read(&fscache_n_relinquishes),
145                    atomic_read(&fscache_n_relinquishes_null),
146                    atomic_read(&fscache_n_relinquishes_waitcrt));
147
148         seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
149                    atomic_read(&fscache_n_attr_changed),
150                    atomic_read(&fscache_n_attr_changed_ok),
151                    atomic_read(&fscache_n_attr_changed_nobufs),
152                    atomic_read(&fscache_n_attr_changed_nomem),
153                    atomic_read(&fscache_n_attr_changed_calls));
154
155         seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u\n",
156                    atomic_read(&fscache_n_allocs),
157                    atomic_read(&fscache_n_allocs_ok),
158                    atomic_read(&fscache_n_allocs_wait),
159                    atomic_read(&fscache_n_allocs_nobufs));
160         seq_printf(m, "Allocs : ops=%u owt=%u\n",
161                    atomic_read(&fscache_n_alloc_ops),
162                    atomic_read(&fscache_n_alloc_op_waits));
163
164         seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
165                    " int=%u oom=%u\n",
166                    atomic_read(&fscache_n_retrievals),
167                    atomic_read(&fscache_n_retrievals_ok),
168                    atomic_read(&fscache_n_retrievals_wait),
169                    atomic_read(&fscache_n_retrievals_nodata),
170                    atomic_read(&fscache_n_retrievals_nobufs),
171                    atomic_read(&fscache_n_retrievals_intr),
172                    atomic_read(&fscache_n_retrievals_nomem));
173         seq_printf(m, "Retrvls: ops=%u owt=%u\n",
174                    atomic_read(&fscache_n_retrieval_ops),
175                    atomic_read(&fscache_n_retrieval_op_waits));
176
177         seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
178                    atomic_read(&fscache_n_stores),
179                    atomic_read(&fscache_n_stores_ok),
180                    atomic_read(&fscache_n_stores_again),
181                    atomic_read(&fscache_n_stores_nobufs),
182                    atomic_read(&fscache_n_stores_oom));
183         seq_printf(m, "Stores : ops=%u run=%u\n",
184                    atomic_read(&fscache_n_store_ops),
185                    atomic_read(&fscache_n_store_calls));
186
187         seq_printf(m, "Ops    : pend=%u run=%u enq=%u\n",
188                    atomic_read(&fscache_n_op_pend),
189                    atomic_read(&fscache_n_op_run),
190                    atomic_read(&fscache_n_op_enqueue));
191         seq_printf(m, "Ops    : dfr=%u rel=%u gc=%u\n",
192                    atomic_read(&fscache_n_op_deferred_release),
193                    atomic_read(&fscache_n_op_release),
194                    atomic_read(&fscache_n_op_gc));
195         return 0;
196 }
197
198 /*
199  * open "/proc/fs/fscache/stats" allowing provision of a statistical summary
200  */
201 static int fscache_stats_open(struct inode *inode, struct file *file)
202 {
203         return single_open(file, fscache_stats_show, NULL);
204 }
205
206 const struct file_operations fscache_stats_fops = {
207         .owner          = THIS_MODULE,
208         .open           = fscache_stats_open,
209         .read           = seq_read,
210         .llseek         = seq_lseek,
211         .release        = seq_release,
212 };