使用 procstat精确计算Linux中的CPU利用率

使用 procstat精确计算Linux中的CPU利用率,第1张

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

我认为iowait / irq /
softirq不在前4个数字之一中。您可以在内核代码中看到irqtime_account_process_tick的注释,以获取更多详细信息:

(对于Linux内核4.1.1)

2815  * Tick demultiplexing follows the order2816  * - pending hardirq update    <-- this is irq2817  * - pending softirq update    <-- this is softirq2818  * - user_time2819  * - idle_time         <-- iowait is included in here, discuss below2820  * - system time2821  *   - check for guest_time2822  *   - else account as system_time

有关空闲时间的处理,请参见account_idle_time函数:

2772 2776 void account_idle_time(cputime_t cputime)2777 {2778         u64 *cpustat = kcpustat_this_cpu->cpustat;2779         struct rq *rq = this_rq();27802781         if (atomic_read(&rq->nr_iowait) > 0)2782      cpustat[CPUTIME_IOWAIT] += (__force u64) cputime;2783         else2784      cpustat[CPUTIME_IDLE] += (__force u64) cputime;2785 }

如果cpu空闲并且有一些IO待处理,它将在CPUTIME_IOWAIT中计算时间。否则,它计入CPUTIME_IDLE中。

总而言之,我认为irq / softirq中的烦恼对于CPU而言应视为“忙”,因为它实际上正在处理某些IRQ或软IRQ。另一方面,对于CPU,“
iowait”中的烦恼应视为“空闲”,因为它没有做任何事情,而是在等待未决的IO发生。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5012324.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-14
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存