Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi,
I have problem understanding the below output from top and after spending some time searching on google, i decide to ask for help.
__________________________________________________________________________
cosmin@cosmin1:~$ top
top - 11:21:46 up 22 min, 1 user, load average: 0.71, 0.66, 0.51
Tasks: 118 total, 1 running, 117 sleeping, 0 stopped, 0 zombie
Cpu0 : 10.2%us, 23.3%sy, 0.0%ni, 66.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Cpu1 : 7.5%us, 26.4%sy, 0.0%ni, 66.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 4049884k total, 586612k used, 3463272k free, 43436k buffers
Swap: 4192252k total, 0k used, 4192252k free, 299656k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1156 bind 20 0 235m 18m 3024 S 83 0.5 18:31.87 named
1243 root 20 0 151m 18m 9744 S 0 0.5 0:01.36 Xorg
___________________________________________________________________________
From what i know, 66.5%id (in case of CPU0) means that in 66.5% of the time the CPU is idle, doing nothing. The rest of the time, 33.5% (10.2%us + 23.3%sy) is doing user and system tasks.
What is the meaning of 83% CPU usage for named process? Is it 83% of the 33.5%?
Or is it 83% from total CPU? If this is the case how come both CPU are idle for about 66%?
it shows 181.1% activity for mysql - which is quite close to the value 189.5 that you get adding up the "us" % values for all CPUs. Of course, we all know you can't add percentages like that!
What is the meaning of 83% CPU usage for named process? Is it 83% of the 33.5%?
No.
Quote:
Or is it 83% from total CPU?
No. It is the equivalent of 83% of one core. The OS switched that process between two cores. So 83% might mean 40% of one core plus 43% of another.
Quote:
If this is the case how come both CPU are idle for about 66%?
You really have only two CPUs ?
Sometimes the values you see in top are wrong due to sampling glitches. With two CPUs idle for the 132.5% of one core you showed, the total of all processes should be almost all of the remaining 67.5%, not more.
Quote:
Originally Posted by hairysocks
it shows 181.1% activity for mysql - which is quite close to the value 189.5 that you get adding up the "us" % values for all CPUs. Of course, we all know you can't add percentages like that!
I don't know "you can't add percentages like that" and the people who wrote top obviously didn't know it either. Because adding percentages like that is exactly what they are doing. The sy percentages are also included in the sum of percentages for the process that was selected at the time the sy CPU time was consumed. Your 181% is less than the sum of us and sy, because another process used a significant amount.
As I understand it, these figures are basically trying to be calculations of wall-time. And these figures are "apples and oranges."
For a processor (or core), the calculation shows how much wall-time that processor spent in various states during the sample period.
Meanwhile, for a process, the calculation shows how much wall-time the process spent running, or in various kinds of involuntary wait-states.
But what top really can't show you is how the running workload happened to distribute itself among the various processors/cores over that time period. Especially when the overall workload is light, this can be pretty-nigh impossible to rationalize. Sometimes, the numbers are "simply, obviously-nonsense," like 181%.
There are at least two useful things that you can take-away from top, however:
"Why are we waiting?" What is a process waiting on? (When it would prefer not to be waiting at all ...) Virtual-memory is a particular thing to be watching for.
"The 10,000-pound elephants in the room." Particular processes that are consuming a disproportionate amount of any resource, such that they delay others. (The "CPU" resource can generally be regarded as free-of-charge.)
The figures are generally best taken as "relative to one another, not absolute." The exact values are somewhat arbitrary, but the relationship among them over time can be useful.
Sometimes, the numbers are "simply, obviously-nonsense," like 181%.
It isn't nonsense. It is very well defined. It is % that process used of each processor summed over all processors. For example, it might have used 81% of one processor plus 60% of another, plus 40% of a third.
The task CPU% is non-normalised - a multi-threaded process may sum to (considerably) more than 100%. Each thread is limited by the laws of physics to 100% - i.e. equivalent to all of 1 "core".
If you are interested in "dynamic" usage numbers, you must ignore the first iteration of the top output - there is no "previous" entry to determine the delta, so uses the usage since boot for the summary, or process start for the task data. It is similar to the numbers expected from "ps".
Run "top -b -n 2 > somefile" and see the difference.
Thanks for your quick response. Now it is more clear to me how top works. In the mean time, i did find what named was doing to keep 83% CPU and solved it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.