Find out what a kworker does

kernellinuxperformanceprocess

I have kworker processes, which regularly enters D state. My computer also becomes laggy, which I think may be due to D state kworkers. Usually, these processes run with a command similar to this: kworker/u16:2

I was told that D state processes may be due to bad drivers or hardware. I would like to find out which driver or hardware is affected. How can I find out which of these processes do what?

Any way how to investigate that?

Best Answer

There is a good article from RedHat on finding out what code kworker threads are running. Please see https://access.redhat.com/solutions/4388131

Here is an excerpt from the article:

On Red Hat Enterprise Linux 7 the ftrace subsystem and trace-cmd command can provide information about what functions the kworker and softirq kernels threads are running.

# trace-cmd record -e workqueue:workqueue_queue_work
# trace-cmd report > trace.log

You can get list of the most frequently queued to least frequently queued workqueue functions with the following:

# grep -o -e "function=[_a-zA-Z_][_a-zA-Z0-9]*" trace.log|sort|uniq -c |sort -rn
Related Question