diff options
author | Christoph Hellwig <hch@infradead.org> | 2009-12-14 18:14:59 -0500 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2009-12-15 00:08:16 -0500 |
commit | 0b1b213fcf3a8486ada99a2bab84ab8c6f51b264 (patch) | |
tree | 661fd8da7487231224c77b95c33986cb7d7b41ef /fs/xfs/xfs_iget.c | |
parent | 6ef3554422e2c7e7aa424ba63737da498881dff4 (diff) |
xfs: event tracing support
Convert the old xfs tracing support that could only be used with the
out of tree kdb and xfsidbg patches to use the generic event tracer.
To use it make sure CONFIG_EVENT_TRACING is enabled and then enable
all xfs trace channels by:
echo 1 > /sys/kernel/debug/tracing/events/xfs/enable
or alternatively enable single events by just doing the same in one
event subdirectory, e.g.
echo 1 > /sys/kernel/debug/tracing/events/xfs/xfs_ihold/enable
or set more complex filters, etc. In Documentation/trace/events.txt
all this is desctribed in more detail. To reads the events do a
cat /sys/kernel/debug/tracing/trace
Compared to the last posting this patch converts the tracing mostly to
the one tracepoint per callsite model that other users of the new
tracing facility also employ. This allows a very fine-grained control
of the tracing, a cleaner output of the traces and also enables the
perf tool to use each tracepoint as a virtual performance counter,
allowing us to e.g. count how often certain workloads git various
spots in XFS. Take a look at
http://lwn.net/Articles/346470/
for some examples.
Also the btree tracing isn't included at all yet, as it will require
additional core tracing features not in mainline yet, I plan to
deliver it later.
And the really nice thing about this patch is that it actually removes
many lines of code while adding this nice functionality:
fs/xfs/Makefile | 8
fs/xfs/linux-2.6/xfs_acl.c | 1
fs/xfs/linux-2.6/xfs_aops.c | 52 -
fs/xfs/linux-2.6/xfs_aops.h | 2
fs/xfs/linux-2.6/xfs_buf.c | 117 +--
fs/xfs/linux-2.6/xfs_buf.h | 33
fs/xfs/linux-2.6/xfs_fs_subr.c | 3
fs/xfs/linux-2.6/xfs_ioctl.c | 1
fs/xfs/linux-2.6/xfs_ioctl32.c | 1
fs/xfs/linux-2.6/xfs_iops.c | 1
fs/xfs/linux-2.6/xfs_linux.h | 1
fs/xfs/linux-2.6/xfs_lrw.c | 87 --
fs/xfs/linux-2.6/xfs_lrw.h | 45 -
fs/xfs/linux-2.6/xfs_super.c | 104 ---
fs/xfs/linux-2.6/xfs_super.h | 7
fs/xfs/linux-2.6/xfs_sync.c | 1
fs/xfs/linux-2.6/xfs_trace.c | 75 ++
fs/xfs/linux-2.6/xfs_trace.h | 1369 +++++++++++++++++++++++++++++++++++++++++
fs/xfs/linux-2.6/xfs_vnode.h | 4
fs/xfs/quota/xfs_dquot.c | 110 ---
fs/xfs/quota/xfs_dquot.h | 21
fs/xfs/quota/xfs_qm.c | 40 -
fs/xfs/quota/xfs_qm_syscalls.c | 4
fs/xfs/support/ktrace.c | 323 ---------
fs/xfs/support/ktrace.h | 85 --
fs/xfs/xfs.h | 16
fs/xfs/xfs_ag.h | 14
fs/xfs/xfs_alloc.c | 230 +-----
fs/xfs/xfs_alloc.h | 27
fs/xfs/xfs_alloc_btree.c | 1
fs/xfs/xfs_attr.c | 107 ---
fs/xfs/xfs_attr.h | 10
fs/xfs/xfs_attr_leaf.c | 14
fs/xfs/xfs_attr_sf.h | 40 -
fs/xfs/xfs_bmap.c | 507 +++------------
fs/xfs/xfs_bmap.h | 49 -
fs/xfs/xfs_bmap_btree.c | 6
fs/xfs/xfs_btree.c | 5
fs/xfs/xfs_btree_trace.h | 17
fs/xfs/xfs_buf_item.c | 87 --
fs/xfs/xfs_buf_item.h | 20
fs/xfs/xfs_da_btree.c | 3
fs/xfs/xfs_da_btree.h | 7
fs/xfs/xfs_dfrag.c | 2
fs/xfs/xfs_dir2.c | 8
fs/xfs/xfs_dir2_block.c | 20
fs/xfs/xfs_dir2_leaf.c | 21
fs/xfs/xfs_dir2_node.c | 27
fs/xfs/xfs_dir2_sf.c | 26
fs/xfs/xfs_dir2_trace.c | 216 ------
fs/xfs/xfs_dir2_trace.h | 72 --
fs/xfs/xfs_filestream.c | 8
fs/xfs/xfs_fsops.c | 2
fs/xfs/xfs_iget.c | 111 ---
fs/xfs/xfs_inode.c | 67 --
fs/xfs/xfs_inode.h | 76 --
fs/xfs/xfs_inode_item.c | 5
fs/xfs/xfs_iomap.c | 85 --
fs/xfs/xfs_iomap.h | 8
fs/xfs/xfs_log.c | 181 +----
fs/xfs/xfs_log_priv.h | 20
fs/xfs/xfs_log_recover.c | 1
fs/xfs/xfs_mount.c | 2
fs/xfs/xfs_quota.h | 8
fs/xfs/xfs_rename.c | 1
fs/xfs/xfs_rtalloc.c | 1
fs/xfs/xfs_rw.c | 3
fs/xfs/xfs_trans.h | 47 +
fs/xfs/xfs_trans_buf.c | 62 -
fs/xfs/xfs_vnodeops.c | 8
70 files changed, 2151 insertions(+), 2592 deletions(-)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_iget.c')
-rw-r--r-- | fs/xfs/xfs_iget.c | 111 |
1 files changed, 14 insertions, 97 deletions
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c index 073bb4a26b19..f5c904a10c11 100644 --- a/fs/xfs/xfs_iget.c +++ b/fs/xfs/xfs_iget.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include "xfs_inode_item.h" | 43 | #include "xfs_inode_item.h" |
44 | #include "xfs_bmap.h" | 44 | #include "xfs_bmap.h" |
45 | #include "xfs_btree_trace.h" | 45 | #include "xfs_btree_trace.h" |
46 | #include "xfs_dir2_trace.h" | 46 | #include "xfs_trace.h" |
47 | 47 | ||
48 | 48 | ||
49 | /* | 49 | /* |
@@ -90,28 +90,6 @@ xfs_inode_alloc( | |||
90 | ip->i_size = 0; | 90 | ip->i_size = 0; |
91 | ip->i_new_size = 0; | 91 | ip->i_new_size = 0; |
92 | 92 | ||
93 | /* | ||
94 | * Initialize inode's trace buffers. | ||
95 | */ | ||
96 | #ifdef XFS_INODE_TRACE | ||
97 | ip->i_trace = ktrace_alloc(INODE_TRACE_SIZE, KM_NOFS); | ||
98 | #endif | ||
99 | #ifdef XFS_BMAP_TRACE | ||
100 | ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_NOFS); | ||
101 | #endif | ||
102 | #ifdef XFS_BTREE_TRACE | ||
103 | ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_NOFS); | ||
104 | #endif | ||
105 | #ifdef XFS_RW_TRACE | ||
106 | ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_NOFS); | ||
107 | #endif | ||
108 | #ifdef XFS_ILOCK_TRACE | ||
109 | ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_NOFS); | ||
110 | #endif | ||
111 | #ifdef XFS_DIR2_TRACE | ||
112 | ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_NOFS); | ||
113 | #endif | ||
114 | |||
115 | /* prevent anyone from using this yet */ | 93 | /* prevent anyone from using this yet */ |
116 | VFS_I(ip)->i_state = I_NEW|I_LOCK; | 94 | VFS_I(ip)->i_state = I_NEW|I_LOCK; |
117 | 95 | ||
@@ -133,25 +111,6 @@ xfs_inode_free( | |||
133 | if (ip->i_afp) | 111 | if (ip->i_afp) |
134 | xfs_idestroy_fork(ip, XFS_ATTR_FORK); | 112 | xfs_idestroy_fork(ip, XFS_ATTR_FORK); |
135 | 113 | ||
136 | #ifdef XFS_INODE_TRACE | ||
137 | ktrace_free(ip->i_trace); | ||
138 | #endif | ||
139 | #ifdef XFS_BMAP_TRACE | ||
140 | ktrace_free(ip->i_xtrace); | ||
141 | #endif | ||
142 | #ifdef XFS_BTREE_TRACE | ||
143 | ktrace_free(ip->i_btrace); | ||
144 | #endif | ||
145 | #ifdef XFS_RW_TRACE | ||
146 | ktrace_free(ip->i_rwtrace); | ||
147 | #endif | ||
148 | #ifdef XFS_ILOCK_TRACE | ||
149 | ktrace_free(ip->i_lock_trace); | ||
150 | #endif | ||
151 | #ifdef XFS_DIR2_TRACE | ||
152 | ktrace_free(ip->i_dir_trace); | ||
153 | #endif | ||
154 | |||
155 | if (ip->i_itemp) { | 114 | if (ip->i_itemp) { |
156 | /* | 115 | /* |
157 | * Only if we are shutting down the fs will we see an | 116 | * Only if we are shutting down the fs will we see an |
@@ -210,6 +169,7 @@ xfs_iget_cache_hit( | |||
210 | * instead of polling for it. | 169 | * instead of polling for it. |
211 | */ | 170 | */ |
212 | if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { | 171 | if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { |
172 | trace_xfs_iget_skip(ip); | ||
213 | XFS_STATS_INC(xs_ig_frecycle); | 173 | XFS_STATS_INC(xs_ig_frecycle); |
214 | error = EAGAIN; | 174 | error = EAGAIN; |
215 | goto out_error; | 175 | goto out_error; |
@@ -228,7 +188,7 @@ xfs_iget_cache_hit( | |||
228 | * Need to carefully get it back into useable state. | 188 | * Need to carefully get it back into useable state. |
229 | */ | 189 | */ |
230 | if (ip->i_flags & XFS_IRECLAIMABLE) { | 190 | if (ip->i_flags & XFS_IRECLAIMABLE) { |
231 | xfs_itrace_exit_tag(ip, "xfs_iget.alloc"); | 191 | trace_xfs_iget_reclaim(ip); |
232 | 192 | ||
233 | /* | 193 | /* |
234 | * We need to set XFS_INEW atomically with clearing the | 194 | * We need to set XFS_INEW atomically with clearing the |
@@ -254,6 +214,7 @@ xfs_iget_cache_hit( | |||
254 | ip->i_flags &= ~XFS_INEW; | 214 | ip->i_flags &= ~XFS_INEW; |
255 | ip->i_flags |= XFS_IRECLAIMABLE; | 215 | ip->i_flags |= XFS_IRECLAIMABLE; |
256 | __xfs_inode_set_reclaim_tag(pag, ip); | 216 | __xfs_inode_set_reclaim_tag(pag, ip); |
217 | trace_xfs_iget_reclaim(ip); | ||
257 | goto out_error; | 218 | goto out_error; |
258 | } | 219 | } |
259 | inode->i_state = I_LOCK|I_NEW; | 220 | inode->i_state = I_LOCK|I_NEW; |
@@ -273,8 +234,9 @@ xfs_iget_cache_hit( | |||
273 | xfs_ilock(ip, lock_flags); | 234 | xfs_ilock(ip, lock_flags); |
274 | 235 | ||
275 | xfs_iflags_clear(ip, XFS_ISTALE); | 236 | xfs_iflags_clear(ip, XFS_ISTALE); |
276 | xfs_itrace_exit_tag(ip, "xfs_iget.found"); | ||
277 | XFS_STATS_INC(xs_ig_found); | 237 | XFS_STATS_INC(xs_ig_found); |
238 | |||
239 | trace_xfs_iget_found(ip); | ||
278 | return 0; | 240 | return 0; |
279 | 241 | ||
280 | out_error: | 242 | out_error: |
@@ -308,7 +270,7 @@ xfs_iget_cache_miss( | |||
308 | if (error) | 270 | if (error) |
309 | goto out_destroy; | 271 | goto out_destroy; |
310 | 272 | ||
311 | xfs_itrace_exit_tag(ip, "xfs_iget.alloc"); | 273 | xfs_itrace_entry(ip); |
312 | 274 | ||
313 | if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { | 275 | if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { |
314 | error = ENOENT; | 276 | error = ENOENT; |
@@ -353,6 +315,8 @@ xfs_iget_cache_miss( | |||
353 | 315 | ||
354 | write_unlock(&pag->pag_ici_lock); | 316 | write_unlock(&pag->pag_ici_lock); |
355 | radix_tree_preload_end(); | 317 | radix_tree_preload_end(); |
318 | |||
319 | trace_xfs_iget_alloc(ip); | ||
356 | *ipp = ip; | 320 | *ipp = ip; |
357 | return 0; | 321 | return 0; |
358 | 322 | ||
@@ -639,7 +603,7 @@ xfs_ilock( | |||
639 | else if (lock_flags & XFS_ILOCK_SHARED) | 603 | else if (lock_flags & XFS_ILOCK_SHARED) |
640 | mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); | 604 | mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); |
641 | 605 | ||
642 | xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)__return_address); | 606 | trace_xfs_ilock(ip, lock_flags, _RET_IP_); |
643 | } | 607 | } |
644 | 608 | ||
645 | /* | 609 | /* |
@@ -684,7 +648,7 @@ xfs_ilock_nowait( | |||
684 | if (!mrtryaccess(&ip->i_lock)) | 648 | if (!mrtryaccess(&ip->i_lock)) |
685 | goto out_undo_iolock; | 649 | goto out_undo_iolock; |
686 | } | 650 | } |
687 | xfs_ilock_trace(ip, 2, lock_flags, (inst_t *)__return_address); | 651 | trace_xfs_ilock_nowait(ip, lock_flags, _RET_IP_); |
688 | return 1; | 652 | return 1; |
689 | 653 | ||
690 | out_undo_iolock: | 654 | out_undo_iolock: |
@@ -746,7 +710,7 @@ xfs_iunlock( | |||
746 | xfs_trans_unlocked_item(ip->i_itemp->ili_item.li_ailp, | 710 | xfs_trans_unlocked_item(ip->i_itemp->ili_item.li_ailp, |
747 | (xfs_log_item_t*)(ip->i_itemp)); | 711 | (xfs_log_item_t*)(ip->i_itemp)); |
748 | } | 712 | } |
749 | xfs_ilock_trace(ip, 3, lock_flags, (inst_t *)__return_address); | 713 | trace_xfs_iunlock(ip, lock_flags, _RET_IP_); |
750 | } | 714 | } |
751 | 715 | ||
752 | /* | 716 | /* |
@@ -765,6 +729,8 @@ xfs_ilock_demote( | |||
765 | mrdemote(&ip->i_lock); | 729 | mrdemote(&ip->i_lock); |
766 | if (lock_flags & XFS_IOLOCK_EXCL) | 730 | if (lock_flags & XFS_IOLOCK_EXCL) |
767 | mrdemote(&ip->i_iolock); | 731 | mrdemote(&ip->i_iolock); |
732 | |||
733 | trace_xfs_ilock_demote(ip, lock_flags, _RET_IP_); | ||
768 | } | 734 | } |
769 | 735 | ||
770 | #ifdef DEBUG | 736 | #ifdef DEBUG |
@@ -795,52 +761,3 @@ xfs_isilocked( | |||
795 | return 1; | 761 | return 1; |
796 | } | 762 | } |
797 | #endif | 763 | #endif |
798 | |||
799 | #ifdef XFS_INODE_TRACE | ||
800 | |||
801 | #define KTRACE_ENTER(ip, vk, s, line, ra) \ | ||
802 | ktrace_enter((ip)->i_trace, \ | ||
803 | /* 0 */ (void *)(__psint_t)(vk), \ | ||
804 | /* 1 */ (void *)(s), \ | ||
805 | /* 2 */ (void *)(__psint_t) line, \ | ||
806 | /* 3 */ (void *)(__psint_t)atomic_read(&VFS_I(ip)->i_count), \ | ||
807 | /* 4 */ (void *)(ra), \ | ||
808 | /* 5 */ NULL, \ | ||
809 | /* 6 */ (void *)(__psint_t)current_cpu(), \ | ||
810 | /* 7 */ (void *)(__psint_t)current_pid(), \ | ||
811 | /* 8 */ (void *)__return_address, \ | ||
812 | /* 9 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL) | ||
813 | |||
814 | /* | ||
815 | * Vnode tracing code. | ||
816 | */ | ||
817 | void | ||
818 | _xfs_itrace_entry(xfs_inode_t *ip, const char *func, inst_t *ra) | ||
819 | { | ||
820 | KTRACE_ENTER(ip, INODE_KTRACE_ENTRY, func, 0, ra); | ||
821 | } | ||
822 | |||
823 | void | ||
824 | _xfs_itrace_exit(xfs_inode_t *ip, const char *func, inst_t *ra) | ||
825 | { | ||
826 | KTRACE_ENTER(ip, INODE_KTRACE_EXIT, func, 0, ra); | ||
827 | } | ||
828 | |||
829 | void | ||
830 | xfs_itrace_hold(xfs_inode_t *ip, char *file, int line, inst_t *ra) | ||
831 | { | ||
832 | KTRACE_ENTER(ip, INODE_KTRACE_HOLD, file, line, ra); | ||
833 | } | ||
834 | |||
835 | void | ||
836 | _xfs_itrace_ref(xfs_inode_t *ip, char *file, int line, inst_t *ra) | ||
837 | { | ||
838 | KTRACE_ENTER(ip, INODE_KTRACE_REF, file, line, ra); | ||
839 | } | ||
840 | |||
841 | void | ||
842 | xfs_itrace_rele(xfs_inode_t *ip, char *file, int line, inst_t *ra) | ||
843 | { | ||
844 | KTRACE_ENTER(ip, INODE_KTRACE_RELE, file, line, ra); | ||
845 | } | ||
846 | #endif /* XFS_INODE_TRACE */ | ||