Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 | * This program is distributed in the hope that it would be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write the Free Software Foundation, |
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | #ifndef __XFS_STATS_H__ |
| 19 | #define __XFS_STATS_H__ |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | #include <linux/percpu.h> |
| 23 | |
| 24 | /* |
Dave Chinner | 11ef38a | 2016-12-05 14:38:58 +1100 | [diff] [blame] | 25 | * The btree stats arrays have fixed offsets for the different stats. We |
| 26 | * store the base index in the btree cursor via XFS_STATS_CALC_INDEX() and |
| 27 | * that allows us to use fixed offsets into the stats array for each btree |
| 28 | * stat. These index offsets are defined in the order they will be emitted |
| 29 | * in the stats files, so it is possible to add new btree stat types by |
| 30 | * appending to the enum list below. |
| 31 | */ |
| 32 | enum { |
| 33 | __XBTS_lookup = 0, |
| 34 | __XBTS_compare = 1, |
| 35 | __XBTS_insrec = 2, |
| 36 | __XBTS_delrec = 3, |
| 37 | __XBTS_newroot = 4, |
| 38 | __XBTS_killroot = 5, |
| 39 | __XBTS_increment = 6, |
| 40 | __XBTS_decrement = 7, |
| 41 | __XBTS_lshift = 8, |
| 42 | __XBTS_rshift = 9, |
| 43 | __XBTS_split = 10, |
| 44 | __XBTS_join = 11, |
| 45 | __XBTS_alloc = 12, |
| 46 | __XBTS_free = 13, |
| 47 | __XBTS_moves = 14, |
| 48 | |
| 49 | __XBTS_MAX = 15, |
| 50 | }; |
| 51 | |
| 52 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | * XFS global statistics |
| 54 | */ |
Dave Chinner | 11ef38a | 2016-12-05 14:38:58 +1100 | [diff] [blame] | 55 | struct __xfsstats { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | # define XFSSTAT_END_EXTENT_ALLOC 4 |
| 57 | __uint32_t xs_allocx; |
| 58 | __uint32_t xs_allocb; |
| 59 | __uint32_t xs_freex; |
| 60 | __uint32_t xs_freeb; |
| 61 | # define XFSSTAT_END_ALLOC_BTREE (XFSSTAT_END_EXTENT_ALLOC+4) |
| 62 | __uint32_t xs_abt_lookup; |
| 63 | __uint32_t xs_abt_compare; |
| 64 | __uint32_t xs_abt_insrec; |
| 65 | __uint32_t xs_abt_delrec; |
| 66 | # define XFSSTAT_END_BLOCK_MAPPING (XFSSTAT_END_ALLOC_BTREE+7) |
| 67 | __uint32_t xs_blk_mapr; |
| 68 | __uint32_t xs_blk_mapw; |
| 69 | __uint32_t xs_blk_unmap; |
| 70 | __uint32_t xs_add_exlist; |
| 71 | __uint32_t xs_del_exlist; |
| 72 | __uint32_t xs_look_exlist; |
| 73 | __uint32_t xs_cmp_exlist; |
| 74 | # define XFSSTAT_END_BLOCK_MAP_BTREE (XFSSTAT_END_BLOCK_MAPPING+4) |
| 75 | __uint32_t xs_bmbt_lookup; |
| 76 | __uint32_t xs_bmbt_compare; |
| 77 | __uint32_t xs_bmbt_insrec; |
| 78 | __uint32_t xs_bmbt_delrec; |
| 79 | # define XFSSTAT_END_DIRECTORY_OPS (XFSSTAT_END_BLOCK_MAP_BTREE+4) |
| 80 | __uint32_t xs_dir_lookup; |
| 81 | __uint32_t xs_dir_create; |
| 82 | __uint32_t xs_dir_remove; |
| 83 | __uint32_t xs_dir_getdents; |
| 84 | # define XFSSTAT_END_TRANSACTIONS (XFSSTAT_END_DIRECTORY_OPS+3) |
| 85 | __uint32_t xs_trans_sync; |
| 86 | __uint32_t xs_trans_async; |
| 87 | __uint32_t xs_trans_empty; |
| 88 | # define XFSSTAT_END_INODE_OPS (XFSSTAT_END_TRANSACTIONS+7) |
| 89 | __uint32_t xs_ig_attempts; |
| 90 | __uint32_t xs_ig_found; |
| 91 | __uint32_t xs_ig_frecycle; |
| 92 | __uint32_t xs_ig_missed; |
| 93 | __uint32_t xs_ig_dup; |
| 94 | __uint32_t xs_ig_reclaims; |
| 95 | __uint32_t xs_ig_attrchg; |
| 96 | # define XFSSTAT_END_LOG_OPS (XFSSTAT_END_INODE_OPS+5) |
| 97 | __uint32_t xs_log_writes; |
| 98 | __uint32_t xs_log_blocks; |
| 99 | __uint32_t xs_log_noiclogs; |
| 100 | __uint32_t xs_log_force; |
| 101 | __uint32_t xs_log_force_sleep; |
| 102 | # define XFSSTAT_END_TAIL_PUSHING (XFSSTAT_END_LOG_OPS+10) |
| 103 | __uint32_t xs_try_logspace; |
| 104 | __uint32_t xs_sleep_logspace; |
| 105 | __uint32_t xs_push_ail; |
| 106 | __uint32_t xs_push_ail_success; |
| 107 | __uint32_t xs_push_ail_pushbuf; |
| 108 | __uint32_t xs_push_ail_pinned; |
| 109 | __uint32_t xs_push_ail_locked; |
| 110 | __uint32_t xs_push_ail_flushing; |
| 111 | __uint32_t xs_push_ail_restarts; |
| 112 | __uint32_t xs_push_ail_flush; |
| 113 | # define XFSSTAT_END_WRITE_CONVERT (XFSSTAT_END_TAIL_PUSHING+2) |
| 114 | __uint32_t xs_xstrat_quick; |
| 115 | __uint32_t xs_xstrat_split; |
| 116 | # define XFSSTAT_END_READ_WRITE_OPS (XFSSTAT_END_WRITE_CONVERT+2) |
| 117 | __uint32_t xs_write_calls; |
| 118 | __uint32_t xs_read_calls; |
| 119 | # define XFSSTAT_END_ATTRIBUTE_OPS (XFSSTAT_END_READ_WRITE_OPS+4) |
| 120 | __uint32_t xs_attr_get; |
| 121 | __uint32_t xs_attr_set; |
| 122 | __uint32_t xs_attr_remove; |
| 123 | __uint32_t xs_attr_list; |
| 124 | # define XFSSTAT_END_INODE_CLUSTER (XFSSTAT_END_ATTRIBUTE_OPS+3) |
| 125 | __uint32_t xs_iflush_count; |
| 126 | __uint32_t xs_icluster_flushcnt; |
| 127 | __uint32_t xs_icluster_flushinode; |
| 128 | # define XFSSTAT_END_VNODE_OPS (XFSSTAT_END_INODE_CLUSTER+8) |
| 129 | __uint32_t vn_active; /* # vnodes not on free lists */ |
| 130 | __uint32_t vn_alloc; /* # times vn_alloc called */ |
| 131 | __uint32_t vn_get; /* # times vn_get called */ |
| 132 | __uint32_t vn_hold; /* # times vn_hold called */ |
| 133 | __uint32_t vn_rele; /* # times vn_rele called */ |
| 134 | __uint32_t vn_reclaim; /* # times vn_reclaim called */ |
| 135 | __uint32_t vn_remove; /* # times vn_remove called */ |
| 136 | __uint32_t vn_free; /* # times vn_free called */ |
| 137 | #define XFSSTAT_END_BUF (XFSSTAT_END_VNODE_OPS+9) |
Nathan Scott | ce8e922 | 2006-01-11 15:39:08 +1100 | [diff] [blame] | 138 | __uint32_t xb_get; |
| 139 | __uint32_t xb_create; |
| 140 | __uint32_t xb_get_locked; |
| 141 | __uint32_t xb_get_locked_waited; |
| 142 | __uint32_t xb_busy_locked; |
| 143 | __uint32_t xb_miss_locked; |
| 144 | __uint32_t xb_page_retries; |
| 145 | __uint32_t xb_page_found; |
| 146 | __uint32_t xb_get_read; |
David Chinner | 854929f | 2008-10-30 16:55:03 +1100 | [diff] [blame] | 147 | /* Version 2 btree counters */ |
Dave Chinner | 11ef38a | 2016-12-05 14:38:58 +1100 | [diff] [blame] | 148 | #define XFSSTAT_END_ABTB_V2 (XFSSTAT_END_BUF + __XBTS_MAX) |
| 149 | __uint32_t xs_abtb_2[__XBTS_MAX]; |
| 150 | #define XFSSTAT_END_ABTC_V2 (XFSSTAT_END_ABTB_V2 + __XBTS_MAX) |
| 151 | __uint32_t xs_abtc_2[__XBTS_MAX]; |
| 152 | #define XFSSTAT_END_BMBT_V2 (XFSSTAT_END_ABTC_V2 + __XBTS_MAX) |
| 153 | __uint32_t xs_bmbt_2[__XBTS_MAX]; |
| 154 | #define XFSSTAT_END_IBT_V2 (XFSSTAT_END_BMBT_V2 + __XBTS_MAX) |
| 155 | __uint32_t xs_ibt_2[__XBTS_MAX]; |
| 156 | #define XFSSTAT_END_FIBT_V2 (XFSSTAT_END_IBT_V2 + __XBTS_MAX) |
| 157 | __uint32_t xs_fibt_2[__XBTS_MAX]; |
| 158 | #define XFSSTAT_END_RMAP_V2 (XFSSTAT_END_FIBT_V2 + __XBTS_MAX) |
| 159 | __uint32_t xs_rmap_2[__XBTS_MAX]; |
| 160 | #define XFSSTAT_END_REFCOUNT (XFSSTAT_END_RMAP_V2 + __XBTS_MAX) |
| 161 | __uint32_t xs_refcbt_2[__XBTS_MAX]; |
Darrick J. Wong | 46eeb52 | 2016-10-03 09:11:16 -0700 | [diff] [blame] | 162 | #define XFSSTAT_END_XQMSTAT (XFSSTAT_END_REFCOUNT + 6) |
Christoph Hellwig | 48776fd | 2012-03-13 08:52:33 +0000 | [diff] [blame] | 163 | __uint32_t xs_qm_dqreclaims; |
| 164 | __uint32_t xs_qm_dqreclaim_misses; |
| 165 | __uint32_t xs_qm_dquot_dups; |
| 166 | __uint32_t xs_qm_dqcachemisses; |
| 167 | __uint32_t xs_qm_dqcachehits; |
| 168 | __uint32_t xs_qm_dqwants; |
| 169 | #define XFSSTAT_END_QM (XFSSTAT_END_XQMSTAT+2) |
| 170 | __uint32_t xs_qm_dquot; |
| 171 | __uint32_t xs_qm_dquot_unused; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | /* Extra precision counters */ |
| 173 | __uint64_t xs_xstrat_bytes; |
| 174 | __uint64_t xs_write_bytes; |
| 175 | __uint64_t xs_read_bytes; |
| 176 | }; |
| 177 | |
Dave Chinner | 11ef38a | 2016-12-05 14:38:58 +1100 | [diff] [blame] | 178 | struct xfsstats { |
| 179 | union { |
| 180 | struct __xfsstats s; |
| 181 | uint32_t a[XFSSTAT_END_XQMSTAT]; |
| 182 | }; |
| 183 | }; |
| 184 | |
| 185 | /* |
| 186 | * simple wrapper for getting the array index of s struct member offset |
| 187 | */ |
| 188 | #define XFS_STATS_CALC_INDEX(member) \ |
| 189 | (offsetof(struct __xfsstats, member) / (int)sizeof(__uint32_t)) |
| 190 | |
| 191 | |
Bill O'Donnell | 80529c4 | 2015-10-12 05:19:45 +1100 | [diff] [blame] | 192 | int xfs_stats_format(struct xfsstats __percpu *stats, char *buf); |
| 193 | void xfs_stats_clearall(struct xfsstats __percpu *stats); |
| 194 | extern struct xstats xfsstats; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
Bill O'Donnell | ff6d6af | 2015-10-12 18:21:22 +1100 | [diff] [blame] | 196 | #define XFS_STATS_INC(mp, v) \ |
| 197 | do { \ |
Dave Chinner | 11ef38a | 2016-12-05 14:38:58 +1100 | [diff] [blame] | 198 | per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v++; \ |
| 199 | per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v++; \ |
Bill O'Donnell | ff6d6af | 2015-10-12 18:21:22 +1100 | [diff] [blame] | 200 | } while (0) |
Bill O'Donnell | 80529c4 | 2015-10-12 05:19:45 +1100 | [diff] [blame] | 201 | |
Bill O'Donnell | ff6d6af | 2015-10-12 18:21:22 +1100 | [diff] [blame] | 202 | #define XFS_STATS_DEC(mp, v) \ |
| 203 | do { \ |
Dave Chinner | 11ef38a | 2016-12-05 14:38:58 +1100 | [diff] [blame] | 204 | per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v--; \ |
| 205 | per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v--; \ |
Bill O'Donnell | ff6d6af | 2015-10-12 18:21:22 +1100 | [diff] [blame] | 206 | } while (0) |
Bill O'Donnell | 80529c4 | 2015-10-12 05:19:45 +1100 | [diff] [blame] | 207 | |
Bill O'Donnell | ff6d6af | 2015-10-12 18:21:22 +1100 | [diff] [blame] | 208 | #define XFS_STATS_ADD(mp, v, inc) \ |
| 209 | do { \ |
Dave Chinner | 11ef38a | 2016-12-05 14:38:58 +1100 | [diff] [blame] | 210 | per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v += (inc); \ |
| 211 | per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v += (inc); \ |
| 212 | } while (0) |
| 213 | |
| 214 | #define XFS_STATS_INC_OFF(mp, off) \ |
| 215 | do { \ |
| 216 | per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off]++; \ |
| 217 | per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off]++; \ |
| 218 | } while (0) |
| 219 | |
| 220 | #define XFS_STATS_DEC_OFF(mp, off) \ |
| 221 | do { \ |
| 222 | per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off]; \ |
| 223 | per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off]; \ |
| 224 | } while (0) |
| 225 | |
| 226 | #define XFS_STATS_ADD_OFF(mp, off, inc) \ |
| 227 | do { \ |
| 228 | per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off] += (inc); \ |
| 229 | per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off] += (inc); \ |
Bill O'Donnell | ff6d6af | 2015-10-12 18:21:22 +1100 | [diff] [blame] | 230 | } while (0) |
| 231 | |
| 232 | #if defined(CONFIG_PROC_FS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 234 | extern int xfs_init_procfs(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | extern void xfs_cleanup_procfs(void); |
| 236 | |
| 237 | |
| 238 | #else /* !CONFIG_PROC_FS */ |
| 239 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 240 | static inline int xfs_init_procfs(void) |
| 241 | { |
Christoph Hellwig | 766b092 | 2008-07-18 17:12:50 +1000 | [diff] [blame] | 242 | return 0; |
| 243 | } |
| 244 | |
Christoph Hellwig | 9f8868f | 2008-07-18 17:11:46 +1000 | [diff] [blame] | 245 | static inline void xfs_cleanup_procfs(void) |
| 246 | { |
Christoph Hellwig | 766b092 | 2008-07-18 17:12:50 +1000 | [diff] [blame] | 247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
| 249 | #endif /* !CONFIG_PROC_FS */ |
| 250 | |
| 251 | #endif /* __XFS_STATS_H__ */ |