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负载,还是某个时间段的? 为了画折线图报表,一般横坐标都是 ...
随机推荐
- 【算法34】蓄水池抽样算法 (Reservoir Sampling Algorithm)
蓄水池抽样算法简介 蓄水池抽样算法随机算法的一种,用来从 N 个样本中随机选择 K 个样本,其中 N 非常大(以至于 N 个样本不能同时放入内存)或者 N 是一个未知数.其时间复杂度为 O(N),包含 ...
- jQuery中的AJAX的使用
1.运用ajax()方法,比其它如load().get().post()全局性函数它更多地关注实现过程中的细节:首先要了解其参数列表: url: 要求为String类型的参数,(默认为当前页地址)发送 ...
- [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]
Three Families Three families share a garden. They usually clean the garden together at the end o ...
- html5 app开发
如今html5技术越来越成熟,很多iPhone 及Android 上的移动APP都能用html5来开发完成.让我们一起来了解一下html5开发app. 一.HTML5框架开发的移动APP 编写开发游戏 ...
- WebService 工作原理及实例教程
一.WebService到底是什么? 先来看下标准的定义:Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统 ...
- devexpress 严重性 代码 说明 项目 文件 行 禁止显示状态 错误 “lc.exe”已退出,代码为 -1。
将licensens.licx删除,就能正常运行
- C#扩展一个现有的类
做个记录,写个示例 using System; class Rubbish { public void Say() { Console.Write("Hello"); } } st ...
- 【ZOJ2314】Reactor Cooling(有上下界的网络流)
前言 话说有上下界的网络流好像全机房就我一个人会手动滑稽,当然这是不可能的 Solution 其实这道题目就是一道板子题,主要讲解一下怎么做无源无汇的上下界最大流: 算法步骤 1.将每条边转换成0~u ...
- CRUD组件的高阶使用
1.list页面自定列显示: class PermissionConfig(sites.AryaConfig): def dabo(self, obj=None, is_header=Fa ...
- Django 使用getattr() 方法获取配置文件的变量值
在django项目的开发过程中,有时需要获取配置文件里的变量值,可以通过下面这样的方式去进行获取 from django.conf import settings item = getattr(set ...