栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用/ 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发生。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/403255.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号