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