aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fscache/stats.c
blob: 65deb99e756b023836d1b71728aa7162d72e98ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/* FS-Cache statistics
 *
 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
 * Written by David Howells (dhowells@redhat.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#define FSCACHE_DEBUG_LEVEL THREAD
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include "internal.h"

/*
 * operation counters
 */
atomic_t fscache_n_op_pend;
atomic_t fscache_n_op_run;
atomic_t fscache_n_op_enqueue;
atomic_t fscache_n_op_requeue;
atomic_t fscache_n_op_deferred_release;
atomic_t fscache_n_op_release;
atomic_t fscache_n_op_gc;

atomic_t fscache_n_attr_changed;
atomic_t fscache_n_attr_changed_ok;
atomic_t fscache_n_attr_changed_nobufs;
atomic_t fscache_n_attr_changed_nomem;
atomic_t fscache_n_attr_changed_calls;

atomic_t fscache_n_allocs;
atomic_t fscache_n_allocs_ok;
atomic_t fscache_n_allocs_wait;
atomic_t fscache_n_allocs_nobufs;
atomic_t fscache_n_alloc_ops;
atomic_t fscache_n_alloc_op_waits;

atomic_t fscache_n_retrievals;
atomic_t fscache_n_retrievals_ok;
atomic_t fscache_n_retrievals_wait;
atomic_t fscache_n_retrievals_nodata;
atomic_t fscache_n_retrievals_nobufs;
atomic_t fscache_n_retrievals_intr;
atomic_t fscache_n_retrievals_nomem;
atomic_t fscache_n_retrieval_ops;
atomic_t fscache_n_retrieval_op_waits;

atomic_t fscache_n_stores;
atomic_t fscache_n_stores_ok;
atomic_t fscache_n_stores_again;
atomic_t fscache_n_stores_nobufs;
atomic_t fscache_n_stores_oom;
atomic_t fscache_n_store_ops;
atomic_t fscache_n_store_calls;

atomic_t fscache_n_marks;
atomic_t fscache_n_uncaches;

atomic_t fscache_n_acquires;
atomic_t fscache_n_acquires_null;
atomic_t fscache_n_acquires_no_cache;
atomic_t fscache_n_acquires_ok;
atomic_t fscache_n_acquires_nobufs;
atomic_t fscache_n_acquires_oom;

atomic_t fscache_n_updates;
atomic_t fscache_n_updates_null;
atomic_t fscache_n_updates_run;

atomic_t fscache_n_relinquishes;
atomic_t fscache_n_relinquishes_null;
atomic_t fscache_n_relinquishes_waitcrt;

atomic_t fscache_n_cookie_index;
atomic_t fscache_n_cookie_data;
atomic_t fscache_n_cookie_special;

atomic_t fscache_n_object_alloc;
atomic_t fscache_n_object_no_alloc;
atomic_t fscache_n_object_lookups;
atomic_t fscache_n_object_lookups_negative;
atomic_t fscache_n_object_lookups_positive;
atomic_t fscache_n_object_created;
atomic_t fscache_n_object_avail;
atomic_t fscache_n_object_dead;

atomic_t fscache_n_checkaux_none;
atomic_t fscache_n_checkaux_okay;
atomic_t fscache_n_checkaux_update;
atomic_t fscache_n_checkaux_obsolete;

/*
 * display the general statistics
 */
static int fscache_stats_show(struct seq_file *m, void *v)
{
	seq_puts(m, "FS-Cache statistics\n");

	seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
		   atomic_read(&fscache_n_cookie_index),
		   atomic_read(&fscache_n_cookie_data),
		   atomic_read(&fscache_n_cookie_special));

	seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
		   atomic_read(&fscache_n_object_alloc),
		   atomic_read(&fscache_n_object_no_alloc),
		   atomic_read(&fscache_n_object_avail),
		   atomic_read(&fscache_n_object_dead));
	seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
		   atomic_read(&fscache_n_checkaux_none),
		   atomic_read(&fscache_n_checkaux_okay),
		   atomic_read(&fscache_n_checkaux_update),
		   atomic_read(&fscache_n_checkaux_obsolete));

	seq_printf(m, "Pages  : mrk=%u unc=%u\n",
		   atomic_read(&fscache_n_marks),
		   atomic_read(&fscache_n_uncaches));

	seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
		   " oom=%u\n",
		   atomic_read(&fscache_n_acquires),
		   atomic_read(&fscache_n_acquires_null),
		   atomic_read(&fscache_n_acquires_no_cache),
		   atomic_read(&fscache_n_acquires_ok),
		   atomic_read(&fscache_n_acquires_nobufs),
		   atomic_read(&fscache_n_acquires_oom));

	seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u\n",
		   atomic_read(&fscache_n_object_lookups),
		   atomic_read(&fscache_n_object_lookups_negative),
		   atomic_read(&fscache_n_object_lookups_positive),
		   atomic_read(&fscache_n_object_created));

	seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
		   atomic_read(&fscache_n_updates),
		   atomic_read(&fscache_n_updates_null),
		   atomic_read(&fscache_n_updates_run));

	seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u\n",
		   atomic_read(&fscache_n_relinquishes),
		   atomic_read(&fscache_n_relinquishes_null),
		   atomic_read(&fscache_n_relinquishes_waitcrt));

	seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
		   atomic_read(&fscache_n_attr_changed),
		   atomic_read(&fscache_n_attr_changed_ok),
		   atomic_read(&fscache_n_attr_changed_nobufs),
		   atomic_read(&fscache_n_attr_changed_nomem),
		   atomic_read(&fscache_n_attr_changed_calls));

	seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u\n",
		   atomic_read(&fscache_n_allocs),
		   atomic_read(&fscache_n_allocs_ok),
		   atomic_read(&fscache_n_allocs_wait),
		   atomic_read(&fscache_n_allocs_nobufs));
	seq_printf(m, "Allocs : ops=%u owt=%u\n",
		   atomic_read(&fscache_n_alloc_ops),
		   atomic_read(&fscache_n_alloc_op_waits));

	seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
		   " int=%u oom=%u\n",
		   atomic_read(&fscache_n_retrievals),
		   atomic_read(&fscache_n_retrievals_ok),
		   atomic_read(&fscache_n_retrievals_wait),
		   atomic_read(&fscache_n_retrievals_nodata),
		   atomic_read(&fscache_n_retrievals_nobufs),
		   atomic_read(&fscache_n_retrievals_intr),
		   atomic_read(&fscache_n_retrievals_nomem));
	seq_printf(m, "Retrvls: ops=%u owt=%u\n",
		   atomic_read(&fscache_n_retrieval_ops),
		   atomic_read(&fscache_n_retrieval_op_waits));

	seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
		   atomic_read(&fscache_n_stores),
		   atomic_read(&fscache_n_stores_ok),
		   atomic_read(&fscache_n_stores_again),
		   atomic_read(&fscache_n_stores_nobufs),
		   atomic_read(&fscache_n_stores_oom));
	seq_printf(m, "Stores : ops=%u run=%u\n",
		   atomic_read(&fscache_n_store_ops),
		   atomic_read(&fscache_n_store_calls));

	seq_printf(m, "Ops    : pend=%u run=%u enq=%u\n",
		   atomic_read(&fscache_n_op_pend),
		   atomic_read(&fscache_n_op_run),
		   atomic_read(&fscache_n_op_enqueue));
	seq_printf(m, "Ops    : dfr=%u rel=%u gc=%u\n",
		   atomic_read(&fscache_n_op_deferred_release),
		   atomic_read(&fscache_n_op_release),
		   atomic_read(&fscache_n_op_gc));
	return 0;
}

/*
 * open "/proc/fs/fscache/stats" allowing provision of a statistical summary
 */
static int fscache_stats_open(struct inode *inode, struct file *file)
{
	return single_open(file, fscache_stats_show, NULL);
}

const struct file_operations fscache_stats_fops = {
	.owner		= THIS_MODULE,
	.open		= fscache_stats_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= seq_release,
};