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 | |
| 38 | /* |
David Howells | 1e1236b | 2021-10-20 14:34:41 +0100 | [diff] [blame] | 39 | * display the general statistics |
| 40 | */ |
| 41 | int fscache_stats_show(struct seq_file *m, void *v) |
| 42 | { |
| 43 | seq_puts(m, "FS-Cache statistics\n"); |
David Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 44 | seq_printf(m, "Cookies: n=%d v=%d vcol=%u voom=%u\n", |
| 45 | atomic_read(&fscache_n_cookies), |
David Howells | 62ab633 | 2021-10-20 15:26:17 +0100 | [diff] [blame] | 46 | atomic_read(&fscache_n_volumes), |
| 47 | atomic_read(&fscache_n_volumes_collision), |
| 48 | atomic_read(&fscache_n_volumes_nomem) |
| 49 | ); |
David Howells | 1e1236b | 2021-10-20 14:34:41 +0100 | [diff] [blame] | 50 | |
David Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 51 | 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 Howells | 12bb21a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 56 | 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 Howells | d24af13 | 2021-10-20 15:53:34 +0100 | [diff] [blame^] | 64 | seq_printf(m, "Invals : n=%u\n", |
| 65 | atomic_read(&fscache_n_invalidates)); |
| 66 | |
David Howells | 7f3283a | 2021-10-20 15:53:34 +0100 | [diff] [blame] | 67 | 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 Howells | 1e1236b | 2021-10-20 14:34:41 +0100 | [diff] [blame] | 75 | netfs_stats_show(m); |
| 76 | return 0; |
| 77 | } |