问个cpu iowait的问题

165 views
Skip to first unread message

Wang Xu

unread,
Feb 18, 2011, 12:10:45 AM2/18/11
to Linux @ BUPT
这样啊,iowait 的时候,CPU本身是不是空闲呢,就是说它是不是在睡觉呢,有CPU intensive的应用,是不是可以在wait的时间里用CPU干活呢?

vmstat说2.5.41之前的linux,iowait 是算到 idle 里面的,而且这个时间也不算到任何进程里,所以看起来 cpu 是可用的啊

我这个都是猜测啊,业内的大牛们,神马 coly 啊,bergwolf 啊的,快快跳出来啊

--
Wang Xu

Zichen Xu

unread,
Feb 18, 2011, 4:10:40 AM2/18/11
to linu...@googlegroups.com


2011/2/18 Wang Xu <gna...@gmail.com>

这样啊,iowait 的时候,CPU本身是不是空闲呢,就是说它是不是在睡觉呢,有CPU intensive的应用,是不是可以在wait的时间里用CPU干活呢?

It depends on the multi-thread degree. The CPU may switch to another job to process. Linux is not a batch system, man.
 

vmstat说2.5.41之前的linux,iowait 是算到 idle 里面的,而且这个时间也不算到任何进程里,所以看起来 cpu 是可用的啊

我这个都是猜测啊,业内的大牛们,神马 coly 啊,bergwolf 啊的,快快跳出来啊

--
Wang Xu

--
To post to this group, send email to linu...@googlegroups.com
website: http://linuxfb.net
twitter: http://twitter.com/linuxfb
IRC: #linux...@irc.freenode.net



--
Zichen Xu - X.Z.C.
University of South Florida
Computer Science and Engineering
33620, Fowler Ave
Tampa, FL
徐子晨

Wang Xu

unread,
Feb 18, 2011, 4:23:51 AM2/18/11
to linu...@googlegroups.com
嗯,一下午终于有人回了,兴奋ing

2011/2/18 Zichen Xu <xzck...@gmail.com>


2011/2/18 Wang Xu <gna...@gmail.com>

这样啊,iowait 的时候,CPU本身是不是空闲呢,就是说它是不是在睡觉呢,有CPU intensive的应用,是不是可以在wait的时间里用CPU干活呢?

It depends on the multi-thread degree. The CPU may switch to another job to process. Linux is not a batch system, man.

其实我就是想知道,这个时候是不是其他进程可以来抢占,还是CPU会被某个等待中的进程锁住,呵呵,问得比较菜哈

--
Wang Xu

Zichen Xu

unread,
Feb 18, 2011, 4:29:43 AM2/18/11
to linu...@googlegroups.com


2011/2/18 Wang Xu <gna...@gmail.com>
It depends on your process's priority. Generally, CPU is a valuable resource, it cannot be locked. But in a realtime system, it is possible. If you type top in cmd mode after running like 100 processes. You will c those changes like CPU utilization for each process. Those are dynamic along with time varies. Another special case is the dual core or quad core system, you could occupy one certain core or brutally shut it down. The answer to your question could be easily found in any classic OS textbooks. Or you could google it.

--
Wang Xu

--
To post to this group, send email to linu...@googlegroups.com
website: http://linuxfb.net
twitter: http://twitter.com/linuxfb
IRC: #linux...@irc.freenode.net

Peng Tao

unread,
Feb 20, 2011, 11:34:48 AM2/20/11
to linu...@googlegroups.com, Wang Xu
2011/2/18 Wang Xu <gna...@gmail.com>:

> 这样啊,iowait 的时候,CPU本身是不是空闲呢,就是说它是不是在睡觉呢,有CPU
> intensive的应用,是不是可以在wait的时间里用CPU干活呢?
我拍脑袋说一下是的:)
iowait的时候CPU是idle的,如果有cpu intensive的应用,可以利用起来运行计算。

> vmstat说2.5.41之前的linux,iowait 是算到 idle 里面的,而且这个时间也不算到任何进程里,所以看起来 cpu 是可用的啊
> 我这个都是猜测啊,业内的大牛们,神马 coly 啊,bergwolf 啊的,快快跳出来啊
>
> --
> Wang Xu
>

> --
> To post to this group, send email to linu...@googlegroups.com
> website: http://linuxfb.net
> twitter: http://twitter.com/linuxfb
> IRC: #linux...@irc.freenode.net
>

--
Thanks,
-Bergwolf

Peng Tao

unread,
Feb 23, 2011, 2:39:30 AM2/23/11
to linu...@googlegroups.com, Wang Xu
2011/2/21 Peng Tao <berg...@gmail.com>:

> 2011/2/18 Wang Xu <gna...@gmail.com>:
>> 这样啊,iowait 的时候,CPU本身是不是空闲呢,就是说它是不是在睡觉呢,有CPU
>> intensive的应用,是不是可以在wait的时间里用CPU干活呢?
> 我拍脑袋说一下是的:)
> iowait的时候CPU是idle的,如果有cpu intensive的应用,可以利用起来运行计算。

今天看了下代码,确认是这样的。iowait的时候task是在sleep中,不占用CPU的,所以可以用来运行其他进程。

kernel会先把task state改成uninterruptible,就是ps看到的D状态。然后调用io_schedule()或者io_schedule_timeout(),实际是调用到schedule()让进程sleep,并最终在enqueue_sleeper()中把sleep的这段时间计算到进程的iowait时间里。进程sleep是通过把进程从runqueue中摘下来实现的,这样scheduler就不会调度sleep的进程。可见进程iowait的时候是不占用CPU的。

--
Thanks,
-Bergwolf

Reply all
Reply to author
Forward
0 new messages