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

小编典典

我认为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中的烦恼对于CPU而言应视为“忙”,因为它实际上正在处理某些IRQ或软IRQ。另一方面,对于CPU,“

iowait”中的烦恼应视为“空闲”,因为它没有做任何事情,而是在等待未决的IO发生。

2020-06-07

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值