CacheFiles: Better showing of debugging information in active object problems
[linux-2.6-block.git] / fs / fscache / stats.c
CommitLineData
7394daa8
DH
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 */
21atomic_t fscache_n_op_pend;
22atomic_t fscache_n_op_run;
23atomic_t fscache_n_op_enqueue;
24atomic_t fscache_n_op_requeue;
25atomic_t fscache_n_op_deferred_release;
26atomic_t fscache_n_op_release;
27atomic_t fscache_n_op_gc;
5753c441 28atomic_t fscache_n_op_cancelled;
e3d4d28b 29atomic_t fscache_n_op_rejected;
7394daa8
DH
30
31atomic_t fscache_n_attr_changed;
32atomic_t fscache_n_attr_changed_ok;
33atomic_t fscache_n_attr_changed_nobufs;
34atomic_t fscache_n_attr_changed_nomem;
35atomic_t fscache_n_attr_changed_calls;
36
37atomic_t fscache_n_allocs;
38atomic_t fscache_n_allocs_ok;
39atomic_t fscache_n_allocs_wait;
40atomic_t fscache_n_allocs_nobufs;
5753c441 41atomic_t fscache_n_allocs_intr;
60d543ca 42atomic_t fscache_n_allocs_object_dead;
7394daa8
DH
43atomic_t fscache_n_alloc_ops;
44atomic_t fscache_n_alloc_op_waits;
45
46atomic_t fscache_n_retrievals;
47atomic_t fscache_n_retrievals_ok;
48atomic_t fscache_n_retrievals_wait;
49atomic_t fscache_n_retrievals_nodata;
50atomic_t fscache_n_retrievals_nobufs;
51atomic_t fscache_n_retrievals_intr;
52atomic_t fscache_n_retrievals_nomem;
60d543ca 53atomic_t fscache_n_retrievals_object_dead;
7394daa8
DH
54atomic_t fscache_n_retrieval_ops;
55atomic_t fscache_n_retrieval_op_waits;
56
57atomic_t fscache_n_stores;
58atomic_t fscache_n_stores_ok;
59atomic_t fscache_n_stores_again;
60atomic_t fscache_n_stores_nobufs;
61atomic_t fscache_n_stores_oom;
62atomic_t fscache_n_store_ops;
63atomic_t fscache_n_store_calls;
1bccf513
DH
64atomic_t fscache_n_store_pages;
65atomic_t fscache_n_store_radix_deletes;
66atomic_t fscache_n_store_pages_over_limit;
7394daa8 67
201a1542
DH
68atomic_t fscache_n_store_vmscan_not_storing;
69atomic_t fscache_n_store_vmscan_gone;
70atomic_t fscache_n_store_vmscan_busy;
71atomic_t fscache_n_store_vmscan_cancelled;
72
7394daa8
DH
73atomic_t fscache_n_marks;
74atomic_t fscache_n_uncaches;
75
76atomic_t fscache_n_acquires;
77atomic_t fscache_n_acquires_null;
78atomic_t fscache_n_acquires_no_cache;
79atomic_t fscache_n_acquires_ok;
80atomic_t fscache_n_acquires_nobufs;
81atomic_t fscache_n_acquires_oom;
82
83atomic_t fscache_n_updates;
84atomic_t fscache_n_updates_null;
85atomic_t fscache_n_updates_run;
86
87atomic_t fscache_n_relinquishes;
88atomic_t fscache_n_relinquishes_null;
89atomic_t fscache_n_relinquishes_waitcrt;
2175bb06 90atomic_t fscache_n_relinquishes_retire;
7394daa8
DH
91
92atomic_t fscache_n_cookie_index;
93atomic_t fscache_n_cookie_data;
94atomic_t fscache_n_cookie_special;
95
96atomic_t fscache_n_object_alloc;
97atomic_t fscache_n_object_no_alloc;
98atomic_t fscache_n_object_lookups;
99atomic_t fscache_n_object_lookups_negative;
100atomic_t fscache_n_object_lookups_positive;
101atomic_t fscache_n_object_created;
102atomic_t fscache_n_object_avail;
103atomic_t fscache_n_object_dead;
104
105atomic_t fscache_n_checkaux_none;
106atomic_t fscache_n_checkaux_okay;
107atomic_t fscache_n_checkaux_update;
108atomic_t fscache_n_checkaux_obsolete;
109
52bd75fd
DH
110atomic_t fscache_n_cop_alloc_object;
111atomic_t fscache_n_cop_lookup_object;
112atomic_t fscache_n_cop_lookup_complete;
113atomic_t fscache_n_cop_grab_object;
114atomic_t fscache_n_cop_update_object;
115atomic_t fscache_n_cop_drop_object;
116atomic_t fscache_n_cop_put_object;
117atomic_t fscache_n_cop_sync_cache;
118atomic_t fscache_n_cop_attr_changed;
119atomic_t fscache_n_cop_read_or_alloc_page;
120atomic_t fscache_n_cop_read_or_alloc_pages;
121atomic_t fscache_n_cop_allocate_page;
122atomic_t fscache_n_cop_allocate_pages;
123atomic_t fscache_n_cop_write_page;
124atomic_t fscache_n_cop_uncache_page;
125atomic_t fscache_n_cop_dissociate_pages;
126
7394daa8
DH
127/*
128 * display the general statistics
129 */
130static int fscache_stats_show(struct seq_file *m, void *v)
131{
132 seq_puts(m, "FS-Cache statistics\n");
133
134 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
135 atomic_read(&fscache_n_cookie_index),
136 atomic_read(&fscache_n_cookie_data),
137 atomic_read(&fscache_n_cookie_special));
138
139 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
140 atomic_read(&fscache_n_object_alloc),
141 atomic_read(&fscache_n_object_no_alloc),
142 atomic_read(&fscache_n_object_avail),
143 atomic_read(&fscache_n_object_dead));
144 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
145 atomic_read(&fscache_n_checkaux_none),
146 atomic_read(&fscache_n_checkaux_okay),
147 atomic_read(&fscache_n_checkaux_update),
148 atomic_read(&fscache_n_checkaux_obsolete));
149
150 seq_printf(m, "Pages : mrk=%u unc=%u\n",
151 atomic_read(&fscache_n_marks),
152 atomic_read(&fscache_n_uncaches));
153
154 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
155 " oom=%u\n",
156 atomic_read(&fscache_n_acquires),
157 atomic_read(&fscache_n_acquires_null),
158 atomic_read(&fscache_n_acquires_no_cache),
159 atomic_read(&fscache_n_acquires_ok),
160 atomic_read(&fscache_n_acquires_nobufs),
161 atomic_read(&fscache_n_acquires_oom));
162
163 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u\n",
164 atomic_read(&fscache_n_object_lookups),
165 atomic_read(&fscache_n_object_lookups_negative),
166 atomic_read(&fscache_n_object_lookups_positive),
167 atomic_read(&fscache_n_object_created));
168
169 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
170 atomic_read(&fscache_n_updates),
171 atomic_read(&fscache_n_updates_null),
172 atomic_read(&fscache_n_updates_run));
173
2175bb06 174 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
7394daa8
DH
175 atomic_read(&fscache_n_relinquishes),
176 atomic_read(&fscache_n_relinquishes_null),
2175bb06
DH
177 atomic_read(&fscache_n_relinquishes_waitcrt),
178 atomic_read(&fscache_n_relinquishes_retire));
7394daa8
DH
179
180 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
181 atomic_read(&fscache_n_attr_changed),
182 atomic_read(&fscache_n_attr_changed_ok),
183 atomic_read(&fscache_n_attr_changed_nobufs),
184 atomic_read(&fscache_n_attr_changed_nomem),
185 atomic_read(&fscache_n_attr_changed_calls));
186
5753c441 187 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
7394daa8
DH
188 atomic_read(&fscache_n_allocs),
189 atomic_read(&fscache_n_allocs_ok),
190 atomic_read(&fscache_n_allocs_wait),
5753c441
DH
191 atomic_read(&fscache_n_allocs_nobufs),
192 atomic_read(&fscache_n_allocs_intr));
60d543ca 193 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
7394daa8 194 atomic_read(&fscache_n_alloc_ops),
60d543ca
DH
195 atomic_read(&fscache_n_alloc_op_waits),
196 atomic_read(&fscache_n_allocs_object_dead));
7394daa8
DH
197
198 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
199 " int=%u oom=%u\n",
200 atomic_read(&fscache_n_retrievals),
201 atomic_read(&fscache_n_retrievals_ok),
202 atomic_read(&fscache_n_retrievals_wait),
203 atomic_read(&fscache_n_retrievals_nodata),
204 atomic_read(&fscache_n_retrievals_nobufs),
205 atomic_read(&fscache_n_retrievals_intr),
206 atomic_read(&fscache_n_retrievals_nomem));
60d543ca 207 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
7394daa8 208 atomic_read(&fscache_n_retrieval_ops),
60d543ca
DH
209 atomic_read(&fscache_n_retrieval_op_waits),
210 atomic_read(&fscache_n_retrievals_object_dead));
7394daa8
DH
211
212 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
213 atomic_read(&fscache_n_stores),
214 atomic_read(&fscache_n_stores_ok),
215 atomic_read(&fscache_n_stores_again),
216 atomic_read(&fscache_n_stores_nobufs),
217 atomic_read(&fscache_n_stores_oom));
1bccf513 218 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
7394daa8 219 atomic_read(&fscache_n_store_ops),
1bccf513
DH
220 atomic_read(&fscache_n_store_calls),
221 atomic_read(&fscache_n_store_pages),
222 atomic_read(&fscache_n_store_radix_deletes),
223 atomic_read(&fscache_n_store_pages_over_limit));
7394daa8 224
201a1542
DH
225 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u\n",
226 atomic_read(&fscache_n_store_vmscan_not_storing),
227 atomic_read(&fscache_n_store_vmscan_gone),
228 atomic_read(&fscache_n_store_vmscan_busy),
229 atomic_read(&fscache_n_store_vmscan_cancelled));
230
e3d4d28b 231 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
7394daa8
DH
232 atomic_read(&fscache_n_op_pend),
233 atomic_read(&fscache_n_op_run),
5753c441 234 atomic_read(&fscache_n_op_enqueue),
e3d4d28b
DH
235 atomic_read(&fscache_n_op_cancelled),
236 atomic_read(&fscache_n_op_rejected));
7394daa8
DH
237 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
238 atomic_read(&fscache_n_op_deferred_release),
239 atomic_read(&fscache_n_op_release),
240 atomic_read(&fscache_n_op_gc));
52bd75fd
DH
241
242 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
243 atomic_read(&fscache_n_cop_alloc_object),
244 atomic_read(&fscache_n_cop_lookup_object),
245 atomic_read(&fscache_n_cop_lookup_complete),
246 atomic_read(&fscache_n_cop_grab_object));
247 seq_printf(m, "CacheOp: upo=%d dro=%d pto=%d atc=%d syn=%d\n",
248 atomic_read(&fscache_n_cop_update_object),
249 atomic_read(&fscache_n_cop_drop_object),
250 atomic_read(&fscache_n_cop_put_object),
251 atomic_read(&fscache_n_cop_attr_changed),
252 atomic_read(&fscache_n_cop_sync_cache));
253 seq_printf(m, "CacheOp: rap=%d ras=%d alp=%d als=%d wrp=%d ucp=%d dsp=%d\n",
254 atomic_read(&fscache_n_cop_read_or_alloc_page),
255 atomic_read(&fscache_n_cop_read_or_alloc_pages),
256 atomic_read(&fscache_n_cop_allocate_page),
257 atomic_read(&fscache_n_cop_allocate_pages),
258 atomic_read(&fscache_n_cop_write_page),
259 atomic_read(&fscache_n_cop_uncache_page),
260 atomic_read(&fscache_n_cop_dissociate_pages));
7394daa8
DH
261 return 0;
262}
263
264/*
265 * open "/proc/fs/fscache/stats" allowing provision of a statistical summary
266 */
267static int fscache_stats_open(struct inode *inode, struct file *file)
268{
269 return single_open(file, fscache_stats_show, NULL);
270}
271
272const struct file_operations fscache_stats_fops = {
273 .owner = THIS_MODULE,
274 .open = fscache_stats_open,
275 .read = seq_read,
276 .llseek = seq_lseek,
277 .release = seq_release,
278};