小智..
9
我认为iowait/irq/softirq不计入前4个数字之一.您可以在内核代码中看到irqtime_account_process_tick的注释以获取更多详细信息:
2815 * Tick demultiplexing follows the order
2816 * - pending hardirq update
2817 * - pending softirq update
2818 * - user_time
2819 * - idle_time
2820 * - system time
2821 * - check for guest_time
2822 * - else account as system_time
有关空闲时间的处理,请参阅account_idle_time函数:
2772 /*
2773 * Account for idle time.
2774 * @cputime: the cpu time spent in idle wait
2775 */
2776 void account_idle_time(cputime_t cputime)
2777 {
2778 u64 *cpustat = kcpustat_this_cpu->cpustat;
2779 struct rq *rq = this_rq();
2780
2781 if (atomic_read(&rq->nr_iowait) > 0)
2782 cpustat[CPUTIME_IOWAIT] += (__force u64) cputime;
2783 else
2784 cpustat[CPUTIME_IDLE] += (__force u64) cputime;
2785 }
如果cpu处于空闲状态并且有一些IO挂起,它将计算CPUTIME_IOWAIT中的时间.否则,它在CPUTIME_IDLE中计数.
总而言之,我认为irq/softirq中的jiffies应该被视为cpu的"忙"因为它实际上处理了一些IRQ或软IRQ.另一方面,"iowait"中的jiffies应该被视为cpu的"空闲",因为它没有做某事但是等待挂起的IO发生.