Tracking Linux kworker threads


How to find out which part of kernel/module has created this workqueue.How to track a kworker-thread named for example ''kworker/0:3 to its origin in kernel-space?

I found this thread on lkml that answers your question a little. (It seems even Linus himself was puzzled as to how to find out the origin of those threads.)
Basically, there are two ways of doing this:
$ echo workqueue:workqueue_queue_work > /sys/kernel/debug/tracing/set_event
$ cat /sys/kernel/debug/tracing/trace_pipe > out.txt
(wait a few secs)
For this you will need ftrace to be compiled in your kernel, and to enable it with:
mount -t debugfs nodev /sys/kernel/debug
More information on the function tracer facilities of Linux is available in the ftrace.txt documentation.
This will output what threads are all doing, and is useful for tracing multiple small jobs.
cat /proc/THE_OFFENDING_KWORKER/stack
This will output the stack of a single thread doing a lot of work. It may allow you to find out what caused this specific thread to hog the CPU (for example). THE_OFFENDING_KWORKER is the pid of the kworker in the process list. _____ by anarcat

Comments

Popular posts from this blog

Airtel Digital tv remote factory reset and reprogram

Copy_to_user or copy_from_user instead of memcpy