David Howells | 1e1236b | 2021-10-20 14:34:41 +0100 | [diff] [blame] | 1 | // 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 Howells | 62ab633 | 2021-10-20 15:26:17 +0100 | [diff] [blame] | 14 | * operation counters |
| 15 | */ |
| 16 | atomic_t fscache_n_volumes; |
| 17 | atomic_t fscache_n_volumes_collision; |
| 18 | atomic_t fscache_n_volumes_nomem; |
David Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 19 | atomic_t fscache_n_cookies; |
David Howells | 12bb21a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 20 | atomic_t fscache_n_cookies_lru; |
| 21 | atomic_t fscache_n_cookies_lru_expired; |
| 22 | atomic_t fscache_n_cookies_lru_removed; |
| 23 | atomic_t fscache_n_cookies_lru_dropped; |
David Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 24 | |
| 25 | atomic_t fscache_n_acquires; |
| 26 | atomic_t fscache_n_acquires_ok; |
| 27 | atomic_t fscache_n_acquires_oom; |
| 28 | |
David Howells | d24af13 | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 29 | atomic_t fscache_n_invalidates; |
| 30 | |
David Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 31 | atomic_t fscache_n_updates; |
| 32 | EXPORT_SYMBOL(fscache_n_updates); |
| 33 | |
| 34 | atomic_t fscache_n_relinquishes; |
| 35 | atomic_t fscache_n_relinquishes_retire; |
| 36 | atomic_t fscache_n_relinquishes_dropped; |
David Howells | 62ab633 | 2021-10-20 15:26:17 +0100 | [diff] [blame] | 37 | |
David Howells | 16a96bd | 2021-10-20 14:06:34 +0100 | [diff] [blame] | 38 | atomic_t fscache_n_resizes; |
| 39 | atomic_t fscache_n_resizes_null; |
| 40 | |
David Howells | 8e7a867 | 2021-10-20 23:06:16 +0100 | [diff] [blame] | 41 | atomic_t fscache_n_read; |
| 42 | EXPORT_SYMBOL(fscache_n_read); |
| 43 | atomic_t fscache_n_write; |
| 44 | EXPORT_SYMBOL(fscache_n_write); |
David Howells | 3929eca | 2021-10-21 21:58:29 +0100 | [diff] [blame] | 45 | atomic_t fscache_n_no_write_space; |
| 46 | EXPORT_SYMBOL(fscache_n_no_write_space); |
| 47 | atomic_t fscache_n_no_create_space; |
| 48 | EXPORT_SYMBOL(fscache_n_no_create_space); |
David Howells | 9f08ebc | 2021-10-22 09:17:58 +0100 | [diff] [blame] | 49 | atomic_t fscache_n_culled; |
| 50 | EXPORT_SYMBOL(fscache_n_culled); |
David Howells | 8e7a867 | 2021-10-20 23:06:16 +0100 | [diff] [blame] | 51 | |
David Howells | 62ab633 | 2021-10-20 15:26:17 +0100 | [diff] [blame] | 52 | /* |
David Howells | 1e1236b | 2021-10-20 14:34:41 +0100 | [diff] [blame] | 53 | * display the general statistics |
| 54 | */ |
| 55 | int fscache_stats_show(struct seq_file *m, void *v) |
| 56 | { |
| 57 | seq_puts(m, "FS-Cache statistics\n"); |
David Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 58 | seq_printf(m, "Cookies: n=%d v=%d vcol=%u voom=%u\n", |
| 59 | atomic_read(&fscache_n_cookies), |
David Howells | 62ab633 | 2021-10-20 15:26:17 +0100 | [diff] [blame] | 60 | atomic_read(&fscache_n_volumes), |
| 61 | atomic_read(&fscache_n_volumes_collision), |
| 62 | atomic_read(&fscache_n_volumes_nomem) |
| 63 | ); |
David Howells | 1e1236b | 2021-10-20 14:34:41 +0100 | [diff] [blame] | 64 | |
David Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 65 | 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 Howells | 12bb21a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 70 | 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 Howells | d24af13 | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 78 | seq_printf(m, "Invals : n=%u\n", |
| 79 | atomic_read(&fscache_n_invalidates)); |
| 80 | |
David Howells | 16a96bd | 2021-10-20 14:06:34 +0100 | [diff] [blame] | 81 | 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 Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 85 | |
| 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 Howells | 9f08ebc | 2021-10-22 09:17:58 +0100 | [diff] [blame] | 91 | seq_printf(m, "NoSpace: nwr=%u ncr=%u cull=%u\n", |
David Howells | 3929eca | 2021-10-21 21:58:29 +0100 | [diff] [blame] | 92 | atomic_read(&fscache_n_no_write_space), |
David Howells | 9f08ebc | 2021-10-22 09:17:58 +0100 | [diff] [blame] | 93 | atomic_read(&fscache_n_no_create_space), |
| 94 | atomic_read(&fscache_n_culled)); |
David Howells | 3929eca | 2021-10-21 21:58:29 +0100 | [diff] [blame] | 95 | |
David Howells | 8e7a867 | 2021-10-20 23:06:16 +0100 | [diff] [blame] | 96 | seq_printf(m, "IO : rd=%u wr=%u\n", |
| 97 | atomic_read(&fscache_n_read), |
| 98 | atomic_read(&fscache_n_write)); |
| 99 | |
David Howells | 1e1236b | 2021-10-20 14:34:41 +0100 | [diff] [blame] | 100 | netfs_stats_show(m); |
| 101 | return 0; |
| 102 | } |