I am running a multithreaded program on my 8-core processor. top
command shows 8 processes are running and each one utilizes a core by 100%. The problem is that only 21% are marked as user cpu and my application is running so slow:
Cpu(s): 20.6%us, 79.4%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
How can I find further information about the system processes those which have taken 79% of the CPU time? Specifically, I want to know what are these system calls.
Thanks in advance!
EDIT: This is what top returns:
top - 11:23:04 up 83 days, 1:20, 10 users, load average: 8.00, 8.00, 8.00
Tasks: 267 total, 10 running, 257 sleeping, 0 stopped, 0 zombie
Cpu(s): 40.6%us, 17.4%sy, 0.0%ni, 41.9%id, 0.0%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 16324640k total, 5645008k used, 10679632k free, 285368k buffers
Swap: 2047992k total, 32064k used, 2015928k free, 4584140k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
27262 ahmad 20 0 308m 32m 18m R 102.2 0.2 5022:32 Espresso
26872 ahmad 20 0 176m 12m 4540 R 100.0 0.1 5087:05 Espresso
27263 ahmad 20 0 175m 13m 4824 R 100.0 0.1 5022:35 Espresso
27265 ahmad 20 0 175m 12m 4508 R 100.0 0.1 5022:35 Espresso
26869 ahmad 20 0 308m 31m 18m R 98.3 0.2 5086:20 Espresso
26870 ahmad 20 0 175m 13m 4864 R 98.3 0.1 5087:05 Espresso
26871 ahmad 20 0 176m 12m 4592 R 98.3 0.1 5086:58 Espresso
27264 ahmad 20 0 176m 12m 4552 R 98.3 0.1 5022:06 Espresso
1 root 20 0 19404 1164 940 S 0.0 0.0 0:02.12 init
2 root 20 0 0 0 0 S 0.0 0.0 0:02.81 kthreadd
It's time spent executing kernel code, but this does not mean that it has been triggered by system calls. For instance, it could be time spent reading large directories, but it could also be time spent handling
iptables
rules, or something else.You can install the relevant package (it could be named
linux-tools-2.6
, but it depends on your distribution) and useperf top
to look at what code the kernel is running. Read more here aboutperf
.First of all.
man top
Here are some examplesCPU utilization from highest to lowest or vice versa
SHIFT+r
MEM usage
SHIFT+m
k = kill a process by it's pid