3

On Ubuntu 16.04 computer I saw kworker take up 80% of a CPU, consistently.

I generated a perf report:

  • sudo apt-get install linux-tools-common linux-tools-$(uname -r)
  • Record some 10 seconds of backtraces on all CPUs sudo perf record -g -a sleep 10
  • View it with sudo perf report.

Top few results are:

Samples: 47K of event 'cycles:ppp', Event count (approx.): 38282161158
  Children      Self  Command          Shared Object                  Symbol
+   77.04%     0.00%  kworker/3:3      [kernel.kallsyms]              [k] ret_from_fork
+   77.04%     0.00%  kworker/3:3      [kernel.kallsyms]              [k] kthread
+   77.04%     0.00%  kworker/3:3      [kernel.kallsyms]              [k] worker_thread
+   77.00%     0.13%  kworker/3:3      [kernel.kallsyms]              [k] process_one_work
+   76.26%     0.04%  kworker/3:3      [kernel.kallsyms]              [k] rpm_idle
+   75.98%     0.06%  kworker/3:3      [kernel.kallsyms]              [k] rpm_suspend
+   75.97%     0.03%  kworker/3:3      [kernel.kallsyms]              [k] pm_runtime_work
+   75.84%     0.03%  kworker/3:3      [kernel.kallsyms]              [k] __rpm_callback
+   75.82%     0.01%  kworker/3:3      [kernel.kallsyms]              [k] usb_runtime_idle
+   75.76%     0.00%  kworker/3:3      [kernel.kallsyms]              [k] __pm_runtime_suspend
+   75.64%     0.00%  kworker/3:3      [kernel.kallsyms]              [k] rpm_callback
+   75.61%     0.04%  kworker/3:3      [kernel.kallsyms]              [k] usb_runtime_suspend
+   75.51%     0.03%  kworker/3:3      [kernel.kallsyms]              [k] usb_suspend_both
+   73.51%     0.15%  kworker/3:3      [kernel.kallsyms]              [k] usb_control_msg
+   71.97%     0.14%  kworker/3:3      [kernel.kallsyms]              [k] usb_start_wait_urb
+   68.38%     0.05%  kworker/3:3      [kernel.kallsyms]              [k] usb_submit_urb
+   68.33%     0.30%  kworker/3:3      [kernel.kallsyms]              [k] usb_submit_urb.part.8
+   67.75%     0.82%  kworker/3:3      [kernel.kallsyms]              [k] usb_hcd_submit_urb
+   60.96%    60.41%  kworker/3:3      [kernel.kallsyms]              [k] xhci_hub_control
+   55.99%     0.12%  kworker/3:3      [kernel.kallsyms]              [k] hub_suspend
+   54.97%     0.04%  kworker/3:3      [kernel.kallsyms]              [k] set_port_feature
+   19.36%     0.01%  kworker/3:3      [kernel.kallsyms]              [k] usb_resume_interface.isra.8
+   19.35%     0.02%  kworker/3:3      [kernel.kallsyms]              [k] hub_resume
+   19.32%     0.14%  kworker/3:3      [kernel.kallsyms]              [k] hub_activate
+   18.78%     0.08%  kworker/3:3      [kernel.kallsyms]              [k] hub_ext_port_status
+   11.13%     0.00%  ksoftirqd/3      [kernel.kallsyms]              [k] ret_from_fork
+   11.13%     0.00%  ksoftirqd/3      [kernel.kallsyms]              [k] kthread
+   10.44%     0.51%  ksoftirqd/3      [kernel.kallsyms]              [k] smpboot_thread_fn

I do not know how to reproduce. It goes away after a reboot. What is going on?

3

Same problem here on a Dell XPS laptop and kernel 4.4.0-130

I fixed it by disabling dynamic USB power management in kernel

I added usbcore.autosuspend=-1 to my kernel's boot command line:

GRUB_CMDLINE_LINUX_DEFAULT="<existing stuff> usbcore.autosuspend=-1"
  • To do that permanently, open the grub configuration file

    sudo nano /etc/default/grub
    

and add the flag described above.

  • Next you have to update your grub via

    sudo update-grub
    
  • After reboot, everything should be fine, the busy CPU is now free for doing something useful :)

Disabling dynamic PM might impact battery life when you have USB devices connected, but few USB devices are able to handle this mode....

  • Thanks- seems to work for me! – Fergie Jul 16 at 7:14
0

I used to have a similar problem on a Dell laptop. I read it was due to a bug of the kernel and it could be tempered by flushing some kernel cache by writing some values to some file in /sys, but I doubt this will help you.

I know kworker processes cannot be killed. If I'm to believe other answers to the same question on Askubuntu/Unix, kworker are placeholder processes corresponding to the activity of the kernel.

The solutions proposed below are the sorted from most obvious and likely to yield results (if yet untried), to the less likely.

Just in case you haven't done so yet, I suggest you update your kernel to the last available version of the repositories (sudo apt update). Updating the kernel usually requires a restart to see the effect.

Otherwise, you could try installing Ubuntu 18.04, whose kernel version is 4.15.0-22 and probably integrates a fix.

If you've googled your question, you've probably already found bug reports matching your description. You should read through the comments they sometimes contain solutions or workarounds. The link below appear to closely match yours, though it is a bit intriguing because the fix should have arrived into the Ubuntu kernel by now (comment #18).

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1488426

Something I didn't try when I met the bug was using cpu limiting application like cpulimit or cputool (sudo apt install cpulimit or sudo apt install cputool). I have no idea whether there is any chance for this approach to work. I doubt it can work with such a non-standard process.


Note: You may want to add the output of uname -mr to your question and future questions whenever related to the Linux kernel.

Write an answer if you find something working.

  • Thanks for your reply, however what you proposed are not actionable items for me. - Can't update the kernel because some drivers don't work well, but this remains a possible fix. - Can't update to Ubuntu 18 yet as there are program build issues, mainly needing cuda 8. - Not a good idea to limit the cpu because we need the compute resource. - Haven't found a fix yet. I'll post if I find something. – sunapi386 Jun 14 '18 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.