Sometimes, while watching the process list utility top, htop or ps you can find there is a kworker process. This process can take a lot of CPU resources and memory, but just to kill you can not, will not allow the system. In today’s article we will understand what kind of process kworker Linux why you need it, and how to cope with the high resource consumption of the process.
The fact that kworker is a process that combines all processes running in the Linux kernel. High CPU / memory usage of this process means that the kernel does any work.
What is a kworker process in Linux
Kworker is responsible for all operations that are performed at the kernel level. It’s different timers, interrupts, input/output and so on. Such processes can be multiple for multiple CPU cores. Example: kworker:0, kworker:1 and so on. To see what processes are, and how they consume resources, you can use top, which must be run as root:
Or using the ps utility:
sudo ps aux | grep kworker
Here you can see the number of processes and how kworker loads the CPU. This process usually is not associated directly with the system software. High resource consumption can cause certain kernel modules or programs that tell the kernel to do a particular job. If you need to reduce the load, you just need to ask the kernel not to do the work that it does. For this you first need to understand what it does.
To solve this problem you can use the perf utility. To install the utility it is necessary to know the kernel version:
Now install the packages kernel tools for this version:
sudo install apt install linux-tools-common linux-tools-5.4.0-29-generic
First, record 10 seconds of logs of the cores. To do this, run:
sudo perf record-g-a sleep 10
Left open the report and find out what overload the system:
sudo perf report
Here the first two columns indicate the percentage of events of a given type relative to the total number of events. The third column specifies the process for which was gathered events, the fourth column is the ELF file of the event. If the event was in the library, here you will see the library file. Using the last column you can determine where the event occurred in the kernel space [k] or in user space [.]. With this information you will be able to determine what part of the kernel creates a burden to disable unnecessary functionality or to correct errors.
Now you know what is kworker and what to do with it. Also when the high resource consumption of the process kworker you can try to upgrade the kernel, remove unnecessary programs, disable unnecessary hardware and restart the computer.