linux proc cpu利用率,使用/ proc/stat准确计算Linux中的CPU利用率

小智..

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发生.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值