aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-03-12 04:05:33 -0400
committerChris Mason <clm@fb.com>2014-03-20 20:15:28 -0400
commitc3a468915a384c0015263edd9b7263775599a323 (patch)
tree433ed892fc1733ddb28bf1bf2ac61bdac5b42398
parentf094c9bd3e12ee83e91f4249b600d4d2ac0a4738 (diff)
btrfs: Add trace for btrfs_workqueue alloc/destroy
Since most of the btrfs_workqueue is printed as pointer address, for easier analysis, add trace for btrfs_workqueue alloc/destroy. So it is possible to determine the workqueue that a given work belongs to(by comparing the wq pointer address with alloc trace event). Signed-off-by: Qu Wenruo <quenruo@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--fs/btrfs/async-thread.c7
-rw-r--r--fs/btrfs/async-thread.h2
-rw-r--r--include/trace/events/btrfs.h55
3 files changed, 61 insertions, 3 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index 66532b8f0f7c..ecb5832c0967 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -56,7 +56,8 @@ struct btrfs_workqueue {
56}; 56};
57 57
58static inline struct __btrfs_workqueue 58static inline struct __btrfs_workqueue
59*__btrfs_alloc_workqueue(char *name, int flags, int max_active, int thresh) 59*__btrfs_alloc_workqueue(const char *name, int flags, int max_active,
60 int thresh)
60{ 61{
61 struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS); 62 struct __btrfs_workqueue *ret = kzalloc(sizeof(*ret), GFP_NOFS);
62 63
@@ -92,13 +93,14 @@ static inline struct __btrfs_workqueue
92 INIT_LIST_HEAD(&ret->ordered_list); 93 INIT_LIST_HEAD(&ret->ordered_list);
93 spin_lock_init(&ret->list_lock); 94 spin_lock_init(&ret->list_lock);
94 spin_lock_init(&ret->thres_lock); 95 spin_lock_init(&ret->thres_lock);
96 trace_btrfs_workqueue_alloc(ret, name, flags & WQ_HIGHPRI);
95 return ret; 97 return ret;
96} 98}
97 99
98static inline void 100static inline void
99__btrfs_destroy_workqueue(struct __btrfs_workqueue *wq); 101__btrfs_destroy_workqueue(struct __btrfs_workqueue *wq);
100 102
101struct btrfs_workqueue *btrfs_alloc_workqueue(char *name, 103struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
102 int flags, 104 int flags,
103 int max_active, 105 int max_active,
104 int thresh) 106 int thresh)
@@ -305,6 +307,7 @@ static inline void
305__btrfs_destroy_workqueue(struct __btrfs_workqueue *wq) 307__btrfs_destroy_workqueue(struct __btrfs_workqueue *wq)
306{ 308{
307 destroy_workqueue(wq->normal_wq); 309 destroy_workqueue(wq->normal_wq);
310 trace_btrfs_workqueue_destroy(wq);
308 kfree(wq); 311 kfree(wq);
309} 312}
310 313
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
index 0a891cdc4c28..9c6b66d15fb0 100644
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -38,7 +38,7 @@ struct btrfs_work {
38 unsigned long flags; 38 unsigned long flags;
39}; 39};
40 40
41struct btrfs_workqueue *btrfs_alloc_workqueue(char *name, 41struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
42 int flags, 42 int flags,
43 int max_active, 43 int max_active,
44 int thresh); 44 int thresh);
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index c346919254a9..4ee4e30d26d9 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -22,6 +22,7 @@ struct btrfs_free_cluster;
22struct map_lookup; 22struct map_lookup;
23struct extent_buffer; 23struct extent_buffer;
24struct btrfs_work; 24struct btrfs_work;
25struct __btrfs_workqueue;
25 26
26#define show_ref_type(type) \ 27#define show_ref_type(type) \
27 __print_symbolic(type, \ 28 __print_symbolic(type, \
@@ -1063,6 +1064,60 @@ DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1063 TP_ARGS(work) 1064 TP_ARGS(work)
1064); 1065);
1065 1066
1067DECLARE_EVENT_CLASS(btrfs__workqueue,
1068
1069 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1070
1071 TP_ARGS(wq, name, high),
1072
1073 TP_STRUCT__entry(
1074 __field( void *, wq )
1075 __string( name, name )
1076 __field( int , high )
1077 ),
1078
1079 TP_fast_assign(
1080 __entry->wq = wq;
1081 __assign_str(name, name);
1082 __entry->high = high;
1083 ),
1084
1085 TP_printk("name=%s%s, wq=%p", __get_str(name),
1086 __print_flags(__entry->high, "",
1087 {(WQ_HIGHPRI), "-high"}),
1088 __entry->wq)
1089);
1090
1091DEFINE_EVENT(btrfs__workqueue, btrfs_workqueue_alloc,
1092
1093 TP_PROTO(struct __btrfs_workqueue *wq, const char *name, int high),
1094
1095 TP_ARGS(wq, name, high)
1096);
1097
1098DECLARE_EVENT_CLASS(btrfs__workqueue_done,
1099
1100 TP_PROTO(struct __btrfs_workqueue *wq),
1101
1102 TP_ARGS(wq),
1103
1104 TP_STRUCT__entry(
1105 __field( void *, wq )
1106 ),
1107
1108 TP_fast_assign(
1109 __entry->wq = wq;
1110 ),
1111
1112 TP_printk("wq=%p", __entry->wq)
1113);
1114
1115DEFINE_EVENT(btrfs__workqueue_done, btrfs_workqueue_destroy,
1116
1117 TP_PROTO(struct __btrfs_workqueue *wq),
1118
1119 TP_ARGS(wq)
1120);
1066 1121
1067#endif /* _TRACE_BTRFS_H */ 1122#endif /* _TRACE_BTRFS_H */
1068 1123