aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Mickler <florian@mickler.org>2011-03-31 07:40:42 -0400
committerTejun Heo <tj@kernel.org>2011-03-31 07:40:42 -0400
commite2de9e0862778f4aba103027ce575efbddb8117f (patch)
tree22e002c6a8a56f5bcd5897fabd568ec54e243ca9
parent6aba74f2791287ec407e0f92487a725a25908067 (diff)
workqueue: Document debugging tricks
It is not obvious how to debug run-away workers. These are some tips given by Tejun on lkml. Signed-off-by: Florian Mickler <florian@mickler.org> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--Documentation/workqueue.txt40
1 files changed, 40 insertions, 0 deletions
diff --git a/Documentation/workqueue.txt b/Documentation/workqueue.txt
index 01c513fac40e..a0b577de918f 100644
--- a/Documentation/workqueue.txt
+++ b/Documentation/workqueue.txt
@@ -12,6 +12,7 @@ CONTENTS
124. Application Programming Interface (API) 124. Application Programming Interface (API)
135. Example Execution Scenarios 135. Example Execution Scenarios
146. Guidelines 146. Guidelines
157. Debugging
15 16
16 17
171. Introduction 181. Introduction
@@ -379,3 +380,42 @@ If q1 has WQ_CPU_INTENSIVE set,
379* Unless work items are expected to consume a huge amount of CPU 380* Unless work items are expected to consume a huge amount of CPU
380 cycles, using a bound wq is usually beneficial due to the increased 381 cycles, using a bound wq is usually beneficial due to the increased
381 level of locality in wq operations and work item execution. 382 level of locality in wq operations and work item execution.
383
384
3857. Debugging
386
387Because the work functions are executed by generic worker threads
388there are a few tricks needed to shed some light on misbehaving
389workqueue users.
390
391Worker threads show up in the process list as:
392
393root 5671 0.0 0.0 0 0 ? S 12:07 0:00 [kworker/0:1]
394root 5672 0.0 0.0 0 0 ? S 12:07 0:00 [kworker/1:2]
395root 5673 0.0 0.0 0 0 ? S 12:12 0:00 [kworker/0:0]
396root 5674 0.0 0.0 0 0 ? S 12:13 0:00 [kworker/1:0]
397
398If kworkers are going crazy (using too much cpu), there are two types
399of possible problems:
400
401 1. Something beeing scheduled in rapid succession
402 2. A single work item that consumes lots of cpu cycles
403
404The first one can be tracked using tracing:
405
406 $ echo workqueue:workqueue_queue_work > /sys/kernel/debug/tracing/set_event
407 $ cat /sys/kernel/debug/tracing/trace_pipe > out.txt
408 (wait a few secs)
409 ^C
410
411If something is busy looping on work queueing, it would be dominating
412the output and the offender can be determined with the work item
413function.
414
415For the second type of problems it should be possible to just check
416the stack trace of the offending worker thread.
417
418 $ cat /proc/THE_OFFENDING_KWORKER/stack
419
420The work item's function should be trivially visible in the stack
421trace.