This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

High CPU usage (99%) kswapd0 on ASG/UTM 9.305-4

Hi all,

I'm running ASG/UTM 9.305-4.

Every few days, I see a spike in CPU usage caused by kswapd0:

top - 09:35:30 up 6 days, 12:29,  1 user,  load average: 1.06, 1.03, 1.05
Tasks: 163 total,   2 running, 159 sleeping,   0 stopped,   2 zombie
Cpu(s):  0.0%us, 25.4%sy,  0.0%ni, 74.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3792464k total,  3519572k used,   272892k free,   364348k buffers
Swap:  4190204k total,    27428k used,  4162776k free,  1637560k cached

  PID USER      PR  NI  VIRT  RES  SHR S   %CPU %MEM    TIME+  COMMAND         
  338 root      20   0     0    0    0 R     99  0.0   3587:29 kswapd0          
 1152 root      20   0     0    0    0 S      1  0.0   3:55.21 scsi_eh_1        
13461 postgres  20   0  563m 9616 7936 S      1  0.3   0:00.46 postgres         
16318 root      20   0     0    0    0 S      1  0.0   0:00.31 kworker/0:2      
30871 postgres  20   0  562m 5888 4608 S      1  0.2   0:13.97 postgres         
    1 root      20   0  1916  572  516 S      0  0.0   0:02.47 init             
    2 root      20   0     0    0    0 S      0  0.0   0:00.02 kthreadd         
    3 root      20   0     0    0    0 S      0  0.0   0:11.24 ksoftirqd/0      
    5 root       0 -20     0    0    0 S      0  0.0   0:00.00 kworker/0:0H     
    7 root      RT   0     0    0    0 S      0  0.0   0:00.27 migration/0      
    8 root      20   0     0    0    0 S      0  0.0   0:01.98 rcu_bh           
    9 root      20   0     0    0    0 S      0  0.0   1:31.84 rcu_sched        
   10 root      RT   0     0    0    0 S      0  0.0   0:00.39 migration/1      
   11 root      20   0     0    0    0 S      0  0.0   0:02.81 ksoftirqd/1      
   13 root       0 -20     0    0    0 S      0  0.0   0:00.00 kworker/1:0H     
   14 root      RT   0     0    0    0 S      0  0.0   0:00.30 migration/2      
   15 root      20   0     0    0    0 S      0  0.0   0:01.62 ksoftirqd/2      


The CPU remains at this level until I restart the system. Has anyone else encountered this problem?

I've found that I can reduce the problem temporarily by using the following command to drop the kernel caches on the UTM:

echo 1 > /proc/sys/vm/drop_caches

which drops the CPU usage from kswapd0 down to zero for a while. Today, I noticed it was back. So I've put the command above in a cron job to run every hour for now, but I was wondering if there is another solution?

If it's of any help, the ASG/UTM runs on a Hypervisor (XenServer 6.5 build 90239c) with 4 CPUs and 4Gb of memory assigned to it.

Thanks,
Paulo


This thread was automatically locked due to age.
  • @dibido:

    Hello, can you try to add more vRAM to the machine (e.g. additional 4gb, so a total of 8gb)?

    Your free vRAM ist not critical, but a bit low, so swapping is a regular action by the kernel.
    How many services/users/bandwith are you using?

    How fast is your storage of the xen ?

    Also try to only using 2 vCPUs, maybe it's a problem with the cpu-scheduler, but i don't know how xen handles this.
  • I will try giving it 8Gb of RAM first and see how it goes; I'll try 2 CPUs if that doesn't work.

    I'm not running massive amounts of services. I'm running it at home, fronting a 80Mb DSL line. 
    Services wise, it's Firewall, Intrusion Prevention, Web Filtering, Remote Access and Antivirus/Spam etc..  There's only a few users and about 10 devices or so. Both the Hypervisor and the UTM VM are running on an SSD...

    I'll let you know how it goes.

    I got the idea for dropping the kernel caches from here:

    IBM High CPU usage of kswapd process causes system to become unresponsive - United States

    that actually suggests providing less memory, not more. There's a whole bunch of other discussions on the Internet regarding kswapd0 and kernel (Google search 'kswapd0 high cpu') which seems to indicate a bug in some version of more recent Linux kernels.

    Will let you know how it goes. Thanks for the help.
  • Hi all,

    I'm running ASG/UTM 9.305-4.

    Every few days, I see a spike in CPU usage caused by kswapd0:

    top - 09:35:30 up 6 days, 12:29,  1 user,  load average: 1.06, 1.03, 1.05
    Tasks: 163 total,   2 running, 159 sleeping,   0 stopped,   2 zombie
    Cpu(s):  0.0%us, 25.4%sy,  0.0%ni, 74.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Mem:   3792464k total,  3519572k used,   272892k free,   364348k buffers
    Swap:  4190204k total,    27428k used,  4162776k free,  1637560k cached

      PID USER      PR  NI  VIRT  RES  SHR S   %CPU %MEM    TIME+  COMMAND         
      338 root      20   0     0    0    0 R     99  0.0   3587:29 kswapd0          
     1152 root      20   0     0    0    0 S      1  0.0   3:55.21 scsi_eh_1        
    13461 postgres  20   0  563m 9616 7936 S      1  0.3   0:00.46 postgres         
    16318 root      20   0     0    0    0 S      1  0.0   0:00.31 kworker/0:2      
    30871 postgres  20   0  562m 5888 4608 S      1  0.2   0:13.97 postgres         
        1 root      20   0  1916  572  516 S      0  0.0   0:02.47 init             
        2 root      20   0     0    0    0 S      0  0.0   0:00.02 kthreadd         
        3 root      20   0     0    0    0 S      0  0.0   0:11.24 ksoftirqd/0      
        5 root       0 -20     0    0    0 S      0  0.0   0:00.00 kworker/0:0H     
        7 root      RT   0     0    0    0 S      0  0.0   0:00.27 migration/0      
        8 root      20   0     0    0    0 S      0  0.0   0:01.98 rcu_bh           
        9 root      20   0     0    0    0 S      0  0.0   1:31.84 rcu_sched        
       10 root      RT   0     0    0    0 S      0  0.0   0:00.39 migration/1      
       11 root      20   0     0    0    0 S      0  0.0   0:02.81 ksoftirqd/1      
       13 root       0 -20     0    0    0 S      0  0.0   0:00.00 kworker/1:0H     
       14 root      RT   0     0    0    0 S      0  0.0   0:00.30 migration/2      
       15 root      20   0     0    0    0 S      0  0.0   0:01.62 ksoftirqd/2      


    The CPU remains at this level until I restart the system. Has anyone else encountered this problem?

    I've found that I can reduce the problem temporarily by using the following command to drop the kernel caches on the UTM:

    echo 1 > /proc/sys/vm/drop_caches

    which drops the CPU usage from kswapd0 down to zero for a while. Today, I noticed it was back. So I've put the command above in a cron job to run every hour for now, but I was wondering if there is another solution?

    If it's of any help, the ASG/UTM runs on a Hypervisor (XenServer 6.5 build 90239c) with 4 CPUs and 4Gb of memory assigned to it.

    Thanks,
    Paulo


    how many users and which features?  You aren't swapping that much though.  I would throw in 4 more gigs of ram(make sure you installed in 64 bit mode not 32 bit or you will have to reinstall)
  • Hi all. A quick update. I've given the UTM 6Gb of memory, and so far the problem has disappeared. It used to appear every few days, but it's been two weeks and no issues. I will continue to keep an eye on it, and if it comes back I will let you know.

    I should also mention that in that period, the UTM was also upgraded to 9.306-6...

    But for now, it would seem giving it more memory (or the recent upgrades) has done the trick.