CPU狀態信息us,sy,ni,id,wa,hi,si,st含義


轉自:http://blog.csdn.net/sasoritattoo/article/details/9318893

轉自:http://fishermen.iteye.com/blog/1995862

 

使用系統命令top即可看到如下類似信息:
Cpu(s):  0.0%us,  0.5%sy,  0.0%ni, 99.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
但不知什么含義?google之
 
        
I try to explain  these:
us: is meaning of "user CPU time"
sy: is meaning of "system CPU time"
ni: is meaning of" nice CPU time"
id: is meaning of "idle"
wa: is meaning of "iowait" 
hi:is meaning of "hardware irq"
si : is meaning of "software irq"
st : is meaning of "steal time"

中文翻譯為:

us 用戶空間占用CPU百分比
sy 內核空間占用CPU百分比
ni 用戶進程空間內改變過優先級的進程占用CPU百分比
id 空閑CPU百分比
wa 等待輸入輸出的CPU時間百分比
hi 硬件中斷
si 軟件中斷 
st: 實時

===========================================================================================================================================

對Linux 網卡軟中斷做負載均衡

 

測試中發現服務器整體負載較低,但有cpu負載特別高,其中一個cpu幾乎一半是軟中斷si,特別忙,而還有的cpu特別空閑。

Java代碼   收藏代碼
  1. top - 16:12:08 up 31 days,  3:52,  1 user,  load average: <span style="color: #ff0000;">0.11, 0.11, 0.06</span>  
  2. Tasks: 242 total,   4 running, 238 sleeping,   0 stopped,   0 zombie  
  3. Cpu0  : 12.3%us, 14.6%sy,  0.0%ni, 70.2%id,  0.0%wa,  0.0%hi,  3.0%si,  0.0%st  
  4. Cpu1  : 21.6%us, 22.9%sy,  0.0%ni,  7.3%id,  0.0%wa,  0.0%hi, <span style="color: #ff0000;">48.2%si</span>,  0.0%st  
  5. Cpu2  : 16.5%us, 19.1%sy,  0.0%ni, 43.9%id,  0.0%wa,  0.0%hi, 20.5%si,  0.0%st  
  6. Cpu3  :  2.3%us,  2.6%sy,  0.0%ni, 94.1%id,  0.0%wa,  0.0%hi,  1.0%si,  0.0%st  
  7. Cpu4  :  0.3%us,  0.3%sy,  0.0%ni, 99.3%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st  

       先用mpstat -I SUM -P ALL 5 來看一下每個cpu的終端情況,發現cpu1和cpu2處理的中斷確實很多,是什么dd在使用這兩個cpu做中斷呢?

Java代碼   收藏代碼
  1. # mpstat -I SUM -P ALL 5  
  2. Linux 2.6.32-220.13.1.el6.x86_64 (talus186)     12/26/2013  _x86_64_    (12 CPU)  
  3.   
  4. 04:15:18 PM  CPU    intr/s  
  5. 04:15:23 PM  all  62422.60  
  6. 04:15:23 PM    0      0.00  
  7. 04:15:23 PM    1  21566.20  
  8. 04:15:23 PM    2  12123.00  
  9. 04:15:23 PM    3      0.00  
  10. 04:15:23 PM    4      1.00  

      使用 cat /proc/interrupts 查看中斷情況,間隔幾秒后再次cat /proc/interrupts,然后比較對應值的變化,發現eth0-1、eth0-2等使用cpu1、cpu2做中斷,這兩個對應的中斷號分別是95,96...

 

Java代碼   收藏代碼
  1. 95:         33  325897741          0   30997484         72          0   93968731          0          0          0        426        864  IR-PCI-MSI-edge      eth0-1  
  2.  96:         50        206   66609822        117          0          0          0          0          0          0          0   24437509  IR-PCI-MSI-edge      eth0-2  
     注:網卡(包括磁盤等外設)需要cpu服務時,都會拋出一個中斷,中斷告訴cpu發生了什么事情,cpu就要停止目前的工作來處理這個中斷。比如當網卡收到包時,假如cpu正在執行某個應用進程處理程序,此刻就會被網卡中斷所打斷執行中斷處理程序。每個外設對應的中斷處理程序自然是不同的,因此為了進行區分,防止多個設備發出相同的中斷請求,系統中的每個設備都被分配了一個獨一無二的IRQ(Interupt Request),上面95、96就是所謂的IRQ,如果網卡有多隊列,每個隊列可以對應一個IRQ(參考net)。

      在使用 cat /proc/irq/95/smp_affinity cat /proc/irq/smp_affinity 等看出網卡的隊列都在使用cpu1 和cpu2

Java代碼   收藏代碼
  1. cat /proc/irq/95/smp_affinity  
  2. 00000002  
  3. cat /proc/irq/96/smp_affinity  
  4. 00000004  

      好了,把空閑的cpu用上來分攤網卡中斷

Java代碼   收藏代碼
  1. echo 08 > /proc/irq/97/ smp_affinity  
  2. echo 10 > /proc/irq/98/ smp_affinity  
  3. ...  

      再進行測試,發現cpu消耗整體還不夠均衡,TOP下使用f,然后再加j,發現應用進程使用的cpu與網卡中斷使用的cpu重合,再把單線程應用進程綁定到其他CPU,終於均衡下來。

      最后,網卡軟中斷綁定cpu需要滿足幾個條件:1 linux內核版本必須在2.4+; 2 網卡對應的中斷控制器必須是IO-APIC芯片,且需啟用IO-APIC;3 部分CPU可能不支持。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM