Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fscache, cachefiles: Display stat of culling events

Add a stat counter of culling events whereby the cache backend culls a file
to make space (when asked by cachefilesd in this case) and display in
/proc/fs/fscache/stats.

Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/163819654165.215744.3797804661644212436.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/163906961387.143852.9291157239960289090.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/163967168266.1823006.14436200166581605746.stgit@warthog.procyon.org.uk/ # v3
Link: https://lore.kernel.org/r/164021567619.640689.4339228906248763197.stgit@warthog.procyon.org.uk/ # v4

+9 -2
+1
fs/cachefiles/namei.c
··· 805 805 if (ret < 0) 806 806 goto error; 807 807 808 + fscache_count_culled(); 808 809 dput(victim); 809 810 _leave(" = 0"); 810 811 return 0;
+5 -2
fs/fscache/stats.c
··· 46 46 EXPORT_SYMBOL(fscache_n_no_write_space); 47 47 atomic_t fscache_n_no_create_space; 48 48 EXPORT_SYMBOL(fscache_n_no_create_space); 49 + atomic_t fscache_n_culled; 50 + EXPORT_SYMBOL(fscache_n_culled); 49 51 50 52 /* 51 53 * display the general statistics ··· 88 86 atomic_read(&fscache_n_relinquishes_retire), 89 87 atomic_read(&fscache_n_relinquishes_dropped)); 90 88 91 - seq_printf(m, "NoSpace: nwr=%u ncr=%u\n", 89 + seq_printf(m, "NoSpace: nwr=%u ncr=%u cull=%u\n", 92 90 atomic_read(&fscache_n_no_write_space), 93 - atomic_read(&fscache_n_no_create_space)); 91 + atomic_read(&fscache_n_no_create_space), 92 + atomic_read(&fscache_n_culled)); 94 93 95 94 seq_printf(m, "IO : rd=%u wr=%u\n", 96 95 atomic_read(&fscache_n_read),
+3
include/linux/fscache-cache.h
··· 188 188 extern atomic_t fscache_n_write; 189 189 extern atomic_t fscache_n_no_write_space; 190 190 extern atomic_t fscache_n_no_create_space; 191 + extern atomic_t fscache_n_culled; 191 192 #define fscache_count_read() atomic_inc(&fscache_n_read) 192 193 #define fscache_count_write() atomic_inc(&fscache_n_write) 193 194 #define fscache_count_no_write_space() atomic_inc(&fscache_n_no_write_space) 194 195 #define fscache_count_no_create_space() atomic_inc(&fscache_n_no_create_space) 196 + #define fscache_count_culled() atomic_inc(&fscache_n_culled) 195 197 #else 196 198 #define fscache_count_read() do {} while(0) 197 199 #define fscache_count_write() do {} while(0) 198 200 #define fscache_count_no_write_space() do {} while(0) 199 201 #define fscache_count_no_create_space() do {} while(0) 202 + #define fscache_count_culled() do {} while(0) 200 203 #endif 201 204 202 205 #endif /* _LINUX_FSCACHE_CACHE_H */