Linux Audio

Check our new training course

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