• 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可能不支持。

  • 相关阅读:
    hadoop hdfs基本命令的java编码实现
    三维空间旋转和Three.JS中的实现
    Talk about VR
    Keras bug in model.predict
    How to compile tensorflow on CentOS
    熵(Entropy),交叉熵(Cross-Entropy),KL-松散度(KL Divergence)
    Two kinds of item classification model architecture
    Three failed attempts of handling non-sequential data
    How to setup Tensorflow inception-v3 model on Windows
    (译)三维空间中的几种坐标系
  • 原文地址:https://www.cnblogs.com/x_wukong/p/5992235.html
Copyright © 2020-2023  润新知