Blame view

fs/xfs/xfs_stats.h 5.7 KB
0b61f8a40   Dave Chinner   xfs: convert to S...
1
  // SPDX-License-Identifier: GPL-2.0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  /*
7b7187698   Nathan Scott   [XFS] Update lice...
3
4
   * Copyright (c) 2000,2005 Silicon Graphics, Inc.
   * All Rights Reserved.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
6
7
   */
  #ifndef __XFS_STATS_H__
  #define __XFS_STATS_H__
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
9
10
11
  
  #include <linux/percpu.h>
  
  /*
11ef38afe   Dave Chinner   xfs: make xfs btr...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
   * The btree stats arrays have fixed offsets for the different stats. We
   * store the base index in the btree cursor via XFS_STATS_CALC_INDEX() and
   * that allows us to use fixed offsets into the stats array for each btree
   * stat. These index offsets are defined in the order they will be emitted
   * in the stats files, so it is possible to add new btree stat types by
   * appending to the enum list below.
   */
  enum {
  	__XBTS_lookup = 0,
  	__XBTS_compare = 1,
  	__XBTS_insrec = 2,
  	__XBTS_delrec = 3,
  	__XBTS_newroot = 4,
  	__XBTS_killroot = 5,
  	__XBTS_increment = 6,
  	__XBTS_decrement = 7,
  	__XBTS_lshift = 8,
  	__XBTS_rshift = 9,
  	__XBTS_split = 10,
  	__XBTS_join = 11,
  	__XBTS_alloc = 12,
  	__XBTS_free = 13,
  	__XBTS_moves = 14,
  
  	__XBTS_MAX = 15,
  };
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
   * XFS global statistics
   */
11ef38afe   Dave Chinner   xfs: make xfs btr...
42
  struct __xfsstats {
c8ce540db   Darrick J. Wong   xfs: remove doubl...
43
44
45
46
  	uint32_t		xs_allocx;
  	uint32_t		xs_allocb;
  	uint32_t		xs_freex;
  	uint32_t		xs_freeb;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
47
48
49
50
  	uint32_t		xs_abt_lookup;
  	uint32_t		xs_abt_compare;
  	uint32_t		xs_abt_insrec;
  	uint32_t		xs_abt_delrec;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
51
52
53
54
55
56
57
  	uint32_t		xs_blk_mapr;
  	uint32_t		xs_blk_mapw;
  	uint32_t		xs_blk_unmap;
  	uint32_t		xs_add_exlist;
  	uint32_t		xs_del_exlist;
  	uint32_t		xs_look_exlist;
  	uint32_t		xs_cmp_exlist;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
58
59
60
61
  	uint32_t		xs_bmbt_lookup;
  	uint32_t		xs_bmbt_compare;
  	uint32_t		xs_bmbt_insrec;
  	uint32_t		xs_bmbt_delrec;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
62
63
64
65
  	uint32_t		xs_dir_lookup;
  	uint32_t		xs_dir_create;
  	uint32_t		xs_dir_remove;
  	uint32_t		xs_dir_getdents;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
66
67
68
  	uint32_t		xs_trans_sync;
  	uint32_t		xs_trans_async;
  	uint32_t		xs_trans_empty;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
69
70
71
72
73
74
75
  	uint32_t		xs_ig_attempts;
  	uint32_t		xs_ig_found;
  	uint32_t		xs_ig_frecycle;
  	uint32_t		xs_ig_missed;
  	uint32_t		xs_ig_dup;
  	uint32_t		xs_ig_reclaims;
  	uint32_t		xs_ig_attrchg;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
76
77
78
79
80
  	uint32_t		xs_log_writes;
  	uint32_t		xs_log_blocks;
  	uint32_t		xs_log_noiclogs;
  	uint32_t		xs_log_force;
  	uint32_t		xs_log_force_sleep;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
81
82
83
84
85
86
87
88
89
90
  	uint32_t		xs_try_logspace;
  	uint32_t		xs_sleep_logspace;
  	uint32_t		xs_push_ail;
  	uint32_t		xs_push_ail_success;
  	uint32_t		xs_push_ail_pushbuf;
  	uint32_t		xs_push_ail_pinned;
  	uint32_t		xs_push_ail_locked;
  	uint32_t		xs_push_ail_flushing;
  	uint32_t		xs_push_ail_restarts;
  	uint32_t		xs_push_ail_flush;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
91
92
  	uint32_t		xs_xstrat_quick;
  	uint32_t		xs_xstrat_split;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
93
94
  	uint32_t		xs_write_calls;
  	uint32_t		xs_read_calls;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
95
96
97
98
  	uint32_t		xs_attr_get;
  	uint32_t		xs_attr_set;
  	uint32_t		xs_attr_remove;
  	uint32_t		xs_attr_list;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
99
100
101
  	uint32_t		xs_iflush_count;
  	uint32_t		xs_icluster_flushcnt;
  	uint32_t		xs_icluster_flushinode;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
102
103
104
105
106
107
108
109
  	uint32_t		vn_active;	/* # vnodes not on free lists */
  	uint32_t		vn_alloc;	/* # times vn_alloc called */
  	uint32_t		vn_get;		/* # times vn_get called */
  	uint32_t		vn_hold;	/* # times vn_hold called */
  	uint32_t		vn_rele;	/* # times vn_rele called */
  	uint32_t		vn_reclaim;	/* # times vn_reclaim called */
  	uint32_t		vn_remove;	/* # times vn_remove called */
  	uint32_t		vn_free;	/* # times vn_free called */
c8ce540db   Darrick J. Wong   xfs: remove doubl...
110
111
112
113
114
115
116
117
118
  	uint32_t		xb_get;
  	uint32_t		xb_create;
  	uint32_t		xb_get_locked;
  	uint32_t		xb_get_locked_waited;
  	uint32_t		xb_busy_locked;
  	uint32_t		xb_miss_locked;
  	uint32_t		xb_page_retries;
  	uint32_t		xb_page_found;
  	uint32_t		xb_get_read;
854929f05   David Chinner   [XFS] add new btr...
119
  /* Version 2 btree counters */
c8ce540db   Darrick J. Wong   xfs: remove doubl...
120
  	uint32_t		xs_abtb_2[__XBTS_MAX];
c8ce540db   Darrick J. Wong   xfs: remove doubl...
121
  	uint32_t		xs_abtc_2[__XBTS_MAX];
c8ce540db   Darrick J. Wong   xfs: remove doubl...
122
  	uint32_t		xs_bmbt_2[__XBTS_MAX];
c8ce540db   Darrick J. Wong   xfs: remove doubl...
123
  	uint32_t		xs_ibt_2[__XBTS_MAX];
c8ce540db   Darrick J. Wong   xfs: remove doubl...
124
  	uint32_t		xs_fibt_2[__XBTS_MAX];
c8ce540db   Darrick J. Wong   xfs: remove doubl...
125
  	uint32_t		xs_rmap_2[__XBTS_MAX];
c8ce540db   Darrick J. Wong   xfs: remove doubl...
126
  	uint32_t		xs_refcbt_2[__XBTS_MAX];
c8ce540db   Darrick J. Wong   xfs: remove doubl...
127
128
129
130
131
132
  	uint32_t		xs_qm_dqreclaims;
  	uint32_t		xs_qm_dqreclaim_misses;
  	uint32_t		xs_qm_dquot_dups;
  	uint32_t		xs_qm_dqcachemisses;
  	uint32_t		xs_qm_dqcachehits;
  	uint32_t		xs_qm_dqwants;
c8ce540db   Darrick J. Wong   xfs: remove doubl...
133
134
  	uint32_t		xs_qm_dquot;
  	uint32_t		xs_qm_dquot_unused;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
135
  /* Extra precision counters */
c8ce540db   Darrick J. Wong   xfs: remove doubl...
136
137
138
  	uint64_t		xs_xstrat_bytes;
  	uint64_t		xs_write_bytes;
  	uint64_t		xs_read_bytes;
4e919af78   Darrick J. Wong   xfs: periodically...
139
  	uint64_t		defer_relog;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
  };
26ca39015   Carlos Maiolino   xfs: use offsetof...
141
  #define	xfsstats_offset(f)	(offsetof(struct __xfsstats, f)/sizeof(uint32_t))
11ef38afe   Dave Chinner   xfs: make xfs btr...
142
143
144
  struct xfsstats {
  	union {
  		struct __xfsstats	s;
26ca39015   Carlos Maiolino   xfs: use offsetof...
145
  		uint32_t		a[xfsstats_offset(xs_qm_dquot)];
11ef38afe   Dave Chinner   xfs: make xfs btr...
146
147
148
149
150
151
152
  	};
  };
  
  /*
   * simple wrapper for getting the array index of s struct member offset
   */
  #define XFS_STATS_CALC_INDEX(member)	\
c8ce540db   Darrick J. Wong   xfs: remove doubl...
153
  	(offsetof(struct __xfsstats, member) / (int)sizeof(uint32_t))
11ef38afe   Dave Chinner   xfs: make xfs btr...
154

80529c45a   Bill O'Donnell   xfs: pass xfsstat...
155
156
157
  int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
  void xfs_stats_clearall(struct xfsstats __percpu *stats);
  extern struct xstats xfsstats;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
158

ff6d6af23   Bill O'Donnell   xfs: per-filesyst...
159
160
  #define XFS_STATS_INC(mp, v)					\
  do {								\
11ef38afe   Dave Chinner   xfs: make xfs btr...
161
162
  	per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v++;	\
  	per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v++;	\
ff6d6af23   Bill O'Donnell   xfs: per-filesyst...
163
  } while (0)
80529c45a   Bill O'Donnell   xfs: pass xfsstat...
164

ff6d6af23   Bill O'Donnell   xfs: per-filesyst...
165
166
  #define XFS_STATS_DEC(mp, v)					\
  do {								\
11ef38afe   Dave Chinner   xfs: make xfs btr...
167
168
  	per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v--;	\
  	per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v--;	\
ff6d6af23   Bill O'Donnell   xfs: per-filesyst...
169
  } while (0)
80529c45a   Bill O'Donnell   xfs: pass xfsstat...
170

ff6d6af23   Bill O'Donnell   xfs: per-filesyst...
171
172
  #define XFS_STATS_ADD(mp, v, inc)					\
  do {									\
11ef38afe   Dave Chinner   xfs: make xfs btr...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
  	per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v += (inc);	\
  	per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v += (inc);	\
  } while (0)
  
  #define XFS_STATS_INC_OFF(mp, off)				\
  do {								\
  	per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off]++;	\
  	per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off]++;	\
  } while (0)
  
  #define XFS_STATS_DEC_OFF(mp, off)					\
  do {								\
  	per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off];	\
  	per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off];	\
  } while (0)
  
  #define XFS_STATS_ADD_OFF(mp, off, inc)					\
  do {									\
  	per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off] += (inc);	\
  	per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off] += (inc);	\
ff6d6af23   Bill O'Donnell   xfs: per-filesyst...
193
194
195
  } while (0)
  
  #if defined(CONFIG_PROC_FS)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
196

9f8868ffb   Christoph Hellwig   [XFS] streamline ...
197
  extern int xfs_init_procfs(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
198
199
200
201
  extern void xfs_cleanup_procfs(void);
  
  
  #else	/* !CONFIG_PROC_FS */
9f8868ffb   Christoph Hellwig   [XFS] streamline ...
202
203
  static inline int xfs_init_procfs(void)
  {
766b0925c   Christoph Hellwig   [XFS] fix compila...
204
205
  	return 0;
  }
9f8868ffb   Christoph Hellwig   [XFS] streamline ...
206
207
  static inline void xfs_cleanup_procfs(void)
  {
766b0925c   Christoph Hellwig   [XFS] fix compila...
208
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
209
210
211
212
  
  #endif	/* !CONFIG_PROC_FS */
  
  #endif /* __XFS_STATS_H__ */