`
youlong699
  • 浏览: 21833 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

load 与 cpu use

 
阅读更多
引自一个load 飙到20 (5核), 单cpu idle在80%多的case 。
木名-内核(09:52:24):
load是采集一个瞬间的运行进程和uninterruptible进程进行计算,cpu利用率是整个时间段的繁忙程度,不是很一样
木名-内核(09:53:41):
比如在1ms里面,有100us会有5个线程排队处理,其他900us没有,那么你看到的oad可能是5,但是cpu利用率只有10%

 

狄卢(09:57:51):
那load 分1分 5分 15分 三种值,让人感觉是平均值。但实际上,也是在1分钟之内采集若干个瞬间值做平均?

 

木名-内核(10:02:35):
是的,系统是每5s采集一次

 

木名-内核(10:04:13):
大部分情况下,load能够和cpu利用率符合,但是碰到一些特殊的情况,比如刚好每5s采集的时候运行进程很多,其他时间运行进程很少,这个时候load就会和cpu利用率有偏差

 

狄卢(10:05:25):
哦。。 那这样。。 你昨天看到就是这种进程经常波动的是吧? 进程数量波动从哪里能看处理呢 , 呵呵 我太菜了

 

木名-内核(10:05:53):
我看的是cat /proc/loadavg里面的
32内核有每个cpu的运行队列,18内核只有这个
0.63 0.77 0.75 1/422 16134

这个里面422前面的1就是当前系统的nr_running

 

狄卢(10:07:04):
哦, 这个是多长时间采集一次?

 

木名-内核(10:07:17):
这个是你可以即时的读取
当前读取时刻的

 

狄卢(10:07:52):
哦哦, 那top里展示的load 也是从这里面计算的?

 

木名-内核(10:09:10):
嗯,load是根据每次的nr_running + nr_uninterruptible的值进行计算的
这里只是nr_running的,碰到IO的,就需要结合其他的看了
 
另, 关于进程状态: http://www.361way.com/process-status/1798.html

linux系统最常用的命令莫过于ps,经常要用其查看linux的进程和线程情况。此文我们着重来看进程 。进程又分为以下几种状态:

1. 运行(正在运行或在运行队列中等待)
2. 中断(休眠中, 受阻, 在等待某个条件的形成或接受到信号)
3. 不可中断(收到信号不唤醒和不可运行, 进程必须等待直到有中断发生)
4. 僵死(进程已终止, 但进程描述符存在, 直到父进程调用wait4()系统调用后释放)
5. 停止(进程收到SIGSTOP, SIGSTP, SIGTIN, SIGTOU信号后停止运行运行)

其对应在ps上的相应状态码如下:

状态 定义
R Running.运行中
S Interruptible Sleep.等待调用
D Uninterruptible Sleep.等待磁盘IO
T Stoped.暂停或者跟踪状态
X Dead.即将被撤销
Z Zombie.进程已经结束,仅映像名留存
W Paging.内存交换
N 优先级低的进程
< 优先级高的进程
s 进程的领导者
L 锁定状态
l 多线程状态
+ 前台进程

平时在查看linux进程状态时,查看最多的三个状态是R  S   D 

R状态,不必多说,R就是running的缩写,即运行中的进程。

S 即 sleep进程,休眠进程。其又分为两种:

  1. Interruptible Sleep(可中断睡眠,在ps命令中显示“S”)。处在这种睡眠状态的进程是可以通过给它发送signal来唤醒的,比如发HUP信号给nginx的master进程可以让nginx重新加载配置文件而不需要重新启动nginx进程;
  2. Uninterruptible Sleep(不可中断睡眠,在ps命令中显示“D”)。处在这种状态的进程不接受外来的任何signal,这也是为什么之前我无法用kill杀掉这些处于 D状态的进程,无论是“kill”, “kill -9”还是“kill -15”,因为它们压根儿就不受这些信号的支配。

D 即上面提到的Uninterruptible Sleep ,如果从广义上来分,D状态算是一种特殊的S状态进程。进程为什么会被置于D状态呢?

D 状态的进程通常是在等待IO,比如磁盘IO,网络IO,其他外设IO,如果进程正在等待的IO在较长的时间内都没有响应,那么就很会不幸地被ps看到了, 同时也就意味着很有可能有IO出了问题,可能是外设本身出了故障,也可能是比如NFS挂载的远程文件系统已经不可访问了。

 
正是因为得不到IO的响应,进程才进入了uninterruptible sleep状态,所以要想使进程从uninterruptible sleep状态恢复,就得使进程等待的IO恢复,比如如果是因为从远程挂载的NFS卷不可访问导致进程进入uninterruptible sleep状态的,那么可以通过恢复该NFS卷的连接来使进程的IO请求得到满足,除此之外,要想干掉处在D状态进程就只能重启整个Linux系统(D进程并不能通过kill 和kill -9 杀掉) 。
 
分享到:
评论

相关推荐

    verilog mips流水线cpu

    指令条数40+ 编程语言 verilog 开发环境 vivado2022.2 完成cp0功能 解决load-use冒险 解决raw冒险

    qemu-0.13.0(编译过全处理器支持)

    -S freeze CPU at startup (use 'c' to start execution) -gdb dev wait for gdb connection on 'dev' -s shorthand for -gdb tcp::1234 -d item1,... output log to /tmp/qemu.log (use -d ? for a list of log ...

    Qemu-1.0.1 for windows

    load SMBIOS entry from binary file -smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d] specify SMBIOS type 0 fields -smbios type=1[,manufacturer=str][,product=str][,version=str][,...

    Asynchronous Android Programming(PACKT,2ed,2016)

    In a more advanced phase, you will create background tasks that are able to execute CPU-intensive tasks in native code–making use of the Android NDK. You will be then guided through the process of ...

    Bitsum.Process.Lasso.Pro v3.62.4 x32

    More advanced users can tweak the configuration, but you needn't touch anything to have it instantly improve your system responsiveness and prevent stalls in high load situations. * Process Lasso ...

    PPQI.jl:Julia版本PaddlePaddle快速推断

    add (url = " https://github.com/AgentMaker/PPQI.jl " )API参考load_config: function load_config ( modelpath :: String , use_gpu :: Bool = false , gpu_id :: Int = 0 , use_mkldnn :: Bool = false , cpu_...

    Asynchronous Android Programming

    Use AsyncTask to load data in the background, delivering progress results in the meantime Enhance UI performance and responsiveness by sending work to a service running in the background Defer, ...

    sigar-sigar-1.6.4.tar.gz

    System memory swap cpu load average uptime logins Per process memory cpu credential info state arguments environment open files File system detection and metrics Network interface detection ...

    LINQPad_Premium_5.36.03_Any_CPU 含破解

    There are new methods in LINQPad's Util class to load/save strings or byte arrays to a central machine store (shared between queries). These methods are Util.SaveString, Util.SaveBytes, Util....

    Oracle DBA的UNIX袖珍参考手册之服务器监控

    Memory: Real: 772M/991M act/tot Virtual: 1965M use/tot Free: 15M PID USERNAME PRI NICE SIZE RES STATE TIME CPU COMMAND 837 afis 42 0 34M 29M sleep 128:39 11.70% unixsvr 824 afis 44 0 10M 1826K ...

    uhdd.sys源码

    with an 80386+ CPU and using MS DOS V5 0+ or equivalent XMGR is a DOS driver which works as an &quot;XMS manager&quot; and provides up to 4 GB of XMS memory XMGR has direct support for V3 70+ ...

    AtherosE2200Ethernet.kext

    Makes use of the chip's TCP Segmentation Offload (TSO) feature with IPv4 and IPv6 in order t o reduce CPU load while sending large amounts of data. Fully optimized for Mountain Lion, Mavericks and ...

    cachePHP缓存库.zip

    &lt;?... namespace Cake\Cache; use BadMethodCallException;...电脑里最大的缓存就是内存条了,最快的是CPU上镶的L1和L2缓存,显卡的显存是给显卡运算芯片用的缓存,硬盘上也有16M或者32M的缓存。

    ModernGadgets_1.6.3.rmskin

    The overarching goal of this suite is ease-of-use. Thus, everything has been made as simple and streamlined as possible. ModernGadgets requires HWiNFO, a free system monitoring utility, for full ...

    WinRing0帮助文档

    How to Use Common Put WinRing0.dll, WinRing0x64.dll, WinRing0.sys, WinRing0x64.sys, and WinRing0.vxd into the directory where your application's executable file resides. Visual C++ 2005/2008 See ...

    swingbench2.6.1124.zip

    An easy to use Oracle database load generator. Its comes with its own set of benchmarks and wizards to create them. It can be used to test features of Oracle (partitioning, compression) or evaluate ...

    Bochs - The cross platform IA-32 (x86) emulator

    [3084390] Bochs won't load floppy plugin right on startup [3043174] Docbook use of '_' build failure [3085140] Ia_arpl_Ew_Rw definition of error [3078995] ROL/ROR/SHL/SHR modeling wrong when dest ...

    WinRing.dll WinRing0 is a hardware access library for Windows.

    How to Use Common Put WinRing0.dll, WinRing0x64.dll, WinRing0.sys, WinRing0x64.sys, and WinRing0.vxd into the directory where your application's executable file resides. Visual C++ 2005/2008 See ...

    rust-macho:用于Rust的Mach-O文件格式解析器

    锈男子气概 用于Rust的Mach-O文件格式解析器 用法 ...use mach_object :: {OFile, CPU_TYPE_X86_64, MachCommand, LoadCommand}; let mut f = File :: open ( "test/helloworld" ). unwrap (); let m

    CE中文版-启点CE过NP中文.exe

    Added the ModuleLoader class which can force load dll's Fixed endUpdate for the listview Thanks go out to SER[G]ANT for updating the russion translation files already June 23 2018:Cheat Engine 6.8.1...

Global site tag (gtag.js) - Google Analytics