aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/workqueue.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r--kernel/workqueue.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 32f8e0d2bf5a..b6b966ce1451 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -33,6 +33,7 @@
33#include <linux/kallsyms.h> 33#include <linux/kallsyms.h>
34#include <linux/debug_locks.h> 34#include <linux/debug_locks.h>
35#include <linux/lockdep.h> 35#include <linux/lockdep.h>
36#include <trace/workqueue.h>
36 37
37/* 38/*
38 * The per-CPU workqueue (if single thread, we always use the first 39 * The per-CPU workqueue (if single thread, we always use the first
@@ -123,9 +124,13 @@ struct cpu_workqueue_struct *get_wq_data(struct work_struct *work)
123 return (void *) (atomic_long_read(&work->data) & WORK_STRUCT_WQ_DATA_MASK); 124 return (void *) (atomic_long_read(&work->data) & WORK_STRUCT_WQ_DATA_MASK);
124} 125}
125 126
127DEFINE_TRACE(workqueue_insertion);
128
126static void insert_work(struct cpu_workqueue_struct *cwq, 129static void insert_work(struct cpu_workqueue_struct *cwq,
127 struct work_struct *work, struct list_head *head) 130 struct work_struct *work, struct list_head *head)
128{ 131{
132 trace_workqueue_insertion(cwq->thread, work);
133
129 set_wq_data(work, cwq); 134 set_wq_data(work, cwq);
130 /* 135 /*
131 * Ensure that we get the right work->data if we see the 136 * Ensure that we get the right work->data if we see the
@@ -257,6 +262,8 @@ int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
257} 262}
258EXPORT_SYMBOL_GPL(queue_delayed_work_on); 263EXPORT_SYMBOL_GPL(queue_delayed_work_on);
259 264
265DEFINE_TRACE(workqueue_execution);
266
260static void run_workqueue(struct cpu_workqueue_struct *cwq) 267static void run_workqueue(struct cpu_workqueue_struct *cwq)
261{ 268{
262 spin_lock_irq(&cwq->lock); 269 spin_lock_irq(&cwq->lock);
@@ -275,7 +282,7 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
275 */ 282 */
276 struct lockdep_map lockdep_map = work->lockdep_map; 283 struct lockdep_map lockdep_map = work->lockdep_map;
277#endif 284#endif
278 285 trace_workqueue_execution(cwq->thread, work);
279 cwq->current_work = work; 286 cwq->current_work = work;
280 list_del_init(cwq->worklist.next); 287 list_del_init(cwq->worklist.next);
281 spin_unlock_irq(&cwq->lock); 288 spin_unlock_irq(&cwq->lock);
@@ -746,6 +753,8 @@ init_cpu_workqueue(struct workqueue_struct *wq, int cpu)
746 return cwq; 753 return cwq;
747} 754}
748 755
756DEFINE_TRACE(workqueue_creation);
757
749static int create_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu) 758static int create_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu)
750{ 759{
751 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; 760 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
@@ -768,6 +777,8 @@ static int create_workqueue_thread(struct cpu_workqueue_struct *cwq, int cpu)
768 sched_setscheduler_nocheck(p, SCHED_FIFO, &param); 777 sched_setscheduler_nocheck(p, SCHED_FIFO, &param);
769 cwq->thread = p; 778 cwq->thread = p;
770 779
780 trace_workqueue_creation(cwq->thread, cpu);
781
771 return 0; 782 return 0;
772} 783}
773 784
@@ -849,6 +860,8 @@ struct workqueue_struct *__create_workqueue_key(const char *name,
849} 860}
850EXPORT_SYMBOL_GPL(__create_workqueue_key); 861EXPORT_SYMBOL_GPL(__create_workqueue_key);
851 862
863DEFINE_TRACE(workqueue_destruction);
864
852static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq) 865static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq)
853{ 866{
854 /* 867 /*
@@ -872,6 +885,7 @@ static void cleanup_workqueue_thread(struct cpu_workqueue_struct *cwq)
872 * checks list_empty(), and a "normal" queue_work() can't use 885 * checks list_empty(), and a "normal" queue_work() can't use
873 * a dead CPU. 886 * a dead CPU.
874 */ 887 */
888 trace_workqueue_destruction(cwq->thread);
875 kthread_stop(cwq->thread); 889 kthread_stop(cwq->thread);
876 cwq->thread = NULL; 890 cwq->thread = NULL;
877} 891}