blob: cdbb672a274f834d76aadfe94219c6ddbec106df [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
38/*
David Howells1e1236b2021-10-20 14:34:41 +010039 * display the general statistics
40 */
41int fscache_stats_show(struct seq_file *m, void *v)
42{
43 seq_puts(m, "FS-Cache statistics\n");
David Howells7f3283a2021-10-20 15:53:34 +010044 seq_printf(m, "Cookies: n=%d v=%d vcol=%u voom=%u\n",
45 atomic_read(&fscache_n_cookies),
David Howells62ab6332021-10-20 15:26:17 +010046 atomic_read(&fscache_n_volumes),
47 atomic_read(&fscache_n_volumes_collision),
48 atomic_read(&fscache_n_volumes_nomem)
49 );
David Howells1e1236b2021-10-20 14:34:41 +010050
David Howells7f3283a2021-10-20 15:53:34 +010051 seq_printf(m, "Acquire: n=%u ok=%u oom=%u\n",
52 atomic_read(&fscache_n_acquires),
53 atomic_read(&fscache_n_acquires_ok),
54 atomic_read(&fscache_n_acquires_oom));
55
David Howells12bb21a2021-10-20 15:53:34 +010056 seq_printf(m, "LRU : n=%u exp=%u rmv=%u drp=%u at=%ld\n",
57 atomic_read(&fscache_n_cookies_lru),
58 atomic_read(&fscache_n_cookies_lru_expired),
59 atomic_read(&fscache_n_cookies_lru_removed),
60 atomic_read(&fscache_n_cookies_lru_dropped),
61 timer_pending(&fscache_cookie_lru_timer) ?
62 fscache_cookie_lru_timer.expires - jiffies : 0);
63
David Howellsd24af132021-10-20 15:53:34 +010064 seq_printf(m, "Invals : n=%u\n",
65 atomic_read(&fscache_n_invalidates));
66
David Howells7f3283a2021-10-20 15:53:34 +010067 seq_printf(m, "Updates: n=%u\n",
68 atomic_read(&fscache_n_updates));
69
70 seq_printf(m, "Relinqs: n=%u rtr=%u drop=%u\n",
71 atomic_read(&fscache_n_relinquishes),
72 atomic_read(&fscache_n_relinquishes_retire),
73 atomic_read(&fscache_n_relinquishes_dropped));
74
David Howells1e1236b2021-10-20 14:34:41 +010075 netfs_stats_show(m);
76 return 0;
77}