stats.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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_attr_changed;
  27. atomic_t fscache_n_attr_changed_ok;
  28. atomic_t fscache_n_attr_changed_nobufs;
  29. atomic_t fscache_n_attr_changed_nomem;
  30. atomic_t fscache_n_attr_changed_calls;
  31. atomic_t fscache_n_allocs;
  32. atomic_t fscache_n_allocs_ok;
  33. atomic_t fscache_n_allocs_wait;
  34. atomic_t fscache_n_allocs_nobufs;
  35. atomic_t fscache_n_alloc_ops;
  36. atomic_t fscache_n_alloc_op_waits;
  37. atomic_t fscache_n_retrievals;
  38. atomic_t fscache_n_retrievals_ok;
  39. atomic_t fscache_n_retrievals_wait;
  40. atomic_t fscache_n_retrievals_nodata;
  41. atomic_t fscache_n_retrievals_nobufs;
  42. atomic_t fscache_n_retrievals_intr;
  43. atomic_t fscache_n_retrievals_nomem;
  44. atomic_t fscache_n_retrieval_ops;
  45. atomic_t fscache_n_retrieval_op_waits;
  46. atomic_t fscache_n_stores;
  47. atomic_t fscache_n_stores_ok;
  48. atomic_t fscache_n_stores_again;
  49. atomic_t fscache_n_stores_nobufs;
  50. atomic_t fscache_n_stores_oom;
  51. atomic_t fscache_n_store_ops;
  52. atomic_t fscache_n_store_calls;
  53. atomic_t fscache_n_marks;
  54. atomic_t fscache_n_uncaches;
  55. atomic_t fscache_n_acquires;
  56. atomic_t fscache_n_acquires_null;
  57. atomic_t fscache_n_acquires_no_cache;
  58. atomic_t fscache_n_acquires_ok;
  59. atomic_t fscache_n_acquires_nobufs;
  60. atomic_t fscache_n_acquires_oom;
  61. atomic_t fscache_n_updates;
  62. atomic_t fscache_n_updates_null;
  63. atomic_t fscache_n_updates_run;
  64. atomic_t fscache_n_relinquishes;
  65. atomic_t fscache_n_relinquishes_null;
  66. atomic_t fscache_n_relinquishes_waitcrt;
  67. atomic_t fscache_n_cookie_index;
  68. atomic_t fscache_n_cookie_data;
  69. atomic_t fscache_n_cookie_special;
  70. atomic_t fscache_n_object_alloc;
  71. atomic_t fscache_n_object_no_alloc;
  72. atomic_t fscache_n_object_lookups;
  73. atomic_t fscache_n_object_lookups_negative;
  74. atomic_t fscache_n_object_lookups_positive;
  75. atomic_t fscache_n_object_created;
  76. atomic_t fscache_n_object_avail;
  77. atomic_t fscache_n_object_dead;
  78. atomic_t fscache_n_checkaux_none;
  79. atomic_t fscache_n_checkaux_okay;
  80. atomic_t fscache_n_checkaux_update;
  81. atomic_t fscache_n_checkaux_obsolete;
  82. /*
  83. * display the general statistics
  84. */
  85. static int fscache_stats_show(struct seq_file *m, void *v)
  86. {
  87. seq_puts(m, "FS-Cache statistics\n");
  88. seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
  89. atomic_read(&fscache_n_cookie_index),
  90. atomic_read(&fscache_n_cookie_data),
  91. atomic_read(&fscache_n_cookie_special));
  92. seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
  93. atomic_read(&fscache_n_object_alloc),
  94. atomic_read(&fscache_n_object_no_alloc),
  95. atomic_read(&fscache_n_object_avail),
  96. atomic_read(&fscache_n_object_dead));
  97. seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
  98. atomic_read(&fscache_n_checkaux_none),
  99. atomic_read(&fscache_n_checkaux_okay),
  100. atomic_read(&fscache_n_checkaux_update),
  101. atomic_read(&fscache_n_checkaux_obsolete));
  102. seq_printf(m, "Pages : mrk=%u unc=%u\n",
  103. atomic_read(&fscache_n_marks),
  104. atomic_read(&fscache_n_uncaches));
  105. seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
  106. " oom=%u\n",
  107. atomic_read(&fscache_n_acquires),
  108. atomic_read(&fscache_n_acquires_null),
  109. atomic_read(&fscache_n_acquires_no_cache),
  110. atomic_read(&fscache_n_acquires_ok),
  111. atomic_read(&fscache_n_acquires_nobufs),
  112. atomic_read(&fscache_n_acquires_oom));
  113. seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u\n",
  114. atomic_read(&fscache_n_object_lookups),
  115. atomic_read(&fscache_n_object_lookups_negative),
  116. atomic_read(&fscache_n_object_lookups_positive),
  117. atomic_read(&fscache_n_object_created));
  118. seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
  119. atomic_read(&fscache_n_updates),
  120. atomic_read(&fscache_n_updates_null),
  121. atomic_read(&fscache_n_updates_run));
  122. seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u\n",
  123. atomic_read(&fscache_n_relinquishes),
  124. atomic_read(&fscache_n_relinquishes_null),
  125. atomic_read(&fscache_n_relinquishes_waitcrt));
  126. seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
  127. atomic_read(&fscache_n_attr_changed),
  128. atomic_read(&fscache_n_attr_changed_ok),
  129. atomic_read(&fscache_n_attr_changed_nobufs),
  130. atomic_read(&fscache_n_attr_changed_nomem),
  131. atomic_read(&fscache_n_attr_changed_calls));
  132. seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u\n",
  133. atomic_read(&fscache_n_allocs),
  134. atomic_read(&fscache_n_allocs_ok),
  135. atomic_read(&fscache_n_allocs_wait),
  136. atomic_read(&fscache_n_allocs_nobufs));
  137. seq_printf(m, "Allocs : ops=%u owt=%u\n",
  138. atomic_read(&fscache_n_alloc_ops),
  139. atomic_read(&fscache_n_alloc_op_waits));
  140. seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
  141. " int=%u oom=%u\n",
  142. atomic_read(&fscache_n_retrievals),
  143. atomic_read(&fscache_n_retrievals_ok),
  144. atomic_read(&fscache_n_retrievals_wait),
  145. atomic_read(&fscache_n_retrievals_nodata),
  146. atomic_read(&fscache_n_retrievals_nobufs),
  147. atomic_read(&fscache_n_retrievals_intr),
  148. atomic_read(&fscache_n_retrievals_nomem));
  149. seq_printf(m, "Retrvls: ops=%u owt=%u\n",
  150. atomic_read(&fscache_n_retrieval_ops),
  151. atomic_read(&fscache_n_retrieval_op_waits));
  152. seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
  153. atomic_read(&fscache_n_stores),
  154. atomic_read(&fscache_n_stores_ok),
  155. atomic_read(&fscache_n_stores_again),
  156. atomic_read(&fscache_n_stores_nobufs),
  157. atomic_read(&fscache_n_stores_oom));
  158. seq_printf(m, "Stores : ops=%u run=%u\n",
  159. atomic_read(&fscache_n_store_ops),
  160. atomic_read(&fscache_n_store_calls));
  161. seq_printf(m, "Ops : pend=%u run=%u enq=%u\n",
  162. atomic_read(&fscache_n_op_pend),
  163. atomic_read(&fscache_n_op_run),
  164. atomic_read(&fscache_n_op_enqueue));
  165. seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
  166. atomic_read(&fscache_n_op_deferred_release),
  167. atomic_read(&fscache_n_op_release),
  168. atomic_read(&fscache_n_op_gc));
  169. return 0;
  170. }
  171. /*
  172. * open "/proc/fs/fscache/stats" allowing provision of a statistical summary
  173. */
  174. static int fscache_stats_open(struct inode *inode, struct file *file)
  175. {
  176. return single_open(file, fscache_stats_show, NULL);
  177. }
  178. const struct file_operations fscache_stats_fops = {
  179. .owner = THIS_MODULE,
  180. .open = fscache_stats_open,
  181. .read = seq_read,
  182. .llseek = seq_lseek,
  183. .release = seq_release,
  184. };