On my newly installed system using kernel 3.2 I see a kworker-thread which is constantly consuming CPU. I\'d like to find out which part of kernel/module has created this workqu
An additional solution (that I've already posted in different thread not a while ago and maybe you can find there additional solutions to your problem) for these kinds of problems is to use the perf tool (It's not always enabled by default and you may need to install perf on your device).
Step 1: Set perf to record workqueue events:
perf record -e 'workqueue:*' -ag -T
Step 2: Run it as long as you think you need to catch the event (10 seconds should be ok if this event is frequent enough, but you can let it run longer, depending on the available free space you have left on your device) and then stop it with Ctrl + C
.
Step 3: Print the captured events (on Linux versions < 4.1 I think it should be -f and not -F):
perf script -F comm,pid,tid,time,event,trace
This will display something like this:
task-name pid/tid timestamp event
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
turtle 9201/9201 1473.339166: workqueue:workqueue_queue_work: work struct=0xef20d4c4 function=pm_runtime_work workqueue=0xef1cb600 req_cpu=8 cpu=1
turtle 9201/9201 1473.339176: workqueue:workqueue_activate_work: work struct 0xef20d4c4
kworker/0:3 24223/24223 1473.339221: workqueue:workqueue_execute_start: work struct 0xef20d4c4: function pm_runtime_work
kworker/0:3 24223/24223 1473.339248: workqueue:workqueue_execute_end: work struct 0xef20d4c4
Step 4: Analyzing the table above:
In the first row, a task named turtle (pid 9201)
is pushing the work pm_runtime_work
to the workqueue.
In the third row, we can see that the kworker/0:3 (pid 24223)
is executing that work.
Summary: Now back to your questions, we see that kworker/0:3
has been requested by turtle
task to run the pm_runtime_work
function.
So let's go back to the code and see what this pm_runtime_work
function does! Maybe here we'll manage to understand why it consumes so much CPU.