You don't necessarily understand. CPU Display Information

Source: Internet
Author: User

You will see this line when you use the top command:

650) this.width=650; "title=" image () "border=" 0 "alt=" image () "Src=" http://image.mamicode.com/info/201606/ 20181018163955000369.png "width=" 1096 "height=" "style=" border:0px;padding-top:0px;padding-left:0px; Padding-right:0px;background-image:none; "/>

What are the meanings of each of these values?

Asked this question today, I found that the answer is not very clear. Sure enough, every day with the most top command has not been well-acquainted ... Ashamed... So I looked up some information:

Official explanation

The CPU (s) represents the CPU information. The meaning of each value is:

Us:user CPU time (or)% CPU time spent in user spaceSy:system CPU time (or)% CPU time spent in kernel spaceNi:user Nice CPU time (or)% CPU time spent on low priority processesId:idle CPU time (or)% CPU time spent idleWa:io Wait CPU time (or)% CPU time spent in wait (on disk)hi:hardware IRQ (or)% CPU time spent servicing/handling hardware interruptssi:software IRQ (or)% CPU time spent servicing/handling software interruptsst:steal Time--% CPU time in involuntary wait to virtual CPU while hypervisor is servicing another processor (or) % CPU time stolen from a virtual machine

Translation:US: User state uses CPU time ratioSY: System state uses a CPU time rationi: User-configured CPU time ratio for a nice-weighted process allocationID: Idle CPU time compared towa:cpu waiting for disk write completion timehi: Hard Interrupt consumption timesi: Soft interrupt consumption timeST: Virtual machine steal Time

Well, if it's a list of the above rules that I understand, it's self-deception. Here's my own understanding.

first of all, how is this percentage calculated?

For example, there are 100 CPU time slices in a second, this CPU time slice is the smallest unit of CPU work. Then these 100 CPU time slices are used in different areas and for the purpose, which represents the CPU time ratio occupied by this area. This is the percentage of CPU time that is drawn here.

For example, one of the following programs:

650) this.width=650; "title=" image (+) "border=" 0 "alt=" image (+) "src=" http://image.mamicode.com/info/201606/ 20181018163955377336.png "width=" 389 "height=" 490 "style=" border:0px;padding-top:0px;padding-left:0px; Padding-right:0px;background-image:none; "/>

Copies the file from the SRC location of the disk to the DST location of the disk. The file is read into the kernel space from SRC, then read to the user space, then copy the data to the buf of the user space, then through the user space, kernel space, data to the disk DST.

So from the above program, the CPU consumption in kernel space is the SY (System State CPU percentage), CPU consumption in user space is the US (User state CPU percentage used).

All right, here's the Hi and Si .

If the program is not a problem, then there is no hi and Si, but there is actually a hard interrupt and soft interrupt concept. For example, a hard interrupt, the CPU in the execution of the program, suddenly peripheral hardware (such as hard disk problems) The machine needs to immediately notify the CPU for onsite storage work. This time the CPU will have a context switch. Is that the CPU will be a part of the time will be hard interrupt occupation, this time is hi. Similarly, SI is the CPU time of the soft interrupt, and the soft interrupt is triggered by the software's instruction mode.

The concepts of related soft interrupts and hard interrupts can be consulted:

http://blog.csdn.net/pxz_002/article/details/7327668

here is the NI

NI is nice, what is nice, every Linux process has a priority, high priority process has priority to execute the right, this is called the PRI. In addition to the priority, the process has a priority correction value. That is, if your original priority is 20, then the correction value is-2, then your final process priority is 18. This correction value is called the nice value of the process.

so nice is a process of priority correction, why does it take up CPU time?

NI refers to the user-state CPU time ratio used for the nice-weighted process, and my understanding is that the so-called correction value of a process means allocating some CPU time to the user state of the process, and the CPU time allocated by this middle is our NI. (This understanding is not very sure, if you have the wrong trouble to help point out the next)

here is WA

WA refers to the time that the CPU waits for the disk write to complete, that is, if the IO operation is to take place, the CPU waits while the IO is in progress. For example, the above program, the last step, from the system space to the DST hard disk space, if the program is blocked, then this time the CPU will wait for data to write to the disk to complete the write operation. So this time the CPU waits is WA.

so if a machine sees WA particularly high, then the general explanation is that there is a problem with disk IO, and you can continue with the detailed analysis using commands such as Iostat. here is the St

ST's name is very vivid, steal ... is specifically for virtual machines, a physical can be virtualized out of several virtual machines. On one of the virtual machines with top view found St is not 0, it means that there are so many CPU time is scheduled to me this virtual machine, but due to some kind of virtual technology, this CPU time allocated to other virtual machines. This is called stealing.

ID

The remaining ID is the CPU time slice except for the CPU processing context above. Of course, on these time slices, the CPU is idle.

all of these CPU time on top should be added to 100%. Dstat

aside, there is a dstat command that can also be used to view CPU information. Is Dstat-c's display.

650) this.width=650; "Title=" Image ("border=" 0 "alt=" image () "Src=" http://image.mamicode.com/info/201606/ 20181018163955773836.png "width=" 359 "height=" 263 "style=" border:0px;padding-top:0px;padding-left:0px; Padding-right:0px;background-image:none; "/>

It is easy to match usr and us,sys with Sy,idl and Id,wai and Wa,hig and Hi,siq and Si.

But it can be observed that Dstat is not st,ni statistics, and all its parts combined together may not be 100, which means that Dstat actually does not do CPU statistics on St,ni. Pay attention to this when using.

Reference article:

Http://hi.baidu.com/higkoo/item/70600834426247483075a1df

http://blog.csdn.net/codestinity/article/details/7496962

Http://book.51cto.com/art/200812/99435.htm

Http://unix.stackexchange.com/questions/18918/in-linux-top-command-what-are-us-sy-ni-id-wa-hi-si-and-st-for-cpu-usage


This article is from the "LINUX Super Dream" blog, make sure to keep this source http://215687833.blog.51cto.com/6724358/1787142

You don't necessarily understand. CPU Display Information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.