cpu-idle-cooling.rst 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ================
  3. CPU Idle Cooling
  4. ================
  5. Situation:
  6. ----------
  7. Under certain circumstances a SoC can reach a critical temperature
  8. limit and is unable to stabilize the temperature around a temperature
  9. control. When the SoC has to stabilize the temperature, the kernel can
  10. act on a cooling device to mitigate the dissipated power. When the
  11. critical temperature is reached, a decision must be taken to reduce
  12. the temperature, that, in turn impacts performance.
  13. Another situation is when the silicon temperature continues to
  14. increase even after the dynamic leakage is reduced to its minimum by
  15. clock gating the component. This runaway phenomenon can continue due
  16. to the static leakage. The only solution is to power down the
  17. component, thus dropping the dynamic and static leakage that will
  18. allow the component to cool down.
  19. Last but not least, the system can ask for a specific power budget but
  20. because of the OPP density, we can only choose an OPP with a power
  21. budget lower than the requested one and under-utilize the CPU, thus
  22. losing performance. In other words, one OPP under-utilizes the CPU
  23. with a power less than the requested power budget and the next OPP
  24. exceeds the power budget. An intermediate OPP could have been used if
  25. it were present.
  26. Solutions:
  27. ----------
  28. If we can remove the static and the dynamic leakage for a specific
  29. duration in a controlled period, the SoC temperature will
  30. decrease. Acting on the idle state duration or the idle cycle
  31. injection period, we can mitigate the temperature by modulating the
  32. power budget.
  33. The Operating Performance Point (OPP) density has a great influence on
  34. the control precision of cpufreq, however different vendors have a
  35. plethora of OPP density, and some have large power gap between OPPs,
  36. that will result in loss of performance during thermal control and
  37. loss of power in other scenarios.
  38. At a specific OPP, we can assume that injecting idle cycle on all CPUs
  39. belong to the same cluster, with a duration greater than the cluster
  40. idle state target residency, we lead to dropping the static and the
  41. dynamic leakage for this period (modulo the energy needed to enter
  42. this state). So the sustainable power with idle cycles has a linear
  43. relation with the OPP’s sustainable power and can be computed with a
  44. coefficient similar to::
  45. Power(IdleCycle) = Coef x Power(OPP)
  46. Idle Injection:
  47. ---------------
  48. The base concept of the idle injection is to force the CPU to go to an
  49. idle state for a specified time each control cycle, it provides
  50. another way to control CPU power and heat in addition to
  51. cpufreq. Ideally, if all CPUs belonging to the same cluster, inject
  52. their idle cycles synchronously, the cluster can reach its power down
  53. state with a minimum power consumption and reduce the static leakage
  54. to almost zero. However, these idle cycles injection will add extra
  55. latencies as the CPUs will have to wakeup from a deep sleep state.
  56. We use a fixed duration of idle injection that gives an acceptable
  57. performance penalty and a fixed latency. Mitigation can be increased
  58. or decreased by modulating the duty cycle of the idle injection.
  59. ::
  60. ^
  61. |
  62. |
  63. |------- -------
  64. |_______|_______________________|_______|___________
  65. <------>
  66. idle <---------------------->
  67. running
  68. <----------------------------->
  69. duty cycle 25%
  70. The implementation of the cooling device bases the number of states on
  71. the duty cycle percentage. When no mitigation is happening the cooling
  72. device state is zero, meaning the duty cycle is 0%.
  73. When the mitigation begins, depending on the governor's policy, a
  74. starting state is selected. With a fixed idle duration and the duty
  75. cycle (aka the cooling device state), the running duration can be
  76. computed.
  77. The governor will change the cooling device state thus the duty cycle
  78. and this variation will modulate the cooling effect.
  79. ::
  80. ^
  81. |
  82. |
  83. |------- -------
  84. |_______|_______________|_______|___________
  85. <------>
  86. idle <-------------->
  87. running
  88. <--------------------->
  89. duty cycle 33%
  90. ^
  91. |
  92. |
  93. |------- -------
  94. |_______|_______|_______|___________
  95. <------>
  96. idle <------>
  97. running
  98. <------------->
  99. duty cycle 50%
  100. The idle injection duration value must comply with the constraints:
  101. - It is less than or equal to the latency we tolerate when the
  102. mitigation begins. It is platform dependent and will depend on the
  103. user experience, reactivity vs performance trade off we want. This
  104. value should be specified.
  105. - It is greater than the idle state’s target residency we want to go
  106. for thermal mitigation, otherwise we end up consuming more energy.
  107. Power considerations
  108. --------------------
  109. When we reach the thermal trip point, we have to sustain a specified
  110. power for a specific temperature but at this time we consume::
  111. Power = Capacitance x Voltage^2 x Frequency x Utilisation
  112. ... which is more than the sustainable power (or there is something
  113. wrong in the system setup). The ‘Capacitance’ and ‘Utilisation’ are a
  114. fixed value, ‘Voltage’ and the ‘Frequency’ are fixed artificially
  115. because we don’t want to change the OPP. We can group the
  116. ‘Capacitance’ and the ‘Utilisation’ into a single term which is the
  117. ‘Dynamic Power Coefficient (Cdyn)’ Simplifying the above, we have::
  118. Pdyn = Cdyn x Voltage^2 x Frequency
  119. The power allocator governor will ask us somehow to reduce our power
  120. in order to target the sustainable power defined in the device
  121. tree. So with the idle injection mechanism, we want an average power
  122. (Ptarget) resulting in an amount of time running at full power on a
  123. specific OPP and idle another amount of time. That could be put in a
  124. equation::
  125. P(opp)target = ((Trunning x (P(opp)running) + (Tidle x P(opp)idle)) /
  126. (Trunning + Tidle)
  127. ...
  128. Tidle = Trunning x ((P(opp)running / P(opp)target) - 1)
  129. At this point if we know the running period for the CPU, that gives us
  130. the idle injection we need. Alternatively if we have the idle
  131. injection duration, we can compute the running duration with::
  132. Trunning = Tidle / ((P(opp)running / P(opp)target) - 1)
  133. Practically, if the running power is less than the targeted power, we
  134. end up with a negative time value, so obviously the equation usage is
  135. bound to a power reduction, hence a higher OPP is needed to have the
  136. running power greater than the targeted power.
  137. However, in this demonstration we ignore three aspects:
  138. * The static leakage is not defined here, we can introduce it in the
  139. equation but assuming it will be zero most of the time as it is
  140. difficult to get the values from the SoC vendors
  141. * The idle state wake up latency (or entry + exit latency) is not
  142. taken into account, it must be added in the equation in order to
  143. rigorously compute the idle injection
  144. * The injected idle duration must be greater than the idle state
  145. target residency, otherwise we end up consuming more energy and
  146. potentially invert the mitigation effect
  147. So the final equation is::
  148. Trunning = (Tidle - Twakeup ) x
  149. (((P(opp)dyn + P(opp)static ) - P(opp)target) / P(opp)target )