top的id(空闲CPU)为什么在系统空闲时不是200%?(我双核)

其它类软件,非上述版软件
回复
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: top的id(空闲CPU)为什么在系统空闲时不是200%?(我双核)

#2

帖子 vickycq » 2016-03-16 23:43

貌似只有进程 CPU 占用才会按 “一个核心为 100,两个核心为 200” 规则计算
(但根据某些搜索结果,其它人的并不是这样?)

top 的进程 CPU 占用计算模式,按 Shift + i 切换
1. IRIX Mode (默认)
2. Solaris Mode
<I> :Irix/Solaris_Mode_toggle
When operating in 'Solaris mode' ('I' toggled Off), a
task's cpu usage
will be divided by the total number of
CPUs.
......
if 'Irix mode' is Off, top will operate in
'Solaris mode' where a task's cpu usage will be divided by the
total number of CPUs. You toggle 'Irix/Solaris' modes with the
'I' interactive command
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

Re: top的id(空闲CPU)为什么在系统空闲时不是200%?(我双核)

#3

帖子 科学之子 » 2016-03-18 14:45

vickycq 写了:貌似只有进程 CPU 占用才会按 “一个核心为 100,两个核心为 200” 规则计算
(但根据某些搜索结果,其它人的并不是这样?)

top 的进程 CPU 占用计算模式,按 Shift + i 切换
1. IRIX Mode (默认)
2. Solaris Mode
<I> :Irix/Solaris_Mode_toggle
When operating in 'Solaris mode' ('I' toggled Off), a
task's cpu usage
will be divided by the total number of
CPUs.
......
if 'Irix mode' is Off, top will operate in
'Solaris mode' where a task's cpu usage will be divided by the
total number of CPUs. You toggle 'Irix/Solaris' modes with the
'I' interactive command
您是用什么关键词进行搜索的呢?英语渣都不知道输入什么关键词去搜,希望分享下搜索词来提示一下
shift+i的话,我这里测试发现了一个奇怪的现象
不论Irix mode状态如何
就算我打开两个死循环程序,CPU还是接近100,并非接近200%
按1之后分别显示各核心状态,每个核心也是占满.
但合并显示时并没有像以前那样出现200%的状态
top版本:

代码: 全选

$ top -v
  procps-ng version 3.3.9
Usage:
  top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: top的id(空闲CPU)为什么在系统空闲时不是200%?(我双核)

#4

帖子 vickycq » 2016-03-18 15:18

科学之子 写了: 您是用什么关键词进行搜索的呢?英语渣都不知道输入什么关键词去搜,希望分享下搜索词来提示一下
我用的关键词为 'top cpu usage over 100'
翻几个链接就会发现关于 irix mode 的说明
科学之子 写了:不论Irix mode状态如何 就算我打开两个死循环程序,CPU还是接近100,并非接近200%
irix mode 影响的是 每个进程的占用率统计,不是上面 2.7 us, 2.5 sy, 0.0 ni, 93.6 id 这一行总占用率
例如打开 python,运算 22**222222222222222,这会把一个核心完全占满。下方进程列表显示 python 进程占用 99.9%
这就是 irix mode。按 shift+i 切换到 solaris mode,可见 python 占用率由 100% 降为 50%

但不论 irix mode / solaris mode,上方总占用率总为 ~50%

其实说了这么多,问题还是没解决。网搜 'top cpu usage over 100' 铺天盖地都是解释为何占用率会超过 100%,但他们看到的是 us,sy,ni,id 总占用率超过 100%?还是具体某一个进程的占用率超过 100%?根据 man top,只有某一个具体进程的占用率显示才会有超过 100% 的情况出现。我自己在 3 个不同双核平台上测试也都是如此:上方的 us,sy,ni,id 总占用率永远不会超过 100%,单个核心占满时占用率为 50%

注意下面描述的是进程 CPU 占用,而非总 CPU 占用
man top 写了:1. %CPU -- CPU Usage
The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time.
In a true SMP environment, if a process is multi-threaded and top is not operating in Threads mode, amounts greater than 100% may be reported. You toggle Threads mode with the
`H' interactive command.
Also for multi-processor environments, if Irix mode is Off, top will operate in Solaris mode where a task's cpu usage will be divided by the total number of CPUs. You toggle
Irix/Solaris modes with the `I' interactive command.
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
回复