blob: 51cdaee14109abcddb038a93ebb1ae3974a5f924 [file] [log] [blame]
David Howells7394daa2009-04-03 16:42:37 +01001/* 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;
David Howells5753c442009-11-19 18:11:19 +000028atomic_t fscache_n_op_cancelled;
David Howellse3d4d282009-11-19 18:11:32 +000029atomic_t fscache_n_op_rejected;
David Howells7394daa2009-04-03 16:42:37 +010030
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;
David Howells5753c442009-11-19 18:11:19 +000041atomic_t fscache_n_allocs_intr;
David Howells60d543c2009-11-19 18:11:45 +000042atomic_t fscache_n_allocs_object_dead;
David Howells7394daa2009-04-03 16:42:37 +010043atomic_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;
David Howells60d543c2009-11-19 18:11:45 +000053atomic_t fscache_n_retrievals_object_dead;
David Howells7394daa2009-04-03 16:42:37 +010054atomic_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;
David Howells1bccf512009-11-19 18:11:25 +000064atomic_t fscache_n_store_pages;
65atomic_t fscache_n_store_radix_deletes;
66atomic_t fscache_n_store_pages_over_limit;
David Howells7394daa2009-04-03 16:42:37 +010067
David Howells201a1542009-11-19 18:11:35 +000068atomic_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
David Howells7394daa2009-04-03 16:42:37 +010073atomic_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
David Howellsef778e72012-12-20 21:52:36 +000083atomic_t fscache_n_invalidates;
84atomic_t fscache_n_invalidates_run;
85
David Howells7394daa2009-04-03 16:42:37 +010086atomic_t fscache_n_updates;
87atomic_t fscache_n_updates_null;
88atomic_t fscache_n_updates_run;
89
90atomic_t fscache_n_relinquishes;
91atomic_t fscache_n_relinquishes_null;
92atomic_t fscache_n_relinquishes_waitcrt;
David Howells2175bb02009-11-19 18:11:38 +000093atomic_t fscache_n_relinquishes_retire;
David Howells7394daa2009-04-03 16:42:37 +010094
95atomic_t fscache_n_cookie_index;
96atomic_t fscache_n_cookie_data;
97atomic_t fscache_n_cookie_special;
98
99atomic_t fscache_n_object_alloc;
100atomic_t fscache_n_object_no_alloc;
101atomic_t fscache_n_object_lookups;
102atomic_t fscache_n_object_lookups_negative;
103atomic_t fscache_n_object_lookups_positive;
David Howellsfee096d2009-11-19 18:12:05 +0000104atomic_t fscache_n_object_lookups_timed_out;
David Howells7394daa2009-04-03 16:42:37 +0100105atomic_t fscache_n_object_created;
106atomic_t fscache_n_object_avail;
107atomic_t fscache_n_object_dead;
108
109atomic_t fscache_n_checkaux_none;
110atomic_t fscache_n_checkaux_okay;
111atomic_t fscache_n_checkaux_update;
112atomic_t fscache_n_checkaux_obsolete;
113
David Howells52bd75f2009-11-19 18:11:08 +0000114atomic_t fscache_n_cop_alloc_object;
115atomic_t fscache_n_cop_lookup_object;
116atomic_t fscache_n_cop_lookup_complete;
117atomic_t fscache_n_cop_grab_object;
David Howellsef778e72012-12-20 21:52:36 +0000118atomic_t fscache_n_cop_invalidate_object;
David Howells52bd75f2009-11-19 18:11:08 +0000119atomic_t fscache_n_cop_update_object;
120atomic_t fscache_n_cop_drop_object;
121atomic_t fscache_n_cop_put_object;
122atomic_t fscache_n_cop_sync_cache;
123atomic_t fscache_n_cop_attr_changed;
124atomic_t fscache_n_cop_read_or_alloc_page;
125atomic_t fscache_n_cop_read_or_alloc_pages;
126atomic_t fscache_n_cop_allocate_page;
127atomic_t fscache_n_cop_allocate_pages;
128atomic_t fscache_n_cop_write_page;
129atomic_t fscache_n_cop_uncache_page;
130atomic_t fscache_n_cop_dissociate_pages;
131
David Howells7394daa2009-04-03 16:42:37 +0100132/*
133 * display the general statistics
134 */
135static int fscache_stats_show(struct seq_file *m, void *v)
136{
137 seq_puts(m, "FS-Cache statistics\n");
138
139 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
140 atomic_read(&fscache_n_cookie_index),
141 atomic_read(&fscache_n_cookie_data),
142 atomic_read(&fscache_n_cookie_special));
143
144 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
145 atomic_read(&fscache_n_object_alloc),
146 atomic_read(&fscache_n_object_no_alloc),
147 atomic_read(&fscache_n_object_avail),
148 atomic_read(&fscache_n_object_dead));
149 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
150 atomic_read(&fscache_n_checkaux_none),
151 atomic_read(&fscache_n_checkaux_okay),
152 atomic_read(&fscache_n_checkaux_update),
153 atomic_read(&fscache_n_checkaux_obsolete));
154
155 seq_printf(m, "Pages : mrk=%u unc=%u\n",
156 atomic_read(&fscache_n_marks),
157 atomic_read(&fscache_n_uncaches));
158
159 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
160 " oom=%u\n",
161 atomic_read(&fscache_n_acquires),
162 atomic_read(&fscache_n_acquires_null),
163 atomic_read(&fscache_n_acquires_no_cache),
164 atomic_read(&fscache_n_acquires_ok),
165 atomic_read(&fscache_n_acquires_nobufs),
166 atomic_read(&fscache_n_acquires_oom));
167
David Howellsfee096d2009-11-19 18:12:05 +0000168 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
David Howells7394daa2009-04-03 16:42:37 +0100169 atomic_read(&fscache_n_object_lookups),
170 atomic_read(&fscache_n_object_lookups_negative),
171 atomic_read(&fscache_n_object_lookups_positive),
David Howellscc4fc292010-04-06 14:35:09 -0700172 atomic_read(&fscache_n_object_created),
173 atomic_read(&fscache_n_object_lookups_timed_out));
David Howells7394daa2009-04-03 16:42:37 +0100174
David Howellsef778e72012-12-20 21:52:36 +0000175 seq_printf(m, "Invals : n=%u run=%u\n",
176 atomic_read(&fscache_n_invalidates),
177 atomic_read(&fscache_n_invalidates_run));
178
David Howells7394daa2009-04-03 16:42:37 +0100179 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
180 atomic_read(&fscache_n_updates),
181 atomic_read(&fscache_n_updates_null),
182 atomic_read(&fscache_n_updates_run));
183
David Howells2175bb02009-11-19 18:11:38 +0000184 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
David Howells7394daa2009-04-03 16:42:37 +0100185 atomic_read(&fscache_n_relinquishes),
186 atomic_read(&fscache_n_relinquishes_null),
David Howells2175bb02009-11-19 18:11:38 +0000187 atomic_read(&fscache_n_relinquishes_waitcrt),
188 atomic_read(&fscache_n_relinquishes_retire));
David Howells7394daa2009-04-03 16:42:37 +0100189
190 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
191 atomic_read(&fscache_n_attr_changed),
192 atomic_read(&fscache_n_attr_changed_ok),
193 atomic_read(&fscache_n_attr_changed_nobufs),
194 atomic_read(&fscache_n_attr_changed_nomem),
195 atomic_read(&fscache_n_attr_changed_calls));
196
David Howells5753c442009-11-19 18:11:19 +0000197 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
David Howells7394daa2009-04-03 16:42:37 +0100198 atomic_read(&fscache_n_allocs),
199 atomic_read(&fscache_n_allocs_ok),
200 atomic_read(&fscache_n_allocs_wait),
David Howells5753c442009-11-19 18:11:19 +0000201 atomic_read(&fscache_n_allocs_nobufs),
202 atomic_read(&fscache_n_allocs_intr));
David Howells60d543c2009-11-19 18:11:45 +0000203 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
David Howells7394daa2009-04-03 16:42:37 +0100204 atomic_read(&fscache_n_alloc_ops),
David Howells60d543c2009-11-19 18:11:45 +0000205 atomic_read(&fscache_n_alloc_op_waits),
206 atomic_read(&fscache_n_allocs_object_dead));
David Howells7394daa2009-04-03 16:42:37 +0100207
208 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
209 " int=%u oom=%u\n",
210 atomic_read(&fscache_n_retrievals),
211 atomic_read(&fscache_n_retrievals_ok),
212 atomic_read(&fscache_n_retrievals_wait),
213 atomic_read(&fscache_n_retrievals_nodata),
214 atomic_read(&fscache_n_retrievals_nobufs),
215 atomic_read(&fscache_n_retrievals_intr),
216 atomic_read(&fscache_n_retrievals_nomem));
David Howells60d543c2009-11-19 18:11:45 +0000217 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
David Howells7394daa2009-04-03 16:42:37 +0100218 atomic_read(&fscache_n_retrieval_ops),
David Howells60d543c2009-11-19 18:11:45 +0000219 atomic_read(&fscache_n_retrieval_op_waits),
220 atomic_read(&fscache_n_retrievals_object_dead));
David Howells7394daa2009-04-03 16:42:37 +0100221
222 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
223 atomic_read(&fscache_n_stores),
224 atomic_read(&fscache_n_stores_ok),
225 atomic_read(&fscache_n_stores_again),
226 atomic_read(&fscache_n_stores_nobufs),
227 atomic_read(&fscache_n_stores_oom));
David Howells1bccf512009-11-19 18:11:25 +0000228 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
David Howells7394daa2009-04-03 16:42:37 +0100229 atomic_read(&fscache_n_store_ops),
David Howells1bccf512009-11-19 18:11:25 +0000230 atomic_read(&fscache_n_store_calls),
231 atomic_read(&fscache_n_store_pages),
232 atomic_read(&fscache_n_store_radix_deletes),
233 atomic_read(&fscache_n_store_pages_over_limit));
David Howells7394daa2009-04-03 16:42:37 +0100234
David Howells201a1542009-11-19 18:11:35 +0000235 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u\n",
236 atomic_read(&fscache_n_store_vmscan_not_storing),
237 atomic_read(&fscache_n_store_vmscan_gone),
238 atomic_read(&fscache_n_store_vmscan_busy),
239 atomic_read(&fscache_n_store_vmscan_cancelled));
240
David Howellse3d4d282009-11-19 18:11:32 +0000241 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
David Howells7394daa2009-04-03 16:42:37 +0100242 atomic_read(&fscache_n_op_pend),
243 atomic_read(&fscache_n_op_run),
David Howells5753c442009-11-19 18:11:19 +0000244 atomic_read(&fscache_n_op_enqueue),
David Howellse3d4d282009-11-19 18:11:32 +0000245 atomic_read(&fscache_n_op_cancelled),
246 atomic_read(&fscache_n_op_rejected));
David Howells7394daa2009-04-03 16:42:37 +0100247 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
248 atomic_read(&fscache_n_op_deferred_release),
249 atomic_read(&fscache_n_op_release),
250 atomic_read(&fscache_n_op_gc));
David Howells52bd75f2009-11-19 18:11:08 +0000251
252 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
253 atomic_read(&fscache_n_cop_alloc_object),
254 atomic_read(&fscache_n_cop_lookup_object),
255 atomic_read(&fscache_n_cop_lookup_complete),
256 atomic_read(&fscache_n_cop_grab_object));
David Howellsef778e72012-12-20 21:52:36 +0000257 seq_printf(m, "CacheOp: inv=%d upo=%d dro=%d pto=%d atc=%d syn=%d\n",
258 atomic_read(&fscache_n_cop_invalidate_object),
David Howells52bd75f2009-11-19 18:11:08 +0000259 atomic_read(&fscache_n_cop_update_object),
260 atomic_read(&fscache_n_cop_drop_object),
261 atomic_read(&fscache_n_cop_put_object),
262 atomic_read(&fscache_n_cop_attr_changed),
263 atomic_read(&fscache_n_cop_sync_cache));
264 seq_printf(m, "CacheOp: rap=%d ras=%d alp=%d als=%d wrp=%d ucp=%d dsp=%d\n",
265 atomic_read(&fscache_n_cop_read_or_alloc_page),
266 atomic_read(&fscache_n_cop_read_or_alloc_pages),
267 atomic_read(&fscache_n_cop_allocate_page),
268 atomic_read(&fscache_n_cop_allocate_pages),
269 atomic_read(&fscache_n_cop_write_page),
270 atomic_read(&fscache_n_cop_uncache_page),
271 atomic_read(&fscache_n_cop_dissociate_pages));
David Howells7394daa2009-04-03 16:42:37 +0100272 return 0;
273}
274
275/*
276 * open "/proc/fs/fscache/stats" allowing provision of a statistical summary
277 */
278static int fscache_stats_open(struct inode *inode, struct file *file)
279{
280 return single_open(file, fscache_stats_show, NULL);
281}
282
283const struct file_operations fscache_stats_fops = {
284 .owner = THIS_MODULE,
285 .open = fscache_stats_open,
286 .read = seq_read,
287 .llseek = seq_lseek,
288 .release = seq_release,
289};