{"id":62328,"date":"2026-01-19T19:57:54","date_gmt":"2026-01-19T11:57:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/62328.html"},"modified":"2026-01-19T19:57:54","modified_gmt":"2026-01-19T11:57:54","slug":"%ef%bc%88%e4%ba%8c%ef%bc%89linux-%e8%b0%83%e5%ba%a6%e5%99%a8-cpu%e8%b4%9f%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/62328.html","title":{"rendered":"\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d"},"content":{"rendered":"<h2>\u4e00\u3001\u6982\u8ff0<\/h2>\n<p>CPU\u8d1f\u8f7d&#xff08;CPU load&#xff09;\u6307\u7684\u662f\u67d0\u4e2a\u65f6\u95f4\u70b9\u8fdb\u7a0b\u5bf9\u7cfb\u7edf\u4ea7\u751f\u7684\u538b\u529b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"379\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c4029488.png\" width=\"775\" \/><\/p>\n<ul>\n<li>\n<p>CPU\u7684\u8fd0\u884c\u80fd\u529b&#xff0c;\u5c31\u5982\u5927\u6865\u7684\u901a\u884c\u80fd\u529b&#xff0c;\u5206\u522b\u6709\u6ee1\u8d1f\u8377&#xff0c;\u975e\u6ee1\u8d1f\u8377&#xff0c;\u8d85\u8d1f\u8377\u7b49\u72b6\u6001&#xff0c;\u8fd9\u51e0\u79cd\u72b6\u6001\u5bf9\u5e94\u4e0d\u540c\u7684CPU load\u503c&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5355CPU\u6ee1\u8d1f\u8377\u8fd0\u884c\u65f6 cpu_load \u4e3a1&#xff0c;\u5f53\u591a\u4e2aCPU\u6216\u591a\u6838\u65f6&#xff0c;\u76f8\u5f53\u4e8e\u5927\u6865\u6709\u591a\u4e2a\u8f66\u9053&#xff0c;\u6ee1\u8d1f\u8377\u8fd0\u884c\u65f6 cpu_load \u503c\u4e3aCPU\u6570\u6216\u591a\u6838\u6570&#xff1b;<\/p>\n<\/li>\n<li>\n<p>CPU\u8d1f\u8f7d\u7684\u8ba1\u7b97&#xff08;\u4ee5\u5355CPU\u4e3a\u4f8b&#xff09;&#xff0c;\u5047\u8bbe\u4e00\u5206\u949f\u5185\u6267\u884c10\u4e2a\u4efb\u52a1\u4ee3\u8868\u6ee1\u8d1f\u8377&#xff0c;\u5f53\u4e00\u5206\u949f\u7ed9\u51fa30\u4e2a\u4efb\u52a1\u65f6&#xff0c;CPU\u53ea\u80fd\u5904\u740610\u4e2a&#xff0c;\u5269\u4f5920\u4e2a\u4e0d\u80fd\u5904\u7406&#xff0c;cpu_load&#061;3\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5728\u5b9e\u9645\u7cfb\u7edf\u4e2d\u67e5\u770b&#xff1a;<\/p>\n<ul>\n<li>\n<p>cat \/proc\/cpuinfo&#xff1a;\u67e5\u770bCPU\u4fe1\u606f&#xff1b;<\/p>\n<\/li>\n<li>\n<p>cat \/proc\/loadavg&#xff1a;\u67e5\u770bCPU\u6700\u8fd11\/5\/15\u5206\u949f\u7684\u5e73\u5747\u8d1f\u8f7d\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8ba1\u7b97CPU\u8d1f\u8f7d&#xff0c;\u53ef\u4ee5\u8ba9\u8c03\u5ea6\u5668\u66f4\u597d\u7684\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u5904\u7406&#xff0c;\u4ee5\u4fbf\u63d0\u9ad8\u7cfb\u7edf\u7684\u8fd0\u884c\u6548\u7387\u3002\u6b64\u5916&#xff0c;\u5185\u6838\u4e2d\u5176\u4ed6\u5b50\u7cfb\u7edf\u4e5f\u53ef\u4ee5\u53c2\u8003\u8fd9\u4e9bCPU\u8d1f\u8f7d\u503c\u8fdb\u884c\u76f8\u5e94\u7684\u8c03\u6574&#xff0c;\u6bd4\u5982DVFS\u7b49\u3002<\/p>\n<p>\u76ee\u524d\u5185\u6838\u4e2d&#xff0c;\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u5f0f\u6765\u8ddf\u8e2aCPU\u8d1f\u8f7d&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5168\u5c40CPU\u5e73\u5747\u8d1f\u8f7d&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8fd0\u884c\u961f\u5217CPU\u8d1f\u8f7d&#xff1b;<\/p>\n<\/li>\n<li>\n<p>PELT&#xff08;per entity load tracking&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<h2>\u4e8c\u3001\u5168\u5c40CPU\u5e73\u5747\u8d1f\u8f7d<\/h2>\n<h3>\u57fa\u7840\u6982\u5ff5<\/h3>\n<p>\u5148\u6765\u660e\u786e\u4e24\u4e2a\u4e0eCPU\u8d1f\u8f7d\u8ba1\u7b97\u76f8\u5173\u7684\u6982\u5ff5&#xff1a;<\/p>\n<ul>\n<li>\n<p>active task&#xff08;\u6d3b\u52a8\u4efb\u52a1&#xff09;&#xff1a;\u53ea\u6709\u77e5\u9053\u6d3b\u52a8\u4efb\u52a1\u6570\u91cf&#xff0c;\u624d\u80fd\u8ba1\u7b97CPU\u8d1f\u8f7d&#xff0c;\u800c\u6d3b\u52a8\u4efb\u52a1\u5305\u62ec\u4e86 TASK_RUNNING \u548c TASK_UNINTERRUPTIBLE \u4e24\u7c7b\u4efb\u52a1\u3002\u5305\u542b TASK_UNINTERRUPTIBLE \u4efb\u52a1\u7684\u539f\u56e0\u662f&#xff0c;\u8fd9\u7c7b\u4efb\u52a1\u7ecf\u5e38\u662f\u4f60\u5728\u7b49\u5f85I\/O\u8bf7\u6c42&#xff0c;\u5c06\u5176\u5305\u542b\u5728\u5185\u4e5f\u5408\u7406&#xff1b;<\/p>\n<\/li>\n<li>\n<p>NO_HZ&#xff1a;\u6211\u4eec\u90fd\u77e5\u9053Linux\u5185\u6838\u6bcf\u9694\u56fa\u5b9a\u65f6\u95f4\u53d1\u51fa timer_interrupt&#xff0c;\u800cHZ\u662f\u7528\u6765\u5b9a\u4e491\u79d2\u949f\u7684 timer interrupts \u6b21\u6570&#xff0c;HZ\u7684\u5012\u6570\u662ftick&#xff0c;\u662f\u7cfb\u7edf\u7684\u8282\u62cd\u5668&#xff0c;\u6bcf\u4e2atick\u4f1a\u5904\u7406\u5305\u62ec\u8c03\u5ea6\u5668\u3001\u65f6\u95f4\u7ba1\u7406\u3001\u5b9a\u65f6\u5668\u7b49\u4e8b\u52a1\u3002\u5468\u671f\u6027\u7684\u65f6\u949f\u4e2d\u65ad\u5e26\u6765\u7684\u95ee\u9898\u662f&#xff0c;\u4e0d\u7ba1CPU\u7a7a\u95f2\u6216\u7e41\u5fd9\u90fd\u4f1a\u89e6\u53d1&#xff0c;\u4f1a\u5e26\u6765\u989d\u5916\u7684\u7cfb\u7edf\u635f\u8017&#xff0c;\u56e0\u6b64\u5f15\u5165\u4e86NO_HZ\u6a21\u5f0f&#xff0c;\u53ef\u4ee5\u5728CPU\u7a7a\u95f2\u65f6\u5c06\u5468\u671f\u6027\u65f6\u949f\u5173\u6389\u3002\u5728NO_HZ\u671f\u95f4&#xff0c;\u6d3b\u52a8\u4efb\u52a1\u6570\u91cf\u7684\u6539\u53d8\u4e5f\u9700\u8981\u8003\u8651&#xff0c;\u800c\u5b83\u7684\u8ba1\u7b97\u4e0d\u5982\u5468\u671f\u6027\u65f6\u949f\u6a21\u5f0f\u4e0b\u76f4\u89c2\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u6d41\u7a0b<\/h3>\n<p>Linux\u5185\u6838\u4e2d\u5b9a\u4e49\u4e86\u4e09\u4e2a\u5168\u5c40\u53d8\u91cf\u503c avenrun[3]&#xff0c;\u7528\u4e8e\u5b58\u5728\u6700\u8fd11\/5\/15\u5206\u949f\u7684\u5e73\u5747CPU\u8d1f\u8f7d\u3002\u8ba1\u7b97\u6d41\u7a0b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"614\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c4050b6d.png\" width=\"715\" \/><\/p>\n<p>\u8ba1\u7b97\u6d3b\u52a8\u4efb\u52a1\u6570&#xff0c;\u8fd9\u4e2a\u5305\u62ec\u4e24\u90e8\u5206&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5468\u671f\u6027\u8c03\u5ea6\u4e2d\u65b0\u589e\u52a0\u7684\u6d3b\u52a8\u4efb\u52a1&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5728NO_HZ\u671f\u95f4\u589e\u52a0\u7684\u6d3b\u52a8\u4efb\u52a1\u6570&#xff1b;<\/p>\n<\/li>\n<\/ul>\n<p>\u6839\u636e\u6d3b\u52a8\u4efb\u52a1\u6570\u503c&#xff0c;\u518d\u7ed3\u5408\u5168\u5c40\u53d8\u91cf\u503c avenrun[] \u4e2d\u7684 old value&#xff0c;\u6765\u8ba1\u7b97\u65b0\u7684CPU\u8d1f\u8f7d\u503c&#xff0c;\u5e76\u6700\u7ec8\u66ff\u6362\u6389 avenrun[] \u4e2d\u7684\u503c&#xff1b;<\/p>\n<p>\u7cfb\u7edf\u9ed8\u8ba4\u6bcf\u96945\u79d2\u949f\u4f1a\u8ba1\u7b97\u4e00\u6b21\u8d1f\u8f7d&#xff0c;\u5982\u679c\u7531\u4e8eNO_HZ\u7a7a\u95f2\u800c\u9519\u8fc7\u4e86\u4e0b\u4e00\u4e2aCPU\u8d1f\u8f7d\u7684\u8ba1\u7b97\u5468\u671f&#xff0c;\u5219\u9700\u8981\u518d\u6b21\u8fdb\u884c\u66f4\u65b0\u3002\u6bd4\u5982NO_HZ\u7a7a\u95f220\u79d2\u800c\u65e0\u6cd5\u66f4\u65b0CPU\u8d1f\u8f7d&#xff0c;\u524d5\u79d2\u8d1f\u8f7d\u5df2\u7ecf\u66f4\u65b0&#xff0c;\u9700\u8981\u8ba1\u7b97\u5269\u4f59\u76843\u4e2a\u8ba1\u7b97\u5468\u671f\u7684\u8d1f\u8f7d\u6765\u7ee7\u7eed\u66f4\u65b0\u3002<\/p>\n<h3>\u8ba1\u7b97\u65b9\u6cd5<\/h3>\n<p>Linux\u5185\u6838\u4e2d&#xff0c;\u91c7\u752811\u4f4d\u7cbe\u5ea6\u7684\u5b9a\u70b9\u5316\u8ba1\u7b97&#xff0c;CPU\u8d1f\u8f7d1.0\u7531\u6574\u65702048\u8868\u793a&#xff0c;\u5b8f\u5b9a\u4e49\u5982\u4e0b&#xff1a;<\/p>\n<p>#define FSHIFT          11                             \/* nr of bits of precision *\/<br \/>\n#define FIXED_1         (1&lt;&lt;FSHIFT)            \/* 1.0 as fixed-point *\/<br \/>\n#define LOAD_FREQ   (5*HZ&#043;1)            \/* 5 sec intervals *\/<br \/>\n#define EXP_1           1884                        \/* 1\/exp(5sec\/1min) as fixed-point *\/<br \/>\n#define EXP_5           2014                        \/* 1\/exp(5sec\/5min) *\/<br \/>\n#define EXP_15          2037                      \/* 1\/exp(5sec\/15min) *\/ <\/p>\n<p>\u8ba1\u7b97\u516c\u5f0f\u5982\u4e0b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"187\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c406c1a0.png\" width=\"552\" \/><\/p>\n<ul>\n<li>\n<p>load\u503c\u4e3a\u65e7\u7684CPU\u8d1f\u8f7d\u503c avenrun[]&#xff0c;\u6574\u4e2a\u8ba1\u7b97\u5b8c\u6210\u540e\u5f97\u5230\u65b0\u7684\u8d1f\u8f7d\u503c&#xff0c;\u518d\u66f4\u65b0 avenrun[]&#xff1b;<\/p>\n<\/li>\n<li>\n<p>EXP_1\/EXP_5\/EXP_15&#xff0c;\u5206\u522b\u4ee3\u8868\u6700\u8fd11\/5\/15\u5206\u949f\u7684\u5b9a\u70b9\u5316\u503c\u7684\u6307\u6570\u56e0\u5b50&#xff1b;<\/p>\n<\/li>\n<li>\n<p>active\u503c&#xff0c;\u6839\u636e\u8bfb\u53d6 calc_load_tasks \u7684\u503c\u6765\u5224\u65ad&#xff0c;\u5927\u4e8e0\u5219\u4e58\u4ee5 FIXED_1(2048)\u4f20\u5165&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6839\u636eactive\u548cload\u503c\u7684\u5927\u5c0f\u5173\u7cfb\u6765\u51b3\u5b9a\u662f\u5426\u9700\u8981\u52a01&#xff0c;\u7c7b\u4f3c\u4e8e\u56db\u820d\u4e94\u5165\u7684\u673a\u5236\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5173\u952e\u4ee3\u7801\u5982\u4e0b&#xff1a;<\/p>\n<p>active &#061; atomic_long_read(&amp;calc_load_tasks);<br \/>\nactive &#061; active &gt; 0 ? active * FIXED_1 : 0;<\/p>\n<p>avenrun[0] &#061; calc_load(avenrun[0], EXP_1, active);<br \/>\navenrun[1] &#061; calc_load(avenrun[1], EXP_5, active);<br \/>\navenrun[2] &#061; calc_load(avenrun[2], EXP_15, active); <\/p>\n<ul>\n<li>\n<p>NO_HZ\u6a21\u5f0f\u4e0b\u6d3b\u52a8\u4efb\u52a1\u6570\u91cf\u66f4\u6539\u7684\u8ba1\u7b97<\/p>\n<\/li>\n<\/ul>\n<p>\u7531\u4e8eNO_HZ\u7a7a\u95f2\u6548\u5e94\u800c\u66f4\u7231\u7684CPU\u6d3b\u52a8\u4efb\u52a1\u6570\u91cf&#xff0c;\u5b58\u653e\u5728\u5168\u5c40\u53d8\u91cf calc_load_nohz[2] \u4e2d&#xff0c;\u5e76\u4e14\u6bcf5\u79d2\u8ba1\u7b97\u5468\u671f\u4ea4\u66ff\u66f4\u6362\u4e00\u6b21\u5b58\u50a8\u4f4d\u7f6e&#xff08;calc_load_read_idx\/calc_load_write_idx&#xff09;&#xff0c;\u5176\u4ed6\u7a0b\u5e8f\u53ef\u4ee5\u53bb\u8bfb\u53d6\u6700\u8fd15\u79d2\u5185\u7684\u6d3b\u52a8\u4efb\u52a1\u53d8\u5316\u7684\u589e\u91cf\u503c\u3002<\/p>\n<p>\u8ba1\u7b97\u793a\u4f8b<\/p>\n<p>\u5047\u8bbe\u5728\u67d0\u4e2aCPU\u4e0a&#xff0c;\u5f00\u59cb\u8ba1\u7b97\u65f6 load&#061;0.5&#xff0c;\u6839\u636e calc_load_tasks \u503c\u83b7\u53d6\u4e0d\u540c\u7684active&#xff0c;\u4e2d\u95f4\u8fdb\u5165NO_HZ\u6a21\u5f0f\u7a7a\u95f2\u4e8620\u79d2&#xff0c;\u6574\u4e2a\u8ba1\u7b97\u7684\u503c\u5982\u4e0b\u56fe&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"375\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c407bba1.png\" width=\"992\" \/><\/p>\n<h2>\u4e09\u3001\u8fd0\u884c\u961f\u5217CPU\u8d1f\u8f7d<\/h2>\n<p>Linux\u7cfb\u7edf\u4f1a\u8ba1\u7b97\u6bcf\u4e2atick\u7684\u5e73\u5747CPU\u8d1f\u8f7d&#xff0c;\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u8fd0\u884c\u961f\u5217\u4e2d rq-&gt;cpu_load[5]&#xff0c;\u7528\u4e8e\u8d1f\u8f7d\u5747\u8861\u3002\u4e0b\u56fe\u663e\u793a\u4e86\u8ba1\u7b97\u8fd0\u884c\u961f\u5217\u7684CPU\u8d1f\u8f7d\u7684\u5904\u7406\u6d41\u7a0b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"437\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c409e0f4.png\" width=\"919\" \/><\/p>\n<p>\u6700\u7ec8\u901a\u8fc7 cpu_load_update \u6765\u8ba1\u7b97&#xff0c;\u903b\u8f91\u5982\u4e0b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"223\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c40c2a2e.png\" width=\"449\" \/><\/p>\n<p>\u8870\u51cf\u56e0\u5b50\u7684\u8ba1\u7b97\u4e3b\u8981\u662f\u5728 delay_load_missed() \u51fd\u6570\u4e2d\u5b8c\u6210&#xff0c;\u8be5\u51fd\u6570\u4f1a\u8fd4\u56de load * \u8870\u51cf\u56e0\u5b50 \u7684\u503c&#xff0c;\u4f5c\u4e3a\u4e0a\u56fe\u4e2d\u7684old_load\u3002\u8ba1\u7b97\u65b9\u5f0f\u5982\u4e0b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"445\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c40d449f.png\" width=\"870\" \/><\/p>\n<h2>\u56db\u3001PELT<\/h2>\n<p>PELT&#xff0c;Per-entity load tracking\u3002\u5728Linux\u5f15\u5165PELT\u4e4b\u524d&#xff0c;CFS\u8c03\u5ea6\u5668\u5728\u8ba1\u7b97CPU\u8d1f\u8f7d\u65f6&#xff0c;\u901a\u8fc7\u8ddf\u8e2a\u6bcf\u4e2a\u8fd0\u884c\u961f\u5217\u4e0a\u7684\u8d1f\u8f7d\u6765\u8ba1\u7b97&#xff1b;\u5728\u5f15\u5165PELT\u4e4b\u540e&#xff0c;\u901a\u8fc7\u8ddf\u8e2a\u6bcf\u4e2a\u8c03\u5ea6\u5b9e\u4f53\u7684\u8d1f\u8f7d\u8d21\u732e\u6765\u8ba1\u7b97&#xff08;\u5176\u4e2d&#xff0c;\u8c03\u5ea6\u5b9e\u4f53&#xff1a;\u6307task\u6216task_group&#xff09;\u3002<\/p>\n<h3>PELT\u8ba1\u7b97\u65b9\u6cd5<\/h3>\n<p>\u603b\u4f53\u7684\u8ba1\u7b97\u601d\u8def&#xff1a;<\/p>\n<p>\u5c06\u8c03\u5ea6\u5b9e\u4f53\u7684\u53ef\u8fd0\u884c\u72b6\u6001\u65f6\u95f4&#xff08;\u6b63\u5e38\u8fd0\u884c&#043;\u7b49\u5f85CPU\u8c03\u5ea6\u8fd0\u884c&#xff09;&#xff0c;\u63091024ns\u5212\u5206\u6210\u4e0d\u540c\u7684\u5468\u671f&#xff0c;\u8ba1\u7b97\u6bcf\u4e2a\u5468\u671f\u5185\u8be5\u8c03\u5ea6\u5b9e\u4f53\u5bf9\u7cfb\u7edf\u8d1f\u8f7d\u7684\u8d21\u732e&#xff0c;\u6700\u540e\u5b8c\u6210\u7d2f\u52a0\u3002\u5176\u4e2d&#xff0c;\u6bcf\u4e2a\u8ba1\u7b97\u5468\u671f&#xff0c;\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb&#xff0c;\u9700\u8981\u4e58\u4ee5\u8870\u51cf\u56e0\u5b50y\u8fdb\u884c\u4e00\u6b21\u8870\u51cf\u64cd\u4f5c\u3002<\/p>\n<p>\u5148\u6765\u770b\u4e00\u4e0b\u6bcf\u4e2a\u8c03\u5ea6\u5b9e\u4f53\u7684\u8d1f\u8f7d\u8d21\u732e\u8ba1\u7b97\u516c\u5f0f&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"314\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115753-696e1c410519b.png\" width=\"569\" \/><\/p>\n<ul>\n<li>\n<p>\u5f53\u524d\u65f6\u95f4\u70b9\u7684\u8d1f\u8f7d\u8d21\u732e &#061; \u5f53\u524d\u65f6\u95f4\u70b9\u8d1f\u8f7d &#043; \u4e0a\u4e2a\u5468\u671f\u8d1f\u8f7d\u8d21\u732e * \u8870\u51cf\u56e0\u5b50&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5047\u8bbe\u4e00\u4e2a\u8c03\u5ea6\u5b9e\u4f53\u88ab\u8c03\u5ea6\u8fd0\u884c&#xff0c;\u8fd0\u884c\u65f6\u95f4\u6bb5\u53ef\u4ee5\u5206\u6210\u4e09\u4e2a\u6bb5 d1\/d2\/d3&#xff0c;\u8fd9\u4e09\u4e2a\u6bb5\u662f\u88ab1024us\u7684\u8ba1\u7b97\u5468\u671f\u5206\u9694\u800c\u6210&#xff0c;period_contrib \u662f\u8c03\u5ea6\u5b9e\u4f53 last_update_time \u65f6\u5728\u8ba1\u7b97\u5468\u671f\u95f4\u7684\u8d21\u732e\u503c&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u603b\u4f53\u7684\u8d21\u732e\u503c&#xff0c;\u4e5f\u662f\u6839\u636e d1\/d2\/d3 \u6765\u5206\u6bb5\u8ba1\u7b97&#xff0c;\u6700\u7ec8\u76f8\u52a0\u5373\u53ef&#xff1b;<\/p>\n<\/li>\n<li>\n<p>y\u4e3a\u8870\u51cf\u56e0\u5b50&#xff0c;\u6bcf\u96941024us\u5c31\u4e58\u4ee5y\u6765\u8870\u51cf\u4e00\u6b21\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8ba1\u7b97\u7684\u8c03\u5ea6\u6d41\u7a0b\u5982\u4e0b\u56fe&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"290\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115753-696e1c4116d8a.png\" width=\"728\" \/><\/p>\n<ul>\n<li>\n<p>\u51fd\u6570\u4e3b\u8981\u662f\u8ba1\u7b97\u65f6\u95f4\u5dee&#xff0c;\u518d\u5206\u6210 d1\/d2\/d3 \u6765\u5206\u6bb5\u8ba1\u7b97\u5904\u7406&#xff0c;\u6700\u7ec8\u66f4\u65b0\u76f8\u5e94\u7684\u5b57\u6bb5&#xff1b;<\/p>\n<\/li>\n<li>\n<p>decay_load \u51fd\u6570\u8981\u8ba1\u7b97 val*y^n&#xff0c;\u5185\u6838\u63d0\u4f9b\u4e86\u4e00\u5f20\u8868\u6765\u907f\u514d\u6d6e\u70b9\u8fd0\u7b97&#xff0c;\u503c\u5b58\u50a8\u5728 runnable_avg-yN_inv \u6570\u7ec4\u4e2d\u3002<\/p>\n<\/li>\n<\/ul>\n<p>static const u32 runnable_avg_yN_inv[] &#061; {<br \/>\n        0xffffffff, 0xfa83b2da, 0xf5257d14, 0xefe4b99a, 0xeac0c6e6, 0xe5b906e6,<br \/>\n        0xe0ccdeeb, 0xdbfbb796, 0xd744fcc9, 0xd2a81d91, 0xce248c14, 0xc9b9bd85,<br \/>\n        0xc5672a10, 0xc12c4cc9, 0xbd08a39e, 0xb8fbaf46, 0xb504f333, 0xb123f581,<br \/>\n        0xad583ee9, 0xa9a15ab4, 0xa5fed6a9, 0xa2704302, 0x9ef5325f, 0x9b8d39b9,<br \/>\n        0x9837f050, 0x94f4efa8, 0x91c3d373, 0x8ea4398a, 0x8b95c1e3, 0x88980e80,<br \/>\n        0x85aac367, 0x82cd8698,<br \/>\n}; <\/p>\n<p>Linux\u4e2d\u4f7f\u7528 struct sched_avg \u6765\u8bb0\u5f55\u8c03\u5ea6\u5b9e\u4f53\u548cCFS\u8fd0\u884c\u961f\u5217\u7684\u8d1f\u8f7d\u4fe1\u606f&#xff0c;\u56e0\u6b64 struct sched_entity \u548c struct cfs_rq \u7ed3\u6784\u4f53\u4e2d&#xff0c;\u90fd\u5305\u542b\u4e86 struct sched_avg&#xff0c;\u5b57\u6bb5\u4ecb\u7ecd\u5982\u4e0b&#xff1a;<\/p>\n<p>struct sched_avg {<br \/>\n        u64                                last_update_time;       \/\/\u4e0a\u4e00\u6b21\u8d1f\u8f7d\u66f4\u65b0\u7684\u65f6\u95f4&#xff0c;\u4e3b\u8981\u7528\u4e8e\u8ba1\u7b97\u65f6\u95f4\u5dee&#xff1b;<br \/>\n        u64                                load_sum;                   \/\/\u53ef\u8fd0\u884c\u65f6\u95f4\u5e26\u6765\u7684\u8d1f\u8f7d\u8d21\u732e\u603b\u548c&#xff0c;\u5305\u62ec\u7b49\u5f85\u8c03\u5ea6\u65f6\u95f4\u548c\u6b63\u5728\u8fd0\u884c\u65f6\u95f4&#xff1b;<br \/>\n        u32                                util_sum;                     \/\/\u6b63\u5728\u8fd0\u884c\u65f6\u95f4\u5e26\u6765\u7684\u8d1f\u8f7d\u8d21\u732e\u603b\u548c&#xff1b;<br \/>\n        u32                                period_contrib;           \/\/\u4e0a\u4e00\u6b21\u8d1f\u8f7d\u66f4\u65b0\u65f6&#xff0c;\u5bf91024\u6c42\u4f59\u7684\u503c&#xff1b;<br \/>\n        unsigned long                        load_avg;           \/\/\u53ef\u8fd0\u884c\u65f6\u95f4\u7684\u5e73\u5747\u8d1f\u8f7d\u8d21\u732e&#xff1b;<br \/>\n        unsigned long                        util_avg;           \/\/\u6b63\u5728\u8fd0\u884c\u65f6\u95f4\u7684\u5e73\u5747\u8d1f\u8f7d\u8d21\u732e&#xff1b;<br \/>\n}; <\/p>\n<h3>PELT\u8ba1\u7b97\u8c03\u7528<\/h3>\n<p>PELT\u8ba1\u7b97\u7684\u53d1\u751f\u65f6\u673a\u5982\u4e0b\u56fe\u6240\u793a&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"555\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115753-696e1c4127d48.png\" width=\"902\" \/><\/p>\n<p>\u8c03\u5ea6\u5b9e\u4f53\u7684\u76f8\u5173\u64cd\u4f5c&#xff0c;\u5305\u62ec\u5165\u5217\u51fa\u5217\u64cd\u4f5c&#xff0c;\u90fd\u4f1a\u8fdb\u884c\u8d1f\u8f7d\u8d21\u732e\u7684\u8ba1\u7b97\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u6982\u8ff0<br \/>\nCPU\u8d1f\u8f7d&#xff08;CPU load&#xff09;\u6307\u7684\u662f\u67d0\u4e2a\u65f6\u95f4\u70b9\u8fdb\u7a0b\u5bf9\u7cfb\u7edf\u4ea7\u751f\u7684\u538b\u529b\u3002 CPU\u7684\u8fd0\u884c\u80fd\u529b&#xff0c;\u5c31\u5982\u5927\u6865\u7684\u901a\u884c\u80fd\u529b&#xff0c;\u5206\u522b\u6709\u6ee1\u8d1f\u8377&#xff0c;\u975e\u6ee1\u8d1f\u8377&#xff0c;\u8d85\u8d1f\u8377\u7b49\u72b6\u6001&#xff0c;\u8fd9\u51e0\u79cd\u72b6\u6001\u5bf9\u5e94\u4e0d\u540c\u7684CPU load\u503c&#xff1b;  \u5355CPU\u6ee1\u8d1f\u8377\u8fd0\u884c\u65f6 cpu_load \u4e3a1&#xff0c;\u5f53\u591a\u4e2aCPU\u6216\u591a\u6838\u65f6&#xff0c;\u76f8\u5f53\u4e8e\u5927\u6865\u6709\u591a\u4e2a\u8f66\u9053&#xff0c;\u6ee1\u8d1f\u8377\u8fd0\u884c\u65f6 cpu_load \u503c<\/p>\n","protected":false},"author":2,"featured_media":62318,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[6604,58,1084],"topic":[],"class_list":["post-62328","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/62328.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u6982\u8ff0 CPU\u8d1f\u8f7d&#xff08;CPU load&#xff09;\u6307\u7684\u662f\u67d0\u4e2a\u65f6\u95f4\u70b9\u8fdb\u7a0b\u5bf9\u7cfb\u7edf\u4ea7\u751f\u7684\u538b\u529b\u3002 CPU\u7684\u8fd0\u884c\u80fd\u529b&#xff0c;\u5c31\u5982\u5927\u6865\u7684\u901a\u884c\u80fd\u529b&#xff0c;\u5206\u522b\u6709\u6ee1\u8d1f\u8377&#xff0c;\u975e\u6ee1\u8d1f\u8377&#xff0c;\u8d85\u8d1f\u8377\u7b49\u72b6\u6001&#xff0c;\u8fd9\u51e0\u79cd\u72b6\u6001\u5bf9\u5e94\u4e0d\u540c\u7684CPU load\u503c&#xff1b; \u5355CPU\u6ee1\u8d1f\u8377\u8fd0\u884c\u65f6 cpu_load \u4e3a1&#xff0c;\u5f53\u591a\u4e2aCPU\u6216\u591a\u6838\u65f6&#xff0c;\u76f8\u5f53\u4e8e\u5927\u6865\u6709\u591a\u4e2a\u8f66\u9053&#xff0c;\u6ee1\u8d1f\u8377\u8fd0\u884c\u65f6 cpu_load \u503c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/62328.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-19T11:57:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c4029488.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/62328.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/62328.html\",\"name\":\"\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-19T11:57:54+00:00\",\"dateModified\":\"2026-01-19T11:57:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/62328.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/62328.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/62328.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/62328.html","og_locale":"zh_CN","og_type":"article","og_title":"\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u6982\u8ff0 CPU\u8d1f\u8f7d&#xff08;CPU load&#xff09;\u6307\u7684\u662f\u67d0\u4e2a\u65f6\u95f4\u70b9\u8fdb\u7a0b\u5bf9\u7cfb\u7edf\u4ea7\u751f\u7684\u538b\u529b\u3002 CPU\u7684\u8fd0\u884c\u80fd\u529b&#xff0c;\u5c31\u5982\u5927\u6865\u7684\u901a\u884c\u80fd\u529b&#xff0c;\u5206\u522b\u6709\u6ee1\u8d1f\u8377&#xff0c;\u975e\u6ee1\u8d1f\u8377&#xff0c;\u8d85\u8d1f\u8377\u7b49\u72b6\u6001&#xff0c;\u8fd9\u51e0\u79cd\u72b6\u6001\u5bf9\u5e94\u4e0d\u540c\u7684CPU load\u503c&#xff1b; \u5355CPU\u6ee1\u8d1f\u8377\u8fd0\u884c\u65f6 cpu_load \u4e3a1&#xff0c;\u5f53\u591a\u4e2aCPU\u6216\u591a\u6838\u65f6&#xff0c;\u76f8\u5f53\u4e8e\u5927\u6865\u6709\u591a\u4e2a\u8f66\u9053&#xff0c;\u6ee1\u8d1f\u8377\u8fd0\u884c\u65f6 cpu_load \u503c","og_url":"https:\/\/www.wsisp.com\/helps\/62328.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-19T11:57:54+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260119115752-696e1c4029488.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/62328.html","url":"https:\/\/www.wsisp.com\/helps\/62328.html","name":"\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-19T11:57:54+00:00","dateModified":"2026-01-19T11:57:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/62328.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/62328.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/62328.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\uff08\u4e8c\uff09Linux \u8c03\u5ea6\u5668 - CPU\u8d1f\u8f7d"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/62328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=62328"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/62328\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/62318"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=62328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=62328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=62328"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=62328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}