ptt 的 CPU 在 iowait 的部分吃了非常多的 cpu time (30% 以上),我們覺得 iowait
應該是指 disk I/O, memory I/O 的部分。但是在有 DMA 的前提下,為什麼 CPU 能在
這個部分吃這麼多 cpu?
Trace 進 kernel 看的結果,這個時間在 io_schedule() 時會加上去:
[/lang_zh]
[lang_en]
Ptt's CPU is eaten a lot in the part of iowait, we thought iowait means disk I/O. But with DMA, why CPU takes such a lot of CPU time?
Trace into the kernel, I found the time of iowait will be added inside io_schedule():
[/lang_en]
void __sched io_schedule(void)
{
struct runqueue *rq = &per_cpu(runqueues, _smp_processor_id());
atomic_inc(&rq->nr_iowait);
schedule();
atomic_dec(&rq->nr_iowait);
}
[lang_zh]
中間 context switch 出去之後,每次 timer interrupt 來時,會計一次時間。其中 system time 的部分,如果 nr_iowait 是 true 的話,iowait 就會加上去。於是這個 iowait 就不只是等待 I/O 的時間了。Process 數量少時當然可以忽略,但是在 ptt 上 25000 隻 process ...
[/lang_zh]
[lang_en]
During the context switch from the middle, each time interrupt increase the value if nr_iowait is true. So iowait is no longer the waiting time of I/O. Of course it can be omitted if the process number is small, but ptt has more than 25000 process ...
[/lang_en]