1.. SPDX-License-Identifier: GPL-2.0 2.. include:: ../disclaimer-zh_CN.rst 3 4:Original: Documentation/scheduler/sched-energy.rst 5 6:������: 7 8 ��������� Tang Yizhou <tangyeechou@gmail.com> 9 10============ 11������������������ 12============ 13 141. ������ 15------- 16 17���������������������EAS������������������������������������������CPU������������������������������EAS������ 18���������������������EM������������������������������������������CPU������������������������������������������ 19������������������������������EAS��������������������������������������������������������������������������������� 20������������������������ 21 22���������������������������������������������������������:: 23 24 /!\ EAS���������������CPU��������������� /!\ 25 26EAS������������CPU������������������Arm������������big.LITTLE������������������������������������������ 27��������������������������������������������������� 28 29EAS���������������EM������������������������������������������������������������������������������������������ 30���������������������������������������������Documentation/power/energy-model.rst������ 31 32 332. ��������������� 34------------- 35 36������������������������������: 37 - ������ = [������] ��������������������������������������������������� 38 - ������ = ������/������ = [������/���] = [������] 39 40 EAS���������������������������������������������������������������������������������������������������:: 41 42 ������ [���������/���] 43 ---------------- 44 ������ [������] 45 46���������������������:: 47 48 ������ [������] 49 ----------- 50 ��������� 51 52������������������������������������������������������������������������������������������������������������������ 53��������������������������������������������������������������������������������� 54 55������EM��������������������������������������������������������������������������������������������������� 56������������������������������������������������EM��������������������������������������������������������� 57��������� 58 59���������������EAS���������CFS���������������CPU��������������������������������������������������������� 60���������������������������������EM��������������������������������������������������������������������������� 61CPU���������������������������������������������CPU���EAS��������������������������������������������������� 62������������������CPU������������������������������������������������������ 63 64 653. ������������ 66----------- 67 68EAS������������������������������������������������������������������������������������������������CPU��������� 69CPU������������������������������������������������������������������������������������������������������������ 70���������������CPU������������������������������������1024������������������������������������������ 71���PELT���������������������������������������������������������������������������������EAS������������������ 72������/CPU���������/���������������������������������������������������������������CPU��������������������� 73���������������arch_scale_cpu_capacity()��������������������� 74 75EAS������������������������������������������������������EM���������������������������������������EM��������� 76������������������������������������������������������������������������������������������������������������������������ 77���Documentation/power/energy-model.rst��� 78 79���������������������������������������������������������������������������EM������������������������������������ 80���rd������������������������������������rd->span������������������������������������������������������������ 81���������������������������EM���������������������������em_perf_domain������������ 82 83������������������������������������������������cpuset���������������������������cpuset��������������������� 84������������������������������������������������������������������������������ 85 86������1 87 ������������������������12���CPU������������������3������������������pd0���pd4���pd8��������������� 88 ������������:: 89 90 CPUs: 0 1 2 3 4 5 6 7 8 9 10 11 91 PDs: |--pd0--|--pd4--|---pd8---| 92 RDs: |----rd1----|-----rd2-----| 93 94 ���������������������������������������������������������������cpusets������������������������������������������ 95 ������������������6���CPU������������������������������������������rd1���rd2���������pd4���rd1���rd2 96 ������������������������������������������������������������������->pd������������: 97 98 * rd1->pd: pd0 -> pd4 99 * rd2->pd: pd4 -> pd8 100 101 ���������������������������pd4��������������������������������������������������������������������������� 102 ���������������������������������EM��������������������������������������� 103 104���������������������������������������������������������������������������������������������RCU������������������ 105������������������������������������������������������������ 106 107EAS���������������������������������sched_energy_present������������������������������������EAS 108������������������������������������������������������������6������������������������������ 109 110 1114. ������������������������ 112------------------- 113 114EAS���������CFS���������������������������������������������������������������������EM���PELT��������������������� 115���������CPU������EAS���������������select_task_rq_fair()������find_energy_efficient_cpu() 116���������������������������������������������������������������������������������������������������CPU������ - CPU 117���������������CPU������������������������������������������������������������������������������������������CPU������ 118���������������������������prev_cpu��������������������������� 119 120���������������������������������find_energy_efficient_cpu()������compute_energy()��������� 121������������������������������compute_energy()���������CPU��������������������������������������������� 122���������������������������EM���������������API em_pd_energy()������������������������������������������������ 123��������������������������� 124 125��������������������������������������������������������������������������� 126 127������2 128 ���������������������������������������������������������������������������������������2���CPU���CPU0���CPU1 129 ������������CPU2���CPU3������������ 130 131 ������������������������������P������������CPU���������������������util_avg = 200������������������������ 132 prev_cpu = 0���������������������CPU0������ 133 134 ������CPU������������������������������������CPU 0-3���util_avg���������400���100���600���500��� 135 ������������������������������������������OPP���������������OPP���������CPU��������������������������������� 136 ���������������P���util_avg������������������"PP":: 137 138 CPU util. 139 1024 - - - - - - - Energy Model 140 +-----------+-------------+ 141 | Little | Big | 142 768 ============= +-----+-----+------+------+ 143 | Cap | Pwr | Cap | Pwr | 144 +-----+-----+------+------+ 145 512 =========== - ##- - - - - | 170 | 50 | 512 | 400 | 146 ## ## | 341 | 150 | 768 | 800 | 147 341 -PP - - - - ## ## | 512 | 300 | 1024 | 1700 | 148 PP ## ## +-----+-----+------+------+ 149 170 -## - - - - ## ## 150 ## ## ## ## 151 ------------ ------------- 152 CPU0 CPU1 CPU2 CPU3 153 154 Current OPP: ===== Other OPP: - - - util_avg (100 each): ## 155 156 157 find_energy_efficient_cpu()���������������������������������������������������������������CPU��� 158 ���������������������CPU1���CPU3������������������������������P������������������������������������������������ 159 ������������������������������������������P������CPU0������������������������EAS������OPPs��������������� 160 ���������CPUFreq���������schedutil������������������������������������������������������������6��������� 161 162 **������1. P������������CPU1**:: 163 164 1024 - - - - - - - 165 166 Energy calculation: 167 768 ============= * CPU0: 200 / 341 * 150 = 88 168 * CPU1: 300 / 341 * 150 = 131 169 * CPU2: 600 / 768 * 800 = 625 170 512 - - - - - - - ##- - - - - * CPU3: 500 / 768 * 800 = 520 171 ## ## => total_energy = 1364 172 341 =========== ## ## 173 PP ## ## 174 170 -## - - PP- ## ## 175 ## ## ## ## 176 ------------ ------------- 177 CPU0 CPU1 CPU2 CPU3 178 179 180 **������2. P������������CPU3**:: 181 182 1024 - - - - - - - 183 184 Energy calculation: 185 768 ============= * CPU0: 200 / 341 * 150 = 88 186 * CPU1: 100 / 341 * 150 = 43 187 PP * CPU2: 600 / 768 * 800 = 625 188 512 - - - - - - - ##- - -PP - * CPU3: 700 / 768 * 800 = 729 189 ## ## => total_energy = 1485 190 341 =========== ## ## 191 ## ## 192 170 -## - - - - ## ## 193 ## ## ## ## 194 ------------ ------------- 195 CPU0 CPU1 CPU2 CPU3 196 197 **������3. P������������prev_cpu/CPU0**:: 198 199 1024 - - - - - - - 200 201 Energy calculation: 202 768 ============= * CPU0: 400 / 512 * 300 = 234 203 * CPU1: 100 / 512 * 300 = 58 204 * CPU2: 600 / 768 * 800 = 625 205 512 =========== - ##- - - - - * CPU3: 500 / 768 * 800 = 520 206 ## ## => total_energy = 1437 207 341 -PP - - - - ## ## 208 PP ## ## 209 170 -## - - - - ## ## 210 ## ## ## ## 211 ------------ ------------- 212 CPU0 CPU1 CPU2 CPU3 213 214 ������������������������������������1���������������������������������������������������������CPU1��������������� 215 ������ 216 217������������������������������������������������������������������������������������������������������������������������ 218���������������������������������������������������������������OPP���������������������OPP������������������������������ 219������������������������������������������������������������������������������������������������������������������������ 220������������������������������������������������������������ 221 222���������������������OPP���������������OPP��������������������������������������������������������������������������� 223������������������������������������������������������������������������������������������������������OPP��������������� 224������������������������������������������������������������������������������������������������������������������������ 225���������������������������������������������������������������������������������������������������������������������OPP 226���������������������������CPU������������������������������������������������������������������������������������������ 227������������������������������������OPP������������ 228 229������������������������������������������������������������������������������������������������������������������������ 230������������CPU������������OPP���������������������������������������������������������������������EM������������ 231EAS��������������������������������������������������������������������������������������������������������������� 232������������������������������������EAS��������������������������������������������������������������� 233 234 2355. ��������������� 236------------- 237 238���������������������������EAS������������������������������������������������CPU���������������������������������CPU 239������������������������������������������������������������CPU������������������������������������������������������������ 240������������������������������������EAS���������������������CPU������������������������80%������������������������������ 241���������������������������������CPU���������������������������������������������������EAS������������������������������ 242EAS���������������������������������������������������������CPU���������������CPU��������������������������������� 243���������������������������������������������������EAS������������������������������������������������������������������������ 244������������������������������������80%������������������������ 245 246 a. ���������CPU���������������������������������EAS������������������������������������������������������������ 247 ������������������ 248 b. ������������������������������nice������������������������������������������������CPU��������� 249 c. ���������������������������������������������������������������������/������������������������������������������ 250 ������ 251 252������������CPU���������������80%������������������������������������������������������������������������������������������ 253���������������������������������������������������EAS������������������������������������������������������������������������ 254���������������CPU���������������������������������������������������������������������������������������nice������ 255 256������������������������������������������������������������������������������������������������������������������������ 257������CFS���������������������������������������������������������������CPU������������������������������������������������ 258���������������CFS������������������������������������������������������������������ 259 260 2616. EAS������������������ 262------------------ 263 264���������������������������������CPU������������������������������������������������������������������������������������ 265������������������������������������������������������������������ 266 267 2686.1 - ���������CPU������ 269^^^^^^^^^^^^^^^^^^^ 270 271 272���������������������������������������CPU���������������������������EAS��������������������������� 273SD_ASYM_CPUCAPACITY_FULL��������������������������������������������������������������������������������� 274 275������Documentation/scheduler/sched-capacity.rst������������sched_domain������������ 276��������������������������������������������� 277 278������������EAS���������������������SMP������������������SMP��������������������������������������������������� 279������������������������������������������������������������������������ 280 281 2826.2 - ��������������������� 283^^^^^^^^^^^^^^^^^^^^ 284 285EAS���������������������EM������������������������������������������������������������������������EM������������ 286���������������������������EAS��������������������������������������� 287Documentation/power/energy-model.rst������������EM��������������� 288 289���������������������������������EM������������������������������EAS��� 290 291EAS������EM��������������������������������������������������������������������������������������������������� 292���������������EAS���������EM��������������������������������������������������������������������������������� 293 294 295 2966.3 - ��������������������� 297^^^^^^^^^^^^^^^^^^^^ 298 299���������������������������������������������������������EM������������������CPU��������������������������������� 300��������������������������������������������������������������������������������������������������������������������� 301 302 C = Nd * (Nc + Ns) 303 304���������Nd������������������������Nc���CPU������������Ns���OPP��������������������������������������������� 305������������4���OPP������Ns = 8������ 306 307������������������������������������������������������������������������������������������������C������������������ 308���������������EM_MAX_COMPLEXITY���������������������������������2048���������EAS������������������ 309��������� 310 311������������������������������������������������������EAS������������������������������������������������������ 312��������������������������������������������� 313 314 1. ������������������������������������������������������������cpuset������������������������������������ 315 ������EAS������������������������������������������������������������������������������������������������ 316 ������������������������������������������������ 317 2. ���������������������EAS������������������������������������������������������������������������������ 318 ���EM��� 319 320 3216.4 - Schedutil��������� 322^^^^^^^^^^^^^^^^^^^^^ 323 324EAS������������CPU������������������������������OPP��������������������������������������������������������� 325���������������������CPU���OPP������CPU��������������������������� 326 327������������������������������������������������������������������������������������������������������������������ 328���������������������������������������������CPUFreq������������schedutil������_������_��������������� 329������������������������������������EAS������������������������������������������schedutil��������������� 330��������������������������������������������������������������������������������������������� 331 332������������EAS���schedutil��������������������������������������������� 333 334 3356.5 ������������������������������ 336^^^^^^^^^^^^^^^^^^^^^^^^ 337 338������������������CPU������������������������������������������������EAS������������������������CPU��������� 339PELT������������������������������������������������������������arch_scale{cpu,freq}_capacity() 340��������������������� 341 342���������������������������������������������������������������EAS��� 343 344 3456.6 ������������SMT��� 346^^^^^^^^^^^^^^^^^ 347 348���������������EAS������������SMT������������������������������������������������������EAS������������������������ 349CPU��������������������������������������������������������� 350 351������������SMT���������EAS��� 352