stats.c 10.0 KB

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