FS-Cache: Add counters for entry/exit to/from cache operation functions
[pandora-kernel.git] / 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 atomic_t fscache_n_cop_alloc_object;
97 atomic_t fscache_n_cop_lookup_object;
98 atomic_t fscache_n_cop_lookup_complete;
99 atomic_t fscache_n_cop_grab_object;
100 atomic_t fscache_n_cop_update_object;
101 atomic_t fscache_n_cop_drop_object;
102 atomic_t fscache_n_cop_put_object;
103 atomic_t fscache_n_cop_sync_cache;
104 atomic_t fscache_n_cop_attr_changed;
105 atomic_t fscache_n_cop_read_or_alloc_page;
106 atomic_t fscache_n_cop_read_or_alloc_pages;
107 atomic_t fscache_n_cop_allocate_page;
108 atomic_t fscache_n_cop_allocate_pages;
109 atomic_t fscache_n_cop_write_page;
110 atomic_t fscache_n_cop_uncache_page;
111 atomic_t fscache_n_cop_dissociate_pages;
112
113 /*
114  * display the general statistics
115  */
116 static int fscache_stats_show(struct seq_file *m, void *v)
117 {
118         seq_puts(m, "FS-Cache statistics\n");
119
120         seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
121                    atomic_read(&fscache_n_cookie_index),
122                    atomic_read(&fscache_n_cookie_data),
123                    atomic_read(&fscache_n_cookie_special));
124
125         seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
126                    atomic_read(&fscache_n_object_alloc),
127                    atomic_read(&fscache_n_object_no_alloc),
128                    atomic_read(&fscache_n_object_avail),
129                    atomic_read(&fscache_n_object_dead));
130         seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
131                    atomic_read(&fscache_n_checkaux_none),
132                    atomic_read(&fscache_n_checkaux_okay),
133                    atomic_read(&fscache_n_checkaux_update),
134                    atomic_read(&fscache_n_checkaux_obsolete));
135
136         seq_printf(m, "Pages  : mrk=%u unc=%u\n",
137                    atomic_read(&fscache_n_marks),
138                    atomic_read(&fscache_n_uncaches));
139
140         seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
141                    " oom=%u\n",
142                    atomic_read(&fscache_n_acquires),
143                    atomic_read(&fscache_n_acquires_null),
144                    atomic_read(&fscache_n_acquires_no_cache),
145                    atomic_read(&fscache_n_acquires_ok),
146                    atomic_read(&fscache_n_acquires_nobufs),
147                    atomic_read(&fscache_n_acquires_oom));
148
149         seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u\n",
150                    atomic_read(&fscache_n_object_lookups),
151                    atomic_read(&fscache_n_object_lookups_negative),
152                    atomic_read(&fscache_n_object_lookups_positive),
153                    atomic_read(&fscache_n_object_created));
154
155         seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
156                    atomic_read(&fscache_n_updates),
157                    atomic_read(&fscache_n_updates_null),
158                    atomic_read(&fscache_n_updates_run));
159
160         seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u\n",
161                    atomic_read(&fscache_n_relinquishes),
162                    atomic_read(&fscache_n_relinquishes_null),
163                    atomic_read(&fscache_n_relinquishes_waitcrt));
164
165         seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
166                    atomic_read(&fscache_n_attr_changed),
167                    atomic_read(&fscache_n_attr_changed_ok),
168                    atomic_read(&fscache_n_attr_changed_nobufs),
169                    atomic_read(&fscache_n_attr_changed_nomem),
170                    atomic_read(&fscache_n_attr_changed_calls));
171
172         seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u\n",
173                    atomic_read(&fscache_n_allocs),
174                    atomic_read(&fscache_n_allocs_ok),
175                    atomic_read(&fscache_n_allocs_wait),
176                    atomic_read(&fscache_n_allocs_nobufs));
177         seq_printf(m, "Allocs : ops=%u owt=%u\n",
178                    atomic_read(&fscache_n_alloc_ops),
179                    atomic_read(&fscache_n_alloc_op_waits));
180
181         seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
182                    " int=%u oom=%u\n",
183                    atomic_read(&fscache_n_retrievals),
184                    atomic_read(&fscache_n_retrievals_ok),
185                    atomic_read(&fscache_n_retrievals_wait),
186                    atomic_read(&fscache_n_retrievals_nodata),
187                    atomic_read(&fscache_n_retrievals_nobufs),
188                    atomic_read(&fscache_n_retrievals_intr),
189                    atomic_read(&fscache_n_retrievals_nomem));
190         seq_printf(m, "Retrvls: ops=%u owt=%u\n",
191                    atomic_read(&fscache_n_retrieval_ops),
192                    atomic_read(&fscache_n_retrieval_op_waits));
193
194         seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
195                    atomic_read(&fscache_n_stores),
196                    atomic_read(&fscache_n_stores_ok),
197                    atomic_read(&fscache_n_stores_again),
198                    atomic_read(&fscache_n_stores_nobufs),
199                    atomic_read(&fscache_n_stores_oom));
200         seq_printf(m, "Stores : ops=%u run=%u\n",
201                    atomic_read(&fscache_n_store_ops),
202                    atomic_read(&fscache_n_store_calls));
203
204         seq_printf(m, "Ops    : pend=%u run=%u enq=%u\n",
205                    atomic_read(&fscache_n_op_pend),
206                    atomic_read(&fscache_n_op_run),
207                    atomic_read(&fscache_n_op_enqueue));
208         seq_printf(m, "Ops    : dfr=%u rel=%u gc=%u\n",
209                    atomic_read(&fscache_n_op_deferred_release),
210                    atomic_read(&fscache_n_op_release),
211                    atomic_read(&fscache_n_op_gc));
212
213         seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
214                    atomic_read(&fscache_n_cop_alloc_object),
215                    atomic_read(&fscache_n_cop_lookup_object),
216                    atomic_read(&fscache_n_cop_lookup_complete),
217                    atomic_read(&fscache_n_cop_grab_object));
218         seq_printf(m, "CacheOp: upo=%d dro=%d pto=%d atc=%d syn=%d\n",
219                    atomic_read(&fscache_n_cop_update_object),
220                    atomic_read(&fscache_n_cop_drop_object),
221                    atomic_read(&fscache_n_cop_put_object),
222                    atomic_read(&fscache_n_cop_attr_changed),
223                    atomic_read(&fscache_n_cop_sync_cache));
224         seq_printf(m, "CacheOp: rap=%d ras=%d alp=%d als=%d wrp=%d ucp=%d dsp=%d\n",
225                    atomic_read(&fscache_n_cop_read_or_alloc_page),
226                    atomic_read(&fscache_n_cop_read_or_alloc_pages),
227                    atomic_read(&fscache_n_cop_allocate_page),
228                    atomic_read(&fscache_n_cop_allocate_pages),
229                    atomic_read(&fscache_n_cop_write_page),
230                    atomic_read(&fscache_n_cop_uncache_page),
231                    atomic_read(&fscache_n_cop_dissociate_pages));
232         return 0;
233 }
234
235 /*
236  * open "/proc/fs/fscache/stats" allowing provision of a statistical summary
237  */
238 static int fscache_stats_open(struct inode *inode, struct file *file)
239 {
240         return single_open(file, fscache_stats_show, NULL);
241 }
242
243 const struct file_operations fscache_stats_fops = {
244         .owner          = THIS_MODULE,
245         .open           = fscache_stats_open,
246         .read           = seq_read,
247         .llseek         = seq_lseek,
248         .release        = seq_release,
249 };