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