xref: /openbmc/linux/fs/fscache/stats.c (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
11e1236b8SDavid Howells // SPDX-License-Identifier: GPL-2.0-or-later
21e1236b8SDavid Howells /* FS-Cache statistics
31e1236b8SDavid Howells  *
41e1236b8SDavid Howells  * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved.
51e1236b8SDavid Howells  * Written by David Howells (dhowells@redhat.com)
61e1236b8SDavid Howells  */
71e1236b8SDavid Howells 
81e1236b8SDavid Howells #define FSCACHE_DEBUG_LEVEL CACHE
91e1236b8SDavid Howells #include <linux/proc_fs.h>
101e1236b8SDavid Howells #include <linux/seq_file.h>
111e1236b8SDavid Howells #include "internal.h"
121e1236b8SDavid Howells 
131e1236b8SDavid Howells /*
1462ab6335SDavid Howells  * operation counters
1562ab6335SDavid Howells  */
1662ab6335SDavid Howells atomic_t fscache_n_volumes;
1762ab6335SDavid Howells atomic_t fscache_n_volumes_collision;
1862ab6335SDavid Howells atomic_t fscache_n_volumes_nomem;
197f3283abSDavid Howells atomic_t fscache_n_cookies;
2012bb21a2SDavid Howells atomic_t fscache_n_cookies_lru;
2112bb21a2SDavid Howells atomic_t fscache_n_cookies_lru_expired;
2212bb21a2SDavid Howells atomic_t fscache_n_cookies_lru_removed;
2312bb21a2SDavid Howells atomic_t fscache_n_cookies_lru_dropped;
247f3283abSDavid Howells 
257f3283abSDavid Howells atomic_t fscache_n_acquires;
267f3283abSDavid Howells atomic_t fscache_n_acquires_ok;
277f3283abSDavid Howells atomic_t fscache_n_acquires_oom;
287f3283abSDavid Howells 
29d24af13eSDavid Howells atomic_t fscache_n_invalidates;
30d24af13eSDavid Howells 
317f3283abSDavid Howells atomic_t fscache_n_updates;
327f3283abSDavid Howells EXPORT_SYMBOL(fscache_n_updates);
337f3283abSDavid Howells 
347f3283abSDavid Howells atomic_t fscache_n_relinquishes;
357f3283abSDavid Howells atomic_t fscache_n_relinquishes_retire;
367f3283abSDavid Howells atomic_t fscache_n_relinquishes_dropped;
3762ab6335SDavid Howells 
3816a96bdfSDavid Howells atomic_t fscache_n_resizes;
3916a96bdfSDavid Howells atomic_t fscache_n_resizes_null;
4016a96bdfSDavid Howells 
418e7a867bSDavid Howells atomic_t fscache_n_read;
428e7a867bSDavid Howells EXPORT_SYMBOL(fscache_n_read);
438e7a867bSDavid Howells atomic_t fscache_n_write;
448e7a867bSDavid Howells EXPORT_SYMBOL(fscache_n_write);
453929eca7SDavid Howells atomic_t fscache_n_no_write_space;
463929eca7SDavid Howells EXPORT_SYMBOL(fscache_n_no_write_space);
473929eca7SDavid Howells atomic_t fscache_n_no_create_space;
483929eca7SDavid Howells EXPORT_SYMBOL(fscache_n_no_create_space);
49*9f08ebc3SDavid Howells atomic_t fscache_n_culled;
50*9f08ebc3SDavid Howells EXPORT_SYMBOL(fscache_n_culled);
518e7a867bSDavid Howells 
5262ab6335SDavid Howells /*
531e1236b8SDavid Howells  * display the general statistics
541e1236b8SDavid Howells  */
fscache_stats_show(struct seq_file * m,void * v)551e1236b8SDavid Howells int fscache_stats_show(struct seq_file *m, void *v)
561e1236b8SDavid Howells {
571e1236b8SDavid Howells 	seq_puts(m, "FS-Cache statistics\n");
587f3283abSDavid Howells 	seq_printf(m, "Cookies: n=%d v=%d vcol=%u voom=%u\n",
597f3283abSDavid Howells 		   atomic_read(&fscache_n_cookies),
6062ab6335SDavid Howells 		   atomic_read(&fscache_n_volumes),
6162ab6335SDavid Howells 		   atomic_read(&fscache_n_volumes_collision),
6262ab6335SDavid Howells 		   atomic_read(&fscache_n_volumes_nomem)
6362ab6335SDavid Howells 		   );
641e1236b8SDavid Howells 
657f3283abSDavid Howells 	seq_printf(m, "Acquire: n=%u ok=%u oom=%u\n",
667f3283abSDavid Howells 		   atomic_read(&fscache_n_acquires),
677f3283abSDavid Howells 		   atomic_read(&fscache_n_acquires_ok),
687f3283abSDavid Howells 		   atomic_read(&fscache_n_acquires_oom));
697f3283abSDavid Howells 
7012bb21a2SDavid Howells 	seq_printf(m, "LRU    : n=%u exp=%u rmv=%u drp=%u at=%ld\n",
7112bb21a2SDavid Howells 		   atomic_read(&fscache_n_cookies_lru),
7212bb21a2SDavid Howells 		   atomic_read(&fscache_n_cookies_lru_expired),
7312bb21a2SDavid Howells 		   atomic_read(&fscache_n_cookies_lru_removed),
7412bb21a2SDavid Howells 		   atomic_read(&fscache_n_cookies_lru_dropped),
7512bb21a2SDavid Howells 		   timer_pending(&fscache_cookie_lru_timer) ?
7612bb21a2SDavid Howells 		   fscache_cookie_lru_timer.expires - jiffies : 0);
7712bb21a2SDavid Howells 
78d24af13eSDavid Howells 	seq_printf(m, "Invals : n=%u\n",
79d24af13eSDavid Howells 		   atomic_read(&fscache_n_invalidates));
80d24af13eSDavid Howells 
8116a96bdfSDavid Howells 	seq_printf(m, "Updates: n=%u rsz=%u rsn=%u\n",
8216a96bdfSDavid Howells 		   atomic_read(&fscache_n_updates),
8316a96bdfSDavid Howells 		   atomic_read(&fscache_n_resizes),
8416a96bdfSDavid Howells 		   atomic_read(&fscache_n_resizes_null));
857f3283abSDavid Howells 
867f3283abSDavid Howells 	seq_printf(m, "Relinqs: n=%u rtr=%u drop=%u\n",
877f3283abSDavid Howells 		   atomic_read(&fscache_n_relinquishes),
887f3283abSDavid Howells 		   atomic_read(&fscache_n_relinquishes_retire),
897f3283abSDavid Howells 		   atomic_read(&fscache_n_relinquishes_dropped));
907f3283abSDavid Howells 
91*9f08ebc3SDavid Howells 	seq_printf(m, "NoSpace: nwr=%u ncr=%u cull=%u\n",
923929eca7SDavid Howells 		   atomic_read(&fscache_n_no_write_space),
93*9f08ebc3SDavid Howells 		   atomic_read(&fscache_n_no_create_space),
94*9f08ebc3SDavid Howells 		   atomic_read(&fscache_n_culled));
953929eca7SDavid Howells 
968e7a867bSDavid Howells 	seq_printf(m, "IO     : rd=%u wr=%u\n",
978e7a867bSDavid Howells 		   atomic_read(&fscache_n_read),
988e7a867bSDavid Howells 		   atomic_read(&fscache_n_write));
998e7a867bSDavid Howells 
1001e1236b8SDavid Howells 	netfs_stats_show(m);
1011e1236b8SDavid Howells 	return 0;
1021e1236b8SDavid Howells }
103