blob: fc94e5e79f1c6d456bd6e48ac2fe8a5141f70ef6 [file] [log] [blame]
David Howells1e1236b2021-10-20 14:34:41 +01001// SPDX-License-Identifier: GPL-2.0-or-later
2/* FS-Cache statistics
3 *
4 * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
6 */
7
8#define FSCACHE_DEBUG_LEVEL CACHE
9#include <linux/proc_fs.h>
10#include <linux/seq_file.h>
11#include "internal.h"
12
13/*
David Howells62ab6332021-10-20 15:26:17 +010014 * operation counters
15 */
16atomic_t fscache_n_volumes;
17atomic_t fscache_n_volumes_collision;
18atomic_t fscache_n_volumes_nomem;
David Howells7f3283a2021-10-20 15:53:34 +010019atomic_t fscache_n_cookies;
David Howells12bb21a2021-10-20 15:53:34 +010020atomic_t fscache_n_cookies_lru;
21atomic_t fscache_n_cookies_lru_expired;
22atomic_t fscache_n_cookies_lru_removed;
23atomic_t fscache_n_cookies_lru_dropped;
David Howells7f3283a2021-10-20 15:53:34 +010024
25atomic_t fscache_n_acquires;
26atomic_t fscache_n_acquires_ok;
27atomic_t fscache_n_acquires_oom;
28
David Howellsd24af132021-10-20 15:53:34 +010029atomic_t fscache_n_invalidates;
30
David Howells7f3283a2021-10-20 15:53:34 +010031atomic_t fscache_n_updates;
32EXPORT_SYMBOL(fscache_n_updates);
33
34atomic_t fscache_n_relinquishes;
35atomic_t fscache_n_relinquishes_retire;
36atomic_t fscache_n_relinquishes_dropped;
David Howells62ab6332021-10-20 15:26:17 +010037
David Howells16a96bd2021-10-20 14:06:34 +010038atomic_t fscache_n_resizes;
39atomic_t fscache_n_resizes_null;
40
David Howells8e7a8672021-10-20 23:06:16 +010041atomic_t fscache_n_read;
42EXPORT_SYMBOL(fscache_n_read);
43atomic_t fscache_n_write;
44EXPORT_SYMBOL(fscache_n_write);
David Howells3929eca2021-10-21 21:58:29 +010045atomic_t fscache_n_no_write_space;
46EXPORT_SYMBOL(fscache_n_no_write_space);
47atomic_t fscache_n_no_create_space;
48EXPORT_SYMBOL(fscache_n_no_create_space);
David Howells9f08ebc2021-10-22 09:17:58 +010049atomic_t fscache_n_culled;
50EXPORT_SYMBOL(fscache_n_culled);
David Howells8e7a8672021-10-20 23:06:16 +010051
David Howells62ab6332021-10-20 15:26:17 +010052/*
David Howells1e1236b2021-10-20 14:34:41 +010053 * display the general statistics
54 */
55int fscache_stats_show(struct seq_file *m, void *v)
56{
57 seq_puts(m, "FS-Cache statistics\n");
David Howells7f3283a2021-10-20 15:53:34 +010058 seq_printf(m, "Cookies: n=%d v=%d vcol=%u voom=%u\n",
59 atomic_read(&fscache_n_cookies),
David Howells62ab6332021-10-20 15:26:17 +010060 atomic_read(&fscache_n_volumes),
61 atomic_read(&fscache_n_volumes_collision),
62 atomic_read(&fscache_n_volumes_nomem)
63 );
David Howells1e1236b2021-10-20 14:34:41 +010064
David Howells7f3283a2021-10-20 15:53:34 +010065 seq_printf(m, "Acquire: n=%u ok=%u oom=%u\n",
66 atomic_read(&fscache_n_acquires),
67 atomic_read(&fscache_n_acquires_ok),
68 atomic_read(&fscache_n_acquires_oom));
69
David Howells12bb21a2021-10-20 15:53:34 +010070 seq_printf(m, "LRU : n=%u exp=%u rmv=%u drp=%u at=%ld\n",
71 atomic_read(&fscache_n_cookies_lru),
72 atomic_read(&fscache_n_cookies_lru_expired),
73 atomic_read(&fscache_n_cookies_lru_removed),
74 atomic_read(&fscache_n_cookies_lru_dropped),
75 timer_pending(&fscache_cookie_lru_timer) ?
76 fscache_cookie_lru_timer.expires - jiffies : 0);
77
David Howellsd24af132021-10-20 15:53:34 +010078 seq_printf(m, "Invals : n=%u\n",
79 atomic_read(&fscache_n_invalidates));
80
David Howells16a96bd2021-10-20 14:06:34 +010081 seq_printf(m, "Updates: n=%u rsz=%u rsn=%u\n",
82 atomic_read(&fscache_n_updates),
83 atomic_read(&fscache_n_resizes),
84 atomic_read(&fscache_n_resizes_null));
David Howells7f3283a2021-10-20 15:53:34 +010085
86 seq_printf(m, "Relinqs: n=%u rtr=%u drop=%u\n",
87 atomic_read(&fscache_n_relinquishes),
88 atomic_read(&fscache_n_relinquishes_retire),
89 atomic_read(&fscache_n_relinquishes_dropped));
90
David Howells9f08ebc2021-10-22 09:17:58 +010091 seq_printf(m, "NoSpace: nwr=%u ncr=%u cull=%u\n",
David Howells3929eca2021-10-21 21:58:29 +010092 atomic_read(&fscache_n_no_write_space),
David Howells9f08ebc2021-10-22 09:17:58 +010093 atomic_read(&fscache_n_no_create_space),
94 atomic_read(&fscache_n_culled));
David Howells3929eca2021-10-21 21:58:29 +010095
David Howells8e7a8672021-10-20 23:06:16 +010096 seq_printf(m, "IO : rd=%u wr=%u\n",
97 atomic_read(&fscache_n_read),
98 atomic_read(&fscache_n_write));
99
David Howells1e1236b2021-10-20 14:34:41 +0100100 netfs_stats_show(m);
101 return 0;
102}