2

On an almost daily basis my laptop is stuck. In most cases I need to turn off the machine manually and restart it. In those cases CPU is very busy and memory seems to be used heavily.

Memory: 8GB

CPU: Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz

This happens, when I use different apps, like a browser, eclipse and Microsoft Teams, but the combination of running apps seems to be pretty random.

Output of top

~~Now I can see some processes are using very much CPU, but what exactly is kswapd0 and kworker?~~ I guess, that my system is misconfigured, the current guess is that the swapfile is too small. How can this be increased / controlled?

$ uname -r
>> 5.4.0-54-generic

$ lsb_release -a >> Description: Ubuntu 20.04.1 LTS

Edit regarding the swapfile in a LVM disks system

~$ grep -i swap /etc/fstab
/dev/mapper/vgubuntu-swap_1 none            swap    sw              0       

free -h confirms, that my swapfile is Swap: 975Mi big.

Edit

Here is the Linux bug, but it seems to be marked as invalid. For whatever reason.

And a possible solution (not confirmed yet!): https://bugs.launchpad.net/ubuntu/+source/linux/+bug/887793/comments/170

heynnema
  • 70,711
BairDev
  • 149
  • 1
  • 1
    Against common belief, this is not normal, is not expected to go away by itself. It is a bug of linux. The post marked as a duplicate of this question, and many other accepted answers do not provide a solution. A fix for Ubuntu 12.04 worked for me on 19.10, and I need to do this up to 20.20. See accepted answer in https://askubuntu.com/questions/176565/why-does-kworker-cpu-usage-get-so-high. – vanadium Nov 19 '20 at 13:48
  • @vanadium you mean, this is an 8 years old bug? – BairDev Nov 19 '20 at 14:20
  • Edit your question and show me free -h and grep -i swap /etc/fstab and ls -alh /swapfile. Start comments to me with @heynnema or I'll miss them. – heynnema Nov 20 '20 at 00:14
  • 1
    The pos is eight years old indeed. I have the issue, and that tread helped me out. Looking at your screenshot, I would agree with heynnema that for you, it looks rather looks like a memory problem than a kworker running away, so try the solution of heynnema first. – vanadium Nov 20 '20 at 10:18
  • In "top", you can use > to sort on a different column (by default it sorts on CPU). Could be interesting to see where all your memory goes. I find it strange that a 8 GB RAM system is blocked by only firefox and eclipse. – vanadium Nov 20 '20 at 10:24
  • @heynnema I've added the results for checking the swapfile, but I am confused. I have no idea, what the /swap/core ... stuff is. – BairDev Nov 20 '20 at 10:56
  • Oh, you're using LVM disks, and my answer wasn't for that configuration, so I had to delete my answer. The problem that needs fixing is that your swap (/dev/mapper/vgubuntu-swap_1) is too small. I don't know how to work with LVM disks. I'd suggest changing your question to "How do I increase swap on LVM disk configuration?", and see if you can set your swap size to 4G. That should fix your problem. – heynnema Nov 20 '20 at 13:25
  • @vanadium Show me your free -h and sysctl vm.swappiness. – heynnema Nov 20 '20 at 15:56

1 Answers1

0

My solution:

Create a new swapfile

I've tried to increase the size of the swap_1 volume, but it failed. Probably because there was no space left in the volume group. I have used these instructions and got something like

# fsadm: Filesystem "swap" on device "/dev/mapper/vgubuntu-swap_1" is not supported by this tool.

for

$ lvresize -L +5G --resizefs vgubuntu/swap_1

Swapfile

I have used this answer.

Now I can see:

$ sudo swapon -s

Filename Type Size Used Priority

/swap_2 file 5119996 830464 -2

/dev/dm-2 partition 999420 0 -3

BairDev
  • 149