stats.c 9.6 KB

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