xfs_stats.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_STATS_H__
  7. #define __XFS_STATS_H__
  8. #include <linux/percpu.h>
  9. /*
  10. * The btree stats arrays have fixed offsets for the different stats. We
  11. * store the base index in the btree cursor via XFS_STATS_CALC_INDEX() and
  12. * that allows us to use fixed offsets into the stats array for each btree
  13. * stat. These index offsets are defined in the order they will be emitted
  14. * in the stats files, so it is possible to add new btree stat types by
  15. * appending to the enum list below.
  16. */
  17. enum {
  18. __XBTS_lookup = 0,
  19. __XBTS_compare = 1,
  20. __XBTS_insrec = 2,
  21. __XBTS_delrec = 3,
  22. __XBTS_newroot = 4,
  23. __XBTS_killroot = 5,
  24. __XBTS_increment = 6,
  25. __XBTS_decrement = 7,
  26. __XBTS_lshift = 8,
  27. __XBTS_rshift = 9,
  28. __XBTS_split = 10,
  29. __XBTS_join = 11,
  30. __XBTS_alloc = 12,
  31. __XBTS_free = 13,
  32. __XBTS_moves = 14,
  33. __XBTS_MAX = 15,
  34. };
  35. /*
  36. * XFS global statistics
  37. */
  38. struct __xfsstats {
  39. uint32_t xs_allocx;
  40. uint32_t xs_allocb;
  41. uint32_t xs_freex;
  42. uint32_t xs_freeb;
  43. uint32_t xs_abt_lookup;
  44. uint32_t xs_abt_compare;
  45. uint32_t xs_abt_insrec;
  46. uint32_t xs_abt_delrec;
  47. uint32_t xs_blk_mapr;
  48. uint32_t xs_blk_mapw;
  49. uint32_t xs_blk_unmap;
  50. uint32_t xs_add_exlist;
  51. uint32_t xs_del_exlist;
  52. uint32_t xs_look_exlist;
  53. uint32_t xs_cmp_exlist;
  54. uint32_t xs_bmbt_lookup;
  55. uint32_t xs_bmbt_compare;
  56. uint32_t xs_bmbt_insrec;
  57. uint32_t xs_bmbt_delrec;
  58. uint32_t xs_dir_lookup;
  59. uint32_t xs_dir_create;
  60. uint32_t xs_dir_remove;
  61. uint32_t xs_dir_getdents;
  62. uint32_t xs_trans_sync;
  63. uint32_t xs_trans_async;
  64. uint32_t xs_trans_empty;
  65. uint32_t xs_ig_attempts;
  66. uint32_t xs_ig_found;
  67. uint32_t xs_ig_frecycle;
  68. uint32_t xs_ig_missed;
  69. uint32_t xs_ig_dup;
  70. uint32_t xs_ig_reclaims;
  71. uint32_t xs_ig_attrchg;
  72. uint32_t xs_log_writes;
  73. uint32_t xs_log_blocks;
  74. uint32_t xs_log_noiclogs;
  75. uint32_t xs_log_force;
  76. uint32_t xs_log_force_sleep;
  77. uint32_t xs_try_logspace;
  78. uint32_t xs_sleep_logspace;
  79. uint32_t xs_push_ail;
  80. uint32_t xs_push_ail_success;
  81. uint32_t xs_push_ail_pushbuf;
  82. uint32_t xs_push_ail_pinned;
  83. uint32_t xs_push_ail_locked;
  84. uint32_t xs_push_ail_flushing;
  85. uint32_t xs_push_ail_restarts;
  86. uint32_t xs_push_ail_flush;
  87. uint32_t xs_xstrat_quick;
  88. uint32_t xs_xstrat_split;
  89. uint32_t xs_write_calls;
  90. uint32_t xs_read_calls;
  91. uint32_t xs_attr_get;
  92. uint32_t xs_attr_set;
  93. uint32_t xs_attr_remove;
  94. uint32_t xs_attr_list;
  95. uint32_t xs_iflush_count;
  96. uint32_t xs_icluster_flushcnt;
  97. uint32_t xs_icluster_flushinode;
  98. uint32_t vn_active; /* # vnodes not on free lists */
  99. uint32_t vn_alloc; /* # times vn_alloc called */
  100. uint32_t vn_get; /* # times vn_get called */
  101. uint32_t vn_hold; /* # times vn_hold called */
  102. uint32_t vn_rele; /* # times vn_rele called */
  103. uint32_t vn_reclaim; /* # times vn_reclaim called */
  104. uint32_t vn_remove; /* # times vn_remove called */
  105. uint32_t vn_free; /* # times vn_free called */
  106. uint32_t xb_get;
  107. uint32_t xb_create;
  108. uint32_t xb_get_locked;
  109. uint32_t xb_get_locked_waited;
  110. uint32_t xb_busy_locked;
  111. uint32_t xb_miss_locked;
  112. uint32_t xb_page_retries;
  113. uint32_t xb_page_found;
  114. uint32_t xb_get_read;
  115. /* Version 2 btree counters */
  116. uint32_t xs_abtb_2[__XBTS_MAX];
  117. uint32_t xs_abtc_2[__XBTS_MAX];
  118. uint32_t xs_bmbt_2[__XBTS_MAX];
  119. uint32_t xs_ibt_2[__XBTS_MAX];
  120. uint32_t xs_fibt_2[__XBTS_MAX];
  121. uint32_t xs_rmap_2[__XBTS_MAX];
  122. uint32_t xs_refcbt_2[__XBTS_MAX];
  123. uint32_t xs_qm_dqreclaims;
  124. uint32_t xs_qm_dqreclaim_misses;
  125. uint32_t xs_qm_dquot_dups;
  126. uint32_t xs_qm_dqcachemisses;
  127. uint32_t xs_qm_dqcachehits;
  128. uint32_t xs_qm_dqwants;
  129. uint32_t xs_qm_dquot;
  130. uint32_t xs_qm_dquot_unused;
  131. /* Extra precision counters */
  132. uint64_t xs_xstrat_bytes;
  133. uint64_t xs_write_bytes;
  134. uint64_t xs_read_bytes;
  135. uint64_t defer_relog;
  136. };
  137. #define xfsstats_offset(f) (offsetof(struct __xfsstats, f)/sizeof(uint32_t))
  138. struct xfsstats {
  139. union {
  140. struct __xfsstats s;
  141. uint32_t a[xfsstats_offset(xs_qm_dquot)];
  142. };
  143. };
  144. /*
  145. * simple wrapper for getting the array index of s struct member offset
  146. */
  147. #define XFS_STATS_CALC_INDEX(member) \
  148. (offsetof(struct __xfsstats, member) / (int)sizeof(uint32_t))
  149. int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
  150. void xfs_stats_clearall(struct xfsstats __percpu *stats);
  151. extern struct xstats xfsstats;
  152. #define XFS_STATS_INC(mp, v) \
  153. do { \
  154. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v++; \
  155. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v++; \
  156. } while (0)
  157. #define XFS_STATS_DEC(mp, v) \
  158. do { \
  159. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v--; \
  160. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v--; \
  161. } while (0)
  162. #define XFS_STATS_ADD(mp, v, inc) \
  163. do { \
  164. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v += (inc); \
  165. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v += (inc); \
  166. } while (0)
  167. #define XFS_STATS_INC_OFF(mp, off) \
  168. do { \
  169. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off]++; \
  170. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off]++; \
  171. } while (0)
  172. #define XFS_STATS_DEC_OFF(mp, off) \
  173. do { \
  174. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off]; \
  175. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off]; \
  176. } while (0)
  177. #define XFS_STATS_ADD_OFF(mp, off, inc) \
  178. do { \
  179. per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off] += (inc); \
  180. per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off] += (inc); \
  181. } while (0)
  182. #if defined(CONFIG_PROC_FS)
  183. extern int xfs_init_procfs(void);
  184. extern void xfs_cleanup_procfs(void);
  185. #else /* !CONFIG_PROC_FS */
  186. static inline int xfs_init_procfs(void)
  187. {
  188. return 0;
  189. }
  190. static inline void xfs_cleanup_procfs(void)
  191. {
  192. }
  193. #endif /* !CONFIG_PROC_FS */
  194. #endif /* __XFS_STATS_H__ */