stats.c 10 KB

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