1/* FS-Cache statistics 2 * 3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 4 * Written by David Howells (dhowells@redhat.com) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 9 * 2 of the License, or (at your option) any later version. 10 */ 11 12#define FSCACHE_DEBUG_LEVEL THREAD 13#include <linux/module.h> 14#include <linux/proc_fs.h> 15#include <linux/seq_file.h> 16#include "internal.h" 17 18/* 19 * operation counters 20 */ 21atomic_t fscache_n_op_pend; 22atomic_t fscache_n_op_run; 23atomic_t fscache_n_op_enqueue; 24atomic_t fscache_n_op_requeue; 25atomic_t fscache_n_op_deferred_release; 26atomic_t fscache_n_op_initialised; 27atomic_t fscache_n_op_release; 28atomic_t fscache_n_op_gc; 29atomic_t fscache_n_op_cancelled; 30atomic_t fscache_n_op_rejected; 31 32atomic_t fscache_n_attr_changed; 33atomic_t fscache_n_attr_changed_ok; 34atomic_t fscache_n_attr_changed_nobufs; 35atomic_t fscache_n_attr_changed_nomem; 36atomic_t fscache_n_attr_changed_calls; 37 38atomic_t fscache_n_allocs; 39atomic_t fscache_n_allocs_ok; 40atomic_t fscache_n_allocs_wait; 41atomic_t fscache_n_allocs_nobufs; 42atomic_t fscache_n_allocs_intr; 43atomic_t fscache_n_allocs_object_dead; 44atomic_t fscache_n_alloc_ops; 45atomic_t fscache_n_alloc_op_waits; 46 47atomic_t fscache_n_retrievals; 48atomic_t fscache_n_retrievals_ok; 49atomic_t fscache_n_retrievals_wait; 50atomic_t fscache_n_retrievals_nodata; 51atomic_t fscache_n_retrievals_nobufs; 52atomic_t fscache_n_retrievals_intr; 53atomic_t fscache_n_retrievals_nomem; 54atomic_t fscache_n_retrievals_object_dead; 55atomic_t fscache_n_retrieval_ops; 56atomic_t fscache_n_retrieval_op_waits; 57 58atomic_t fscache_n_stores; 59atomic_t fscache_n_stores_ok; 60atomic_t fscache_n_stores_again; 61atomic_t fscache_n_stores_nobufs; 62atomic_t fscache_n_stores_oom; 63atomic_t fscache_n_store_ops; 64atomic_t fscache_n_store_calls; 65atomic_t fscache_n_store_pages; 66atomic_t fscache_n_store_radix_deletes; 67atomic_t fscache_n_store_pages_over_limit; 68 69atomic_t fscache_n_store_vmscan_not_storing; 70atomic_t fscache_n_store_vmscan_gone; 71atomic_t fscache_n_store_vmscan_busy; 72atomic_t fscache_n_store_vmscan_cancelled; 73atomic_t fscache_n_store_vmscan_wait; 74 75atomic_t fscache_n_marks; 76atomic_t fscache_n_uncaches; 77 78atomic_t fscache_n_acquires; 79atomic_t fscache_n_acquires_null; 80atomic_t fscache_n_acquires_no_cache; 81atomic_t fscache_n_acquires_ok; 82atomic_t fscache_n_acquires_nobufs; 83atomic_t fscache_n_acquires_oom; 84 85atomic_t fscache_n_invalidates; 86atomic_t fscache_n_invalidates_run; 87 88atomic_t fscache_n_updates; 89atomic_t fscache_n_updates_null; 90atomic_t fscache_n_updates_run; 91 92atomic_t fscache_n_relinquishes; 93atomic_t fscache_n_relinquishes_null; 94atomic_t fscache_n_relinquishes_waitcrt; 95atomic_t fscache_n_relinquishes_retire; 96 97atomic_t fscache_n_cookie_index; 98atomic_t fscache_n_cookie_data; 99atomic_t fscache_n_cookie_special; 100 101atomic_t fscache_n_object_alloc; 102atomic_t fscache_n_object_no_alloc; 103atomic_t fscache_n_object_lookups; 104atomic_t fscache_n_object_lookups_negative; 105atomic_t fscache_n_object_lookups_positive; 106atomic_t fscache_n_object_lookups_timed_out; 107atomic_t fscache_n_object_created; 108atomic_t fscache_n_object_avail; 109atomic_t fscache_n_object_dead; 110 111atomic_t fscache_n_checkaux_none; 112atomic_t fscache_n_checkaux_okay; 113atomic_t fscache_n_checkaux_update; 114atomic_t fscache_n_checkaux_obsolete; 115 116atomic_t fscache_n_cop_alloc_object; 117atomic_t fscache_n_cop_lookup_object; 118atomic_t fscache_n_cop_lookup_complete; 119atomic_t fscache_n_cop_grab_object; 120atomic_t fscache_n_cop_invalidate_object; 121atomic_t fscache_n_cop_update_object; 122atomic_t fscache_n_cop_drop_object; 123atomic_t fscache_n_cop_put_object; 124atomic_t fscache_n_cop_sync_cache; 125atomic_t fscache_n_cop_attr_changed; 126atomic_t fscache_n_cop_read_or_alloc_page; 127atomic_t fscache_n_cop_read_or_alloc_pages; 128atomic_t fscache_n_cop_allocate_page; 129atomic_t fscache_n_cop_allocate_pages; 130atomic_t fscache_n_cop_write_page; 131atomic_t fscache_n_cop_uncache_page; 132atomic_t fscache_n_cop_dissociate_pages; 133 134atomic_t fscache_n_cache_no_space_reject; 135atomic_t fscache_n_cache_stale_objects; 136atomic_t fscache_n_cache_retired_objects; 137atomic_t fscache_n_cache_culled_objects; 138 139/* 140 * display the general statistics 141 */ 142static int fscache_stats_show(struct seq_file *m, void *v) 143{ 144 seq_puts(m, "FS-Cache statistics\n"); 145 146 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n", 147 atomic_read(&fscache_n_cookie_index), 148 atomic_read(&fscache_n_cookie_data), 149 atomic_read(&fscache_n_cookie_special)); 150 151 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n", 152 atomic_read(&fscache_n_object_alloc), 153 atomic_read(&fscache_n_object_no_alloc), 154 atomic_read(&fscache_n_object_avail), 155 atomic_read(&fscache_n_object_dead)); 156 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n", 157 atomic_read(&fscache_n_checkaux_none), 158 atomic_read(&fscache_n_checkaux_okay), 159 atomic_read(&fscache_n_checkaux_update), 160 atomic_read(&fscache_n_checkaux_obsolete)); 161 162 seq_printf(m, "Pages : mrk=%u unc=%u\n", 163 atomic_read(&fscache_n_marks), 164 atomic_read(&fscache_n_uncaches)); 165 166 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u" 167 " oom=%u\n", 168 atomic_read(&fscache_n_acquires), 169 atomic_read(&fscache_n_acquires_null), 170 atomic_read(&fscache_n_acquires_no_cache), 171 atomic_read(&fscache_n_acquires_ok), 172 atomic_read(&fscache_n_acquires_nobufs), 173 atomic_read(&fscache_n_acquires_oom)); 174 175 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n", 176 atomic_read(&fscache_n_object_lookups), 177 atomic_read(&fscache_n_object_lookups_negative), 178 atomic_read(&fscache_n_object_lookups_positive), 179 atomic_read(&fscache_n_object_created), 180 atomic_read(&fscache_n_object_lookups_timed_out)); 181 182 seq_printf(m, "Invals : n=%u run=%u\n", 183 atomic_read(&fscache_n_invalidates), 184 atomic_read(&fscache_n_invalidates_run)); 185 186 seq_printf(m, "Updates: n=%u nul=%u run=%u\n", 187 atomic_read(&fscache_n_updates), 188 atomic_read(&fscache_n_updates_null), 189 atomic_read(&fscache_n_updates_run)); 190 191 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n", 192 atomic_read(&fscache_n_relinquishes), 193 atomic_read(&fscache_n_relinquishes_null), 194 atomic_read(&fscache_n_relinquishes_waitcrt), 195 atomic_read(&fscache_n_relinquishes_retire)); 196 197 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n", 198 atomic_read(&fscache_n_attr_changed), 199 atomic_read(&fscache_n_attr_changed_ok), 200 atomic_read(&fscache_n_attr_changed_nobufs), 201 atomic_read(&fscache_n_attr_changed_nomem), 202 atomic_read(&fscache_n_attr_changed_calls)); 203 204 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n", 205 atomic_read(&fscache_n_allocs), 206 atomic_read(&fscache_n_allocs_ok), 207 atomic_read(&fscache_n_allocs_wait), 208 atomic_read(&fscache_n_allocs_nobufs), 209 atomic_read(&fscache_n_allocs_intr)); 210 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n", 211 atomic_read(&fscache_n_alloc_ops), 212 atomic_read(&fscache_n_alloc_op_waits), 213 atomic_read(&fscache_n_allocs_object_dead)); 214 215 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u" 216 " int=%u oom=%u\n", 217 atomic_read(&fscache_n_retrievals), 218 atomic_read(&fscache_n_retrievals_ok), 219 atomic_read(&fscache_n_retrievals_wait), 220 atomic_read(&fscache_n_retrievals_nodata), 221 atomic_read(&fscache_n_retrievals_nobufs), 222 atomic_read(&fscache_n_retrievals_intr), 223 atomic_read(&fscache_n_retrievals_nomem)); 224 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n", 225 atomic_read(&fscache_n_retrieval_ops), 226 atomic_read(&fscache_n_retrieval_op_waits), 227 atomic_read(&fscache_n_retrievals_object_dead)); 228 229 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n", 230 atomic_read(&fscache_n_stores), 231 atomic_read(&fscache_n_stores_ok), 232 atomic_read(&fscache_n_stores_again), 233 atomic_read(&fscache_n_stores_nobufs), 234 atomic_read(&fscache_n_stores_oom)); 235 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n", 236 atomic_read(&fscache_n_store_ops), 237 atomic_read(&fscache_n_store_calls), 238 atomic_read(&fscache_n_store_pages), 239 atomic_read(&fscache_n_store_radix_deletes), 240 atomic_read(&fscache_n_store_pages_over_limit)); 241 242 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n", 243 atomic_read(&fscache_n_store_vmscan_not_storing), 244 atomic_read(&fscache_n_store_vmscan_gone), 245 atomic_read(&fscache_n_store_vmscan_busy), 246 atomic_read(&fscache_n_store_vmscan_cancelled), 247 atomic_read(&fscache_n_store_vmscan_wait)); 248 249 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n", 250 atomic_read(&fscache_n_op_pend), 251 atomic_read(&fscache_n_op_run), 252 atomic_read(&fscache_n_op_enqueue), 253 atomic_read(&fscache_n_op_cancelled), 254 atomic_read(&fscache_n_op_rejected)); 255 seq_printf(m, "Ops : ini=%u dfr=%u rel=%u gc=%u\n", 256 atomic_read(&fscache_n_op_initialised), 257 atomic_read(&fscache_n_op_deferred_release), 258 atomic_read(&fscache_n_op_release), 259 atomic_read(&fscache_n_op_gc)); 260 261 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n", 262 atomic_read(&fscache_n_cop_alloc_object), 263 atomic_read(&fscache_n_cop_lookup_object), 264 atomic_read(&fscache_n_cop_lookup_complete), 265 atomic_read(&fscache_n_cop_grab_object)); 266 seq_printf(m, "CacheOp: inv=%d upo=%d dro=%d pto=%d atc=%d syn=%d\n", 267 atomic_read(&fscache_n_cop_invalidate_object), 268 atomic_read(&fscache_n_cop_update_object), 269 atomic_read(&fscache_n_cop_drop_object), 270 atomic_read(&fscache_n_cop_put_object), 271 atomic_read(&fscache_n_cop_attr_changed), 272 atomic_read(&fscache_n_cop_sync_cache)); 273 seq_printf(m, "CacheOp: rap=%d ras=%d alp=%d als=%d wrp=%d ucp=%d dsp=%d\n", 274 atomic_read(&fscache_n_cop_read_or_alloc_page), 275 atomic_read(&fscache_n_cop_read_or_alloc_pages), 276 atomic_read(&fscache_n_cop_allocate_page), 277 atomic_read(&fscache_n_cop_allocate_pages), 278 atomic_read(&fscache_n_cop_write_page), 279 atomic_read(&fscache_n_cop_uncache_page), 280 atomic_read(&fscache_n_cop_dissociate_pages)); 281 seq_printf(m, "CacheEv: nsp=%d stl=%d rtr=%d cul=%d\n", 282 atomic_read(&fscache_n_cache_no_space_reject), 283 atomic_read(&fscache_n_cache_stale_objects), 284 atomic_read(&fscache_n_cache_retired_objects), 285 atomic_read(&fscache_n_cache_culled_objects)); 286 return 0; 287} 288 289/* 290 * open "/proc/fs/fscache/stats" allowing provision of a statistical summary 291 */ 292static int fscache_stats_open(struct inode *inode, struct file *file) 293{ 294 return single_open(file, fscache_stats_show, NULL); 295} 296 297const struct file_operations fscache_stats_fops = { 298 .owner = THIS_MODULE, 299 .open = fscache_stats_open, 300 .read = seq_read, 301 .llseek = seq_lseek, 302 .release = single_release, 303}; 304