diff options
| -rw-r--r-- | include/trace/events/workqueue.h | 62 | ||||
| -rw-r--r-- | kernel/workqueue.c | 9 |
2 files changed, 71 insertions, 0 deletions
diff --git a/include/trace/events/workqueue.h b/include/trace/events/workqueue.h new file mode 100644 index 000000000000..49682d7e9d60 --- /dev/null +++ b/include/trace/events/workqueue.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #undef TRACE_SYSTEM | ||
| 2 | #define TRACE_SYSTEM workqueue | ||
| 3 | |||
| 4 | #if !defined(_TRACE_WORKQUEUE_H) || defined(TRACE_HEADER_MULTI_READ) | ||
| 5 | #define _TRACE_WORKQUEUE_H | ||
| 6 | |||
| 7 | #include <linux/tracepoint.h> | ||
| 8 | #include <linux/workqueue.h> | ||
| 9 | |||
| 10 | /** | ||
| 11 | * workqueue_execute_start - called immediately before the workqueue callback | ||
| 12 | * @work: pointer to struct work_struct | ||
| 13 | * | ||
| 14 | * Allows to track workqueue execution. | ||
| 15 | */ | ||
| 16 | TRACE_EVENT(workqueue_execute_start, | ||
| 17 | |||
| 18 | TP_PROTO(struct work_struct *work), | ||
| 19 | |||
| 20 | TP_ARGS(work), | ||
| 21 | |||
| 22 | TP_STRUCT__entry( | ||
| 23 | __field( void *, work ) | ||
| 24 | __field( void *, function) | ||
| 25 | ), | ||
| 26 | |||
| 27 | TP_fast_assign( | ||
| 28 | __entry->work = work; | ||
| 29 | __entry->function = work->func; | ||
| 30 | ), | ||
| 31 | |||
| 32 | TP_printk("work struct %p: function %pf", __entry->work, __entry->function) | ||
| 33 | ); | ||
| 34 | |||
| 35 | /** | ||
| 36 | * workqueue_execute_end - called immediately before the workqueue callback | ||
| 37 | * @work: pointer to struct work_struct | ||
| 38 | * | ||
| 39 | * Allows to track workqueue execution. | ||
| 40 | */ | ||
| 41 | TRACE_EVENT(workqueue_execute_end, | ||
| 42 | |||
| 43 | TP_PROTO(struct work_struct *work), | ||
| 44 | |||
| 45 | TP_ARGS(work), | ||
| 46 | |||
| 47 | TP_STRUCT__entry( | ||
| 48 | __field( void *, work ) | ||
| 49 | ), | ||
| 50 | |||
| 51 | TP_fast_assign( | ||
| 52 | __entry->work = work; | ||
| 53 | ), | ||
| 54 | |||
| 55 | TP_printk("work struct %p", __entry->work) | ||
| 56 | ); | ||
| 57 | |||
| 58 | |||
| 59 | #endif /* _TRACE_WORKQUEUE_H */ | ||
| 60 | |||
| 61 | /* This part must be outside protection */ | ||
| 62 | #include <trace/define_trace.h> | ||
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 2994a0e3a61c..8bd600c020e5 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -35,6 +35,9 @@ | |||
| 35 | #include <linux/lockdep.h> | 35 | #include <linux/lockdep.h> |
| 36 | #include <linux/idr.h> | 36 | #include <linux/idr.h> |
| 37 | 37 | ||
| 38 | #define CREATE_TRACE_POINTS | ||
| 39 | #include <trace/events/workqueue.h> | ||
| 40 | |||
| 38 | #include "workqueue_sched.h" | 41 | #include "workqueue_sched.h" |
| 39 | 42 | ||
| 40 | enum { | 43 | enum { |
| @@ -1790,7 +1793,13 @@ static void process_one_work(struct worker *worker, struct work_struct *work) | |||
| 1790 | work_clear_pending(work); | 1793 | work_clear_pending(work); |
| 1791 | lock_map_acquire(&cwq->wq->lockdep_map); | 1794 | lock_map_acquire(&cwq->wq->lockdep_map); |
| 1792 | lock_map_acquire(&lockdep_map); | 1795 | lock_map_acquire(&lockdep_map); |
| 1796 | trace_workqueue_execute_start(work); | ||
| 1793 | f(work); | 1797 | f(work); |
| 1798 | /* | ||
| 1799 | * While we must be careful to not use "work" after this, the trace | ||
| 1800 | * point will only record its address. | ||
| 1801 | */ | ||
| 1802 | trace_workqueue_execute_end(work); | ||
| 1794 | lock_map_release(&lockdep_map); | 1803 | lock_map_release(&lockdep_map); |
| 1795 | lock_map_release(&cwq->wq->lockdep_map); | 1804 | lock_map_release(&cwq->wq->lockdep_map); |
| 1796 | 1805 | ||
