cpu负载的探讨
原链接:http://blog.chinaunix.net/uid-12693781-id-368837.html
/* Variables and functions for calc_load */
static atomic_long_t calc_load_tasks;
static unsigned long calc_load_update;
unsigned long avenrun[];
EXPORT_SYMBOL(avenrun); /**
* get_avenrun - get the load average array
* @loads: pointer to dest load array
* @offset: offset to add
* @shift: shift count to shift the result left
*
* These values are estimates at best, so no need for locking.
*/
void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
{
loads[] = (avenrun[] + offset) << shift;
loads[] = (avenrun[] + offset) << shift;
loads[] = (avenrun[] + offset) << shift;
} static unsigned long
calc_load(unsigned long load, unsigned long exp, unsigned long active)
{
load *= exp;
load += active * (FIXED_1 - exp);
return load >> FSHIFT;
} /*
* calc_load - update the avenrun load estimates 10 ticks after the
* CPUs have updated calc_load_tasks.
*/
void calc_global_load(void)
{
unsigned long upd = calc_load_update + ;
long active; if (time_before(jiffies, upd))
return; active = atomic_long_read(&calc_load_tasks);
active = active > ? active * FIXED_1 : ; avenrun[] = calc_load(avenrun[], EXP_1, active);
avenrun[] = calc_load(avenrun[], EXP_5, active);
avenrun[] = calc_load(avenrun[], EXP_15, active); calc_load_update += LOAD_FREQ;
} /*
* Either called from update_cpu_load() or from a cpu going idle
*/
static void calc_load_account_active(struct rq *this_rq)
{
long nr_active, delta; nr_active = this_rq->nr_running; //记录在cpu上运行的进程数
nr_active += (long) this_rq->nr_uninterruptible; //记录不可中断的进程数 if (nr_active != this_rq->calc_load_active) {
delta = nr_active - this_rq->calc_load_active;
this_rq->calc_load_active = nr_active;
atomic_long_add(delta, &calc_load_tasks);
}
}
#ps aux可以显示进程的运行状态
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
=================进程STAT状态====================
D 无法中断的休眠状态(通常 IO 的进程)
R 正在运行,在可中断队列中;
S 处于休眠状态,静止状态;
T 停止或被追踪,暂停执行;
W 进入内存交换(从内核2.6开始无效);
X 死掉的进程;
Z 僵尸进程不存在但暂时无法消除;
W: 没有足够的记忆体分页可分配
WCHAN 正在等待的进程资源; <:高优先级进程
N: 低优先序进程
L: 有记忆体分页分配并锁在记忆体内 (即时系统或捱A I/O),即,有些页被锁进内存
s 进程的领导者(在它之下有子进程);
l 多进程的(使用 CLONE_THREAD, 类似 NPTL pthreads);
+ 位于后台的进程组;
server1:~$ est
connections established
root 0.2 0.0 ? D Jul20 : [nfsd]
root 0.2 0.0 ? D Jul20 : [nfsd]
root 0.2 0.0 ? S Jul20 : [nfsd]
root 0.2 0.0 ? S Jul20 : [nfsd]
root 0.2 0.0 ? S Jul20 : [nfsd]
root 0.2 0.0 ? S Jul20 : [nfsd]
root 0.2 0.0 ? S Jul20 : [nfsd]
root 0.2 0.0 ? D Jul20 : [nfsd]
server1:~$ top top - 16:13:12 up 14 days, 21:21, 2 users, load average: 180.20, 59.85, 22.61
Tasks: 125 total, 1 running, 124 sleeping, 0 stopped, 0 zombie
Cpu : 2.3%us, 1.3%sy, 0.0%ni, 0.0%id, 95.8%wa, 0.0%hi, 0.5%si, 0.0%st
Mem: 2076212k total, 2028752k used, 47460k free, 1804k buffers
Swap: 2104472k total, 1089140k used, 1015332k free, 244076k cached
cpu负载的探讨的更多相关文章
- cpu负载的探讨 (转)
文章出处:http://blog.chinaunix.net/uid-12693781-id-368837.html 摘要:确定cpu的负载的定义,帮助管理员设置cpu负载阀值,推测可能的导致cpu负 ...
- 【原创】(二)Linux进程调度器-CPU负载
背景 Read the fucking source code! --By 鲁迅 A picture is worth a thousand words. --By 高尔基 说明: Kernel版本: ...
- cpu负载和利用率
理解Linux系统负荷 linux里的CPU负载
- 通过top命令发现plymouthd进程cpu负载达到近100% 解决办法
最近几天一直遇到服务器cpu100%, 通过top命令发现plymouthd进程cpu负载达到近100% 解决方法:打开 /boot/grub/menu.lst , 去掉 “rhgb quiet”这两 ...
- 记录一个多核CPU负载不均衡问题(动态绑定进程到指定cpu:taskset -pc $CPU $PID)
昨晚和一位读者朋友讨论了一个问题:在一台多核 CPU 的 Web 服务器上,存在负载不均衡问题,其中 CPU0 的负载明显高于其它 CPUx,进一步调查表明 PHP-FPM 的嫌疑很大.话说以前我曾经 ...
- Linux CPU负载
昨天查看Nagios警报信息,发现其中一台服务器CPU负载过重,机器为CentOS系统.信息如下: 2011-2-15 (星期二) 17:50 WARNING - load average: 9.73 ...
- Linux系统排查2——CPU负载篇
本随笔介绍CPU负载的排查手段. 查看系统负载的工具:uptime,w,都能查看系统负载,系统平均负载是处于运行或不可打扰状态的进程的平均数, 可运行:运行态,占用CPU,或就绪态,等待CPU调度. ...
- eCos系统CPU负载测量
原文:http://ecos.sourceware.org/docs-latest/ref/services-cpuload.html 译文:http://blog.csdn.net/zoomdy/a ...
- Linux CPU 负载度量公式
一个top命令不就行了么?顶多再加一些管道什么的过滤一下.我一开始也是这么想得.其实还可以理解的更多. 首先一个问题,是统计某个时间点的CPU负载,还是某个时间段的? 为了画折线图报表,一般横坐标都是 ...
随机推荐
- 移动端与PC端的viewport
第一种解析: 设备像素,就是我们直觉上觉得"靠谱"的像素,这些像素为所使用的各种设备提供了正规的分辨率,并且其值可以通过(通常情况下)从screen.width/height属性中 ...
- [翻译] FastReport 变量列表使用
使用报表变量时,引用"frxVariables"单元. 变量定义在"TfrxVariable" 类: TfrxVariable = class(TCollect ...
- express session
一.什么是session? 最近在学习node.js 的express框架,接触到了关于session方面的内容.翻阅了一些的博客,学到了不少东西,发现一篇博文讲的很好,概念内容摘抄如下: Sessi ...
- Elasticsearch 核心插件Kibana 本地文件包含漏洞分析(CVE-2018-17246)
不久前Elasticsearch发布了最新安全公告, Elasticsearch Kibana 6.4.3之前版本和5.6.13之前版本中的Console插件存在严重的本地文件包含漏洞可导致拒绝服务攻 ...
- asp.net core 的用户注册功能——Identity上手
首先请using这个类库. using Microsoft.AspNetCore.Identity; 这个类库老牛逼了,首先是包含了一个IdentityUser类.我们可以自己写一个User类继承Id ...
- springboot-登录拦截器
小伙伴们大家好,今天给大家分享一个简单的springboot版登录拦截器 首先我们需要在springboot的启动类中让它实现WebMvcConfigurer 这个接口 比如: public clas ...
- cpu缓存java性能问题初探
在内存与cpu寄存器之间,还有一块区域叫做cpu高速缓存,即我们常常说的cache. cache分为L1.L2.L3三级缓存,速度递减,离cpu越来越远,L1.L2每个内核自己都有,L3是每个插槽上的 ...
- Backtracking-401. Binary Watch
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom ...
- 合服导致 globalserver 起不来的问题
globalserver 报错 RMIInitArmyBackObject InitError 根据报错信息一路追查下来,发现某个帮派的数据解析 json 的时候报错.监视变量,找出这段字符串,大致结 ...
- zoj4016 Mergeable Stack
题意:对n个栈,有q次操作.每个操作可能为三种情况中的一种:1.将v插入到s栈的顶端:2.输出s栈的栈顶(若栈为空则输出empty):3.将栈t插入到栈s的栈顶. 开始考虑到指针可能会mle,用数组模 ...