Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
0004  * All Rights Reserved.
0005  */
0006 #ifndef __XFS_STATS_H__
0007 #define __XFS_STATS_H__
0008 
0009 
0010 #include <linux/percpu.h>
0011 
0012 /*
0013  * The btree stats arrays have fixed offsets for the different stats. We
0014  * store the base index in the btree cursor via XFS_STATS_CALC_INDEX() and
0015  * that allows us to use fixed offsets into the stats array for each btree
0016  * stat. These index offsets are defined in the order they will be emitted
0017  * in the stats files, so it is possible to add new btree stat types by
0018  * appending to the enum list below.
0019  */
0020 enum {
0021     __XBTS_lookup = 0,
0022     __XBTS_compare = 1,
0023     __XBTS_insrec = 2,
0024     __XBTS_delrec = 3,
0025     __XBTS_newroot = 4,
0026     __XBTS_killroot = 5,
0027     __XBTS_increment = 6,
0028     __XBTS_decrement = 7,
0029     __XBTS_lshift = 8,
0030     __XBTS_rshift = 9,
0031     __XBTS_split = 10,
0032     __XBTS_join = 11,
0033     __XBTS_alloc = 12,
0034     __XBTS_free = 13,
0035     __XBTS_moves = 14,
0036 
0037     __XBTS_MAX = 15,
0038 };
0039 
0040 /*
0041  * XFS global statistics
0042  */
0043 struct __xfsstats {
0044     uint32_t        xs_allocx;
0045     uint32_t        xs_allocb;
0046     uint32_t        xs_freex;
0047     uint32_t        xs_freeb;
0048     uint32_t        xs_abt_lookup;
0049     uint32_t        xs_abt_compare;
0050     uint32_t        xs_abt_insrec;
0051     uint32_t        xs_abt_delrec;
0052     uint32_t        xs_blk_mapr;
0053     uint32_t        xs_blk_mapw;
0054     uint32_t        xs_blk_unmap;
0055     uint32_t        xs_add_exlist;
0056     uint32_t        xs_del_exlist;
0057     uint32_t        xs_look_exlist;
0058     uint32_t        xs_cmp_exlist;
0059     uint32_t        xs_bmbt_lookup;
0060     uint32_t        xs_bmbt_compare;
0061     uint32_t        xs_bmbt_insrec;
0062     uint32_t        xs_bmbt_delrec;
0063     uint32_t        xs_dir_lookup;
0064     uint32_t        xs_dir_create;
0065     uint32_t        xs_dir_remove;
0066     uint32_t        xs_dir_getdents;
0067     uint32_t        xs_trans_sync;
0068     uint32_t        xs_trans_async;
0069     uint32_t        xs_trans_empty;
0070     uint32_t        xs_ig_attempts;
0071     uint32_t        xs_ig_found;
0072     uint32_t        xs_ig_frecycle;
0073     uint32_t        xs_ig_missed;
0074     uint32_t        xs_ig_dup;
0075     uint32_t        xs_ig_reclaims;
0076     uint32_t        xs_ig_attrchg;
0077     uint32_t        xs_log_writes;
0078     uint32_t        xs_log_blocks;
0079     uint32_t        xs_log_noiclogs;
0080     uint32_t        xs_log_force;
0081     uint32_t        xs_log_force_sleep;
0082     uint32_t        xs_try_logspace;
0083     uint32_t        xs_sleep_logspace;
0084     uint32_t        xs_push_ail;
0085     uint32_t        xs_push_ail_success;
0086     uint32_t        xs_push_ail_pushbuf;
0087     uint32_t        xs_push_ail_pinned;
0088     uint32_t        xs_push_ail_locked;
0089     uint32_t        xs_push_ail_flushing;
0090     uint32_t        xs_push_ail_restarts;
0091     uint32_t        xs_push_ail_flush;
0092     uint32_t        xs_xstrat_quick;
0093     uint32_t        xs_xstrat_split;
0094     uint32_t        xs_write_calls;
0095     uint32_t        xs_read_calls;
0096     uint32_t        xs_attr_get;
0097     uint32_t        xs_attr_set;
0098     uint32_t        xs_attr_remove;
0099     uint32_t        xs_attr_list;
0100     uint32_t        xs_iflush_count;
0101     uint32_t        xs_icluster_flushcnt;
0102     uint32_t        xs_icluster_flushinode;
0103     uint32_t        vn_active;  /* # vnodes not on free lists */
0104     uint32_t        vn_alloc;   /* # times vn_alloc called */
0105     uint32_t        vn_get;     /* # times vn_get called */
0106     uint32_t        vn_hold;    /* # times vn_hold called */
0107     uint32_t        vn_rele;    /* # times vn_rele called */
0108     uint32_t        vn_reclaim; /* # times vn_reclaim called */
0109     uint32_t        vn_remove;  /* # times vn_remove called */
0110     uint32_t        vn_free;    /* # times vn_free called */
0111     uint32_t        xb_get;
0112     uint32_t        xb_create;
0113     uint32_t        xb_get_locked;
0114     uint32_t        xb_get_locked_waited;
0115     uint32_t        xb_busy_locked;
0116     uint32_t        xb_miss_locked;
0117     uint32_t        xb_page_retries;
0118     uint32_t        xb_page_found;
0119     uint32_t        xb_get_read;
0120 /* Version 2 btree counters */
0121     uint32_t        xs_abtb_2[__XBTS_MAX];
0122     uint32_t        xs_abtc_2[__XBTS_MAX];
0123     uint32_t        xs_bmbt_2[__XBTS_MAX];
0124     uint32_t        xs_ibt_2[__XBTS_MAX];
0125     uint32_t        xs_fibt_2[__XBTS_MAX];
0126     uint32_t        xs_rmap_2[__XBTS_MAX];
0127     uint32_t        xs_refcbt_2[__XBTS_MAX];
0128     uint32_t        xs_qm_dqreclaims;
0129     uint32_t        xs_qm_dqreclaim_misses;
0130     uint32_t        xs_qm_dquot_dups;
0131     uint32_t        xs_qm_dqcachemisses;
0132     uint32_t        xs_qm_dqcachehits;
0133     uint32_t        xs_qm_dqwants;
0134     uint32_t        xs_qm_dquot;
0135     uint32_t        xs_qm_dquot_unused;
0136 /* Extra precision counters */
0137     uint64_t        xs_xstrat_bytes;
0138     uint64_t        xs_write_bytes;
0139     uint64_t        xs_read_bytes;
0140     uint64_t        defer_relog;
0141 };
0142 
0143 #define xfsstats_offset(f)  (offsetof(struct __xfsstats, f)/sizeof(uint32_t))
0144 
0145 struct xfsstats {
0146     union {
0147         struct __xfsstats   s;
0148         uint32_t        a[xfsstats_offset(xs_qm_dquot)];
0149     };
0150 };
0151 
0152 /*
0153  * simple wrapper for getting the array index of s struct member offset
0154  */
0155 #define XFS_STATS_CALC_INDEX(member)    \
0156     (offsetof(struct __xfsstats, member) / (int)sizeof(uint32_t))
0157 
0158 
0159 int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
0160 void xfs_stats_clearall(struct xfsstats __percpu *stats);
0161 extern struct xstats xfsstats;
0162 
0163 #define XFS_STATS_INC(mp, v)                    \
0164 do {                                \
0165     per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v++;   \
0166     per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v++;    \
0167 } while (0)
0168 
0169 #define XFS_STATS_DEC(mp, v)                    \
0170 do {                                \
0171     per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v--;   \
0172     per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v--;    \
0173 } while (0)
0174 
0175 #define XFS_STATS_ADD(mp, v, inc)                   \
0176 do {                                    \
0177     per_cpu_ptr(xfsstats.xs_stats, current_cpu())->s.v += (inc);    \
0178     per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->s.v += (inc); \
0179 } while (0)
0180 
0181 #define XFS_STATS_INC_OFF(mp, off)              \
0182 do {                                \
0183     per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off]++;    \
0184     per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off]++; \
0185 } while (0)
0186 
0187 #define XFS_STATS_DEC_OFF(mp, off)                  \
0188 do {                                \
0189     per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off];  \
0190     per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off];   \
0191 } while (0)
0192 
0193 #define XFS_STATS_ADD_OFF(mp, off, inc)                 \
0194 do {                                    \
0195     per_cpu_ptr(xfsstats.xs_stats, current_cpu())->a[off] += (inc); \
0196     per_cpu_ptr(mp->m_stats.xs_stats, current_cpu())->a[off] += (inc);  \
0197 } while (0)
0198 
0199 #if defined(CONFIG_PROC_FS)
0200 
0201 extern int xfs_init_procfs(void);
0202 extern void xfs_cleanup_procfs(void);
0203 
0204 
0205 #else   /* !CONFIG_PROC_FS */
0206 
0207 static inline int xfs_init_procfs(void)
0208 {
0209     return 0;
0210 }
0211 
0212 static inline void xfs_cleanup_procfs(void)
0213 {
0214 }
0215 
0216 #endif  /* !CONFIG_PROC_FS */
0217 
0218 #endif /* __XFS_STATS_H__ */