aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-03-05 23:19:50 -0500
committerJosef Bacik <jbacik@fb.com>2014-03-10 15:17:21 -0400
commit52483bc26f0e95c91e8fd07f9def588bf89664f8 (patch)
tree49c742d358bafac2c5339715524a9419915cdaa0
parent6db8914f9763d3f0a7610b497d44f93a4c17e62e (diff)
btrfs: Add ftrace for btrfs_workqueue
Add ftrace for btrfs_workqueue for further workqueue tunning. This patch needs to applied after the workqueue replace patchset. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com>
-rw-r--r--fs/btrfs/async-thread.c7
-rw-r--r--include/trace/events/btrfs.h82
2 files changed, 89 insertions, 0 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index d8c07e5c1f24..00623dd16b81 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -24,6 +24,7 @@
24#include <linux/freezer.h> 24#include <linux/freezer.h>
25#include <linux/workqueue.h> 25#include <linux/workqueue.h>
26#include "async-thread.h" 26#include "async-thread.h"
27#include "ctree.h"
27 28
28#define WORK_DONE_BIT 0 29#define WORK_DONE_BIT 0
29#define WORK_ORDER_DONE_BIT 1 30#define WORK_ORDER_DONE_BIT 1
@@ -210,6 +211,7 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
210 */ 211 */
211 if (test_and_set_bit(WORK_ORDER_DONE_BIT, &work->flags)) 212 if (test_and_set_bit(WORK_ORDER_DONE_BIT, &work->flags))
212 break; 213 break;
214 trace_btrfs_ordered_sched(work);
213 spin_unlock_irqrestore(lock, flags); 215 spin_unlock_irqrestore(lock, flags);
214 work->ordered_func(work); 216 work->ordered_func(work);
215 217
@@ -223,6 +225,7 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
223 * with the lock held though 225 * with the lock held though
224 */ 226 */
225 work->ordered_free(work); 227 work->ordered_free(work);
228 trace_btrfs_all_work_done(work);
226 } 229 }
227 spin_unlock_irqrestore(lock, flags); 230 spin_unlock_irqrestore(lock, flags);
228} 231}
@@ -246,12 +249,15 @@ static void normal_work_helper(struct work_struct *arg)
246 need_order = 1; 249 need_order = 1;
247 wq = work->wq; 250 wq = work->wq;
248 251
252 trace_btrfs_work_sched(work);
249 thresh_exec_hook(wq); 253 thresh_exec_hook(wq);
250 work->func(work); 254 work->func(work);
251 if (need_order) { 255 if (need_order) {
252 set_bit(WORK_DONE_BIT, &work->flags); 256 set_bit(WORK_DONE_BIT, &work->flags);
253 run_ordered_work(wq); 257 run_ordered_work(wq);
254 } 258 }
259 if (!need_order)
260 trace_btrfs_all_work_done(work);
255} 261}
256 262
257void btrfs_init_work(struct btrfs_work *work, 263void btrfs_init_work(struct btrfs_work *work,
@@ -280,6 +286,7 @@ static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq,
280 spin_unlock_irqrestore(&wq->list_lock, flags); 286 spin_unlock_irqrestore(&wq->list_lock, flags);
281 } 287 }
282 queue_work(wq->normal_wq, &work->normal_work); 288 queue_work(wq->normal_wq, &work->normal_work);
289 trace_btrfs_work_queued(work);
283} 290}
284 291
285void btrfs_queue_work(struct btrfs_workqueue *wq, 292void btrfs_queue_work(struct btrfs_workqueue *wq,
diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
index 3176cdc32937..c346919254a9 100644
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
@@ -21,6 +21,7 @@ struct btrfs_block_group_cache;
21struct btrfs_free_cluster; 21struct btrfs_free_cluster;
22struct map_lookup; 22struct map_lookup;
23struct extent_buffer; 23struct extent_buffer;
24struct btrfs_work;
24 25
25#define show_ref_type(type) \ 26#define show_ref_type(type) \
26 __print_symbolic(type, \ 27 __print_symbolic(type, \
@@ -982,6 +983,87 @@ TRACE_EVENT(free_extent_state,
982 (void *)__entry->ip) 983 (void *)__entry->ip)
983); 984);
984 985
986DECLARE_EVENT_CLASS(btrfs__work,
987
988 TP_PROTO(struct btrfs_work *work),
989
990 TP_ARGS(work),
991
992 TP_STRUCT__entry(
993 __field( void *, work )
994 __field( void *, wq )
995 __field( void *, func )
996 __field( void *, ordered_func )
997 __field( void *, ordered_free )
998 ),
999
1000 TP_fast_assign(
1001 __entry->work = work;
1002 __entry->wq = work->wq;
1003 __entry->func = work->func;
1004 __entry->ordered_func = work->ordered_func;
1005 __entry->ordered_free = work->ordered_free;
1006 ),
1007
1008 TP_printk("work=%p, wq=%p, func=%p, ordered_func=%p, ordered_free=%p",
1009 __entry->work, __entry->wq, __entry->func,
1010 __entry->ordered_func, __entry->ordered_free)
1011);
1012
1013/* For situiations that the work is freed */
1014DECLARE_EVENT_CLASS(btrfs__work__done,
1015
1016 TP_PROTO(struct btrfs_work *work),
1017
1018 TP_ARGS(work),
1019
1020 TP_STRUCT__entry(
1021 __field( void *, work )
1022 ),
1023
1024 TP_fast_assign(
1025 __entry->work = work;
1026 ),
1027
1028 TP_printk("work->%p", __entry->work)
1029);
1030
1031DEFINE_EVENT(btrfs__work, btrfs_work_queued,
1032
1033 TP_PROTO(struct btrfs_work *work),
1034
1035 TP_ARGS(work)
1036);
1037
1038DEFINE_EVENT(btrfs__work, btrfs_work_sched,
1039
1040 TP_PROTO(struct btrfs_work *work),
1041
1042 TP_ARGS(work)
1043);
1044
1045DEFINE_EVENT(btrfs__work, btrfs_normal_work_done,
1046
1047 TP_PROTO(struct btrfs_work *work),
1048
1049 TP_ARGS(work)
1050);
1051
1052DEFINE_EVENT(btrfs__work__done, btrfs_all_work_done,
1053
1054 TP_PROTO(struct btrfs_work *work),
1055
1056 TP_ARGS(work)
1057);
1058
1059DEFINE_EVENT(btrfs__work, btrfs_ordered_sched,
1060
1061 TP_PROTO(struct btrfs_work *work),
1062
1063 TP_ARGS(work)
1064);
1065
1066
985#endif /* _TRACE_BTRFS_H */ 1067#endif /* _TRACE_BTRFS_H */
986 1068
987/* This part must be outside protection */ 1069/* This part must be outside protection */