psci-performance-juno.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. PSCI Performance Measurements on Arm Juno Development Platform
  2. ==============================================================
  3. This document summarises the findings of performance measurements of key
  4. operations in the Trusted Firmware-A Power State Coordination Interface (PSCI)
  5. implementation, using the in-built Performance Measurement Framework (PMF) and
  6. runtime instrumentation timestamps.
  7. Method
  8. ------
  9. We used the `Juno R1 platform`_ for these tests, which has 4 x Cortex-A53 and 2
  10. x Cortex-A57 clusters running at the following frequencies:
  11. +-----------------+--------------------+
  12. | Domain | Frequency (MHz) |
  13. +=================+====================+
  14. | Cortex-A57 | 900 (nominal) |
  15. +-----------------+--------------------+
  16. | Cortex-A53 | 650 (underdrive) |
  17. +-----------------+--------------------+
  18. | AXI subsystem | 533 |
  19. +-----------------+--------------------+
  20. Juno supports CPU, cluster and system power down states, corresponding to power
  21. levels 0, 1 and 2 respectively. It does not support any retention states.
  22. Given that runtime instrumentation using PMF is invasive, there is a small
  23. (unquantified) overhead on the results. PMF uses the generic counter for
  24. timestamps, which runs at 50MHz on Juno.
  25. The following source trees and binaries were used:
  26. - TF-A [`v2.9-rc0`_]
  27. - TFTF [`v2.9-rc0`_]
  28. Please see the Runtime Instrumentation :ref:`Testing Methodology
  29. <Runtime Instrumentation Methodology>`
  30. page for more details.
  31. Procedure
  32. ---------
  33. #. Build TFTF with runtime instrumentation enabled:
  34. .. code:: shell
  35. make CROSS_COMPILE=aarch64-none-elf- PLAT=juno \
  36. TESTS=runtime-instrumentation all
  37. #. Fetch Juno's SCP binary from TF-A's archive:
  38. .. code:: shell
  39. curl --fail --connect-timeout 5 --retry 5 -sLS -o scp_bl2.bin \
  40. https://downloads.trustedfirmware.org/tf-a/css_scp_2.12.0/juno/release/juno-bl2.bin
  41. #. Build TF-A with the following build options:
  42. .. code:: shell
  43. make CROSS_COMPILE=aarch64-none-elf- PLAT=juno \
  44. BL33="/path/to/tftf.bin" SCP_BL2="scp_bl2.bin" \
  45. ENABLE_RUNTIME_INSTRUMENTATION=1 fiptool all fip
  46. #. Load the following images onto the development board: ``fip.bin``,
  47. ``scp_bl2.bin``.
  48. Results
  49. -------
  50. ``CPU_SUSPEND`` to deepest power level
  51. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  52. .. table:: ``CPU_SUSPEND`` latencies (µs) to deepest power level in
  53. parallel
  54. +---------+------+-----------+---------+-------------+
  55. | Cluster | Core | Powerdown | Wakekup | Cache Flush |
  56. +=========+======+===========+=========+=============+
  57. | 0 | 0 | 243.76 | 239.92 | 6.32 |
  58. +---------+------+-----------+---------+-------------+
  59. | 0 | 1 | 663.5 | 30.32 | 167.82 |
  60. +---------+------+-----------+---------+-------------+
  61. | 1 | 0 | 105.12 | 22.84 | 5.88 |
  62. +---------+------+-----------+---------+-------------+
  63. | 1 | 1 | 384.16 | 19.06 | 4.7 |
  64. +---------+------+-----------+---------+-------------+
  65. | 1 | 2 | 523.98 | 270.46 | 4.74 |
  66. +---------+------+-----------+---------+-------------+
  67. | 1 | 3 | 950.54 | 220.9 | 89.2 |
  68. +---------+------+-----------+---------+-------------+
  69. .. table:: ``CPU_SUSPEND`` latencies (µs) to deepest power level in
  70. serial
  71. +---------+------+-----------+---------+-------------+
  72. | Cluster | Core | Powerdown | Wakekup | Cache Flush |
  73. +=========+======+===========+=========+=============+
  74. | 0 | 0 | 266.96 | 31.74 | 167.92 |
  75. +---------+------+-----------+---------+-------------+
  76. | 0 | 1 | 266.9 | 31.52 | 167.82 |
  77. +---------+------+-----------+---------+-------------+
  78. | 1 | 0 | 279.86 | 23.42 | 87.52 |
  79. +---------+------+-----------+---------+-------------+
  80. | 1 | 1 | 101.38 | 18.8 | 4.64 |
  81. +---------+------+-----------+---------+-------------+
  82. | 1 | 2 | 101.18 | 19.28 | 4.64 |
  83. +---------+------+-----------+---------+-------------+
  84. | 1 | 3 | 101.32 | 19.02 | 4.62 |
  85. +---------+------+-----------+---------+-------------+
  86. ``CPU_SUSPEND`` to power level 0
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. .. table:: ``CPU_SUSPEND`` latencies (µs) to power level 0 in
  89. parallel
  90. +---------+------+-----------+---------+-------------+
  91. | Cluster | Core | Powerdown | Wakekup | Cache Flush |
  92. +=========+======+===========+=========+=============+
  93. +---------+------+-----------+---------+-------------+
  94. | 0 | 0 | 661.94 | 22.88 | 9.66 |
  95. +---------+------+-----------+---------+-------------+
  96. | 0 | 1 | 801.64 | 23.38 | 9.62 |
  97. +---------+------+-----------+---------+-------------+
  98. | 1 | 0 | 105.56 | 16.02 | 8.12 |
  99. +---------+------+-----------+---------+-------------+
  100. | 1 | 1 | 245.42 | 16.26 | 7.78 |
  101. +---------+------+-----------+---------+-------------+
  102. | 1 | 2 | 384.42 | 16.1 | 7.84 |
  103. +---------+------+-----------+---------+-------------+
  104. | 1 | 3 | 523.74 | 15.4 | 8.02 |
  105. +---------+------+-----------+---------+-------------+
  106. .. table:: ``CPU_SUSPEND`` latencies (µs) to power level 0 in serial
  107. +---------+------+-----------+---------+-------------+
  108. | Cluster | Core | Powerdown | Wakekup | Cache Flush |
  109. +=========+======+===========+=========+=============+
  110. | 0 | 0 | 102.16 | 23.64 | 6.7 |
  111. +---------+------+-----------+---------+-------------+
  112. | 0 | 1 | 101.66 | 23.78 | 6.6 |
  113. +---------+------+-----------+---------+-------------+
  114. | 1 | 0 | 277.74 | 15.96 | 4.66 |
  115. +---------+------+-----------+---------+-------------+
  116. | 1 | 1 | 98.0 | 15.88 | 4.64 |
  117. +---------+------+-----------+---------+-------------+
  118. | 1 | 2 | 97.66 | 15.88 | 4.62 |
  119. +---------+------+-----------+---------+-------------+
  120. | 1 | 3 | 97.76 | 15.38 | 4.64 |
  121. +---------+------+-----------+---------+-------------+
  122. ``CPU_OFF`` on all non-lead CPUs
  123. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  124. ``CPU_OFF`` on all non-lead CPUs in sequence then, ``CPU_SUSPEND`` on the lead
  125. core to the deepest power level.
  126. .. table:: ``CPU_OFF`` latencies (µs) on all non-lead CPUs
  127. +---------+------+-----------+---------+-------------+
  128. | Cluster | Core | Powerdown | Wakekup | Cache Flush |
  129. +=========+======+===========+=========+=============+
  130. | 0 | 0 | 265.38 | 34.12 | 167.36 |
  131. +---------+------+-----------+---------+-------------+
  132. | 0 | 1 | 265.72 | 33.98 | 167.48 |
  133. +---------+------+-----------+---------+-------------+
  134. | 1 | 0 | 185.3 | 23.18 | 87.42 |
  135. +---------+------+-----------+---------+-------------+
  136. | 1 | 1 | 101.58 | 23.46 | 4.48 |
  137. +---------+------+-----------+---------+-------------+
  138. | 1 | 2 | 101.66 | 22.02 | 4.72 |
  139. +---------+------+-----------+---------+-------------+
  140. | 1 | 3 | 101.48 | 22.22 | 4.52 |
  141. +---------+------+-----------+---------+-------------+
  142. ``CPU_VERSION`` in parallel
  143. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144. .. table:: ``CPU_VERSION`` latency (µs) in parallel on all cores
  145. +-------------+--------+--------------+
  146. | Cluster | Core | Latency |
  147. +=============+========+==============+
  148. | 0 | 0 | 1.22 |
  149. +-------------+--------+--------------+
  150. | 0 | 1 | 1.2 |
  151. +-------------+--------+--------------+
  152. | 1 | 0 | 0.6 |
  153. +-------------+--------+--------------+
  154. | 1 | 1 | 1.08 |
  155. +-------------+--------+--------------+
  156. | 1 | 2 | 1.04 |
  157. +-------------+--------+--------------+
  158. | 1 | 3 | 1.04 |
  159. +-------------+--------+--------------+
  160. Annotated Historic Results
  161. --------------------------
  162. The following results are based on the upstream `TF master as of 31/01/2017`_.
  163. TF-A was built using the same build instructions as detailed in the procedure
  164. above.
  165. In the results below, CPUs 0-3 refer to CPUs in the little cluster (A53) and
  166. CPUs 4-5 refer to CPUs in the big cluster (A57). In all cases CPU 4 is the lead
  167. CPU.
  168. ``PSCI_ENTRY`` corresponds to the powerdown latency, ``PSCI_EXIT`` the wakeup latency, and
  169. ``CFLUSH_OVERHEAD`` the latency of the cache flush operation.
  170. ``CPU_SUSPEND`` to deepest power level on all CPUs in parallel
  171. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  172. +-------+---------------------+--------------------+--------------------------+
  173. | CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
  174. +=======+=====================+====================+==========================+
  175. | 0 | 27 | 20 | 5 |
  176. +-------+---------------------+--------------------+--------------------------+
  177. | 1 | 114 | 86 | 5 |
  178. +-------+---------------------+--------------------+--------------------------+
  179. | 2 | 202 | 58 | 5 |
  180. +-------+---------------------+--------------------+--------------------------+
  181. | 3 | 375 | 29 | 94 |
  182. +-------+---------------------+--------------------+--------------------------+
  183. | 4 | 20 | 22 | 6 |
  184. +-------+---------------------+--------------------+--------------------------+
  185. | 5 | 290 | 18 | 206 |
  186. +-------+---------------------+--------------------+--------------------------+
  187. A large variance in ``PSCI_ENTRY`` and ``PSCI_EXIT`` times across CPUs is
  188. observed due to TF PSCI lock contention. In the worst case, CPU 3 has to wait
  189. for the 3 other CPUs in the cluster (0-2) to complete ``PSCI_ENTRY`` and release
  190. the lock before proceeding.
  191. The ``CFLUSH_OVERHEAD`` times for CPUs 3 and 5 are higher because they are the
  192. last CPUs in their respective clusters to power down, therefore both the L1 and
  193. L2 caches are flushed.
  194. The ``CFLUSH_OVERHEAD`` time for CPU 5 is a lot larger than that for CPU 3
  195. because the L2 cache size for the big cluster is lot larger (2MB) compared to
  196. the little cluster (1MB).
  197. ``CPU_SUSPEND`` to power level 0 on all CPUs in parallel
  198. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  199. +-------+---------------------+--------------------+--------------------------+
  200. | CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
  201. +=======+=====================+====================+==========================+
  202. | 0 | 116 | 14 | 8 |
  203. +-------+---------------------+--------------------+--------------------------+
  204. | 1 | 204 | 14 | 8 |
  205. +-------+---------------------+--------------------+--------------------------+
  206. | 2 | 287 | 13 | 8 |
  207. +-------+---------------------+--------------------+--------------------------+
  208. | 3 | 376 | 13 | 9 |
  209. +-------+---------------------+--------------------+--------------------------+
  210. | 4 | 29 | 15 | 7 |
  211. +-------+---------------------+--------------------+--------------------------+
  212. | 5 | 21 | 15 | 8 |
  213. +-------+---------------------+--------------------+--------------------------+
  214. There is no lock contention in TF generic code at power level 0 but the large
  215. variance in ``PSCI_ENTRY`` times across CPUs is due to lock contention in Juno
  216. platform code. The platform lock is used to mediate access to a single SCP
  217. communication channel. This is compounded by the SCP firmware waiting for each
  218. AP CPU to enter WFI before making the channel available to other CPUs, which
  219. effectively serializes the SCP power down commands from all CPUs.
  220. On platforms with a more efficient CPU power down mechanism, it should be
  221. possible to make the ``PSCI_ENTRY`` times smaller and consistent.
  222. The ``PSCI_EXIT`` times are consistent across all CPUs because TF does not
  223. require locks at power level 0.
  224. The ``CFLUSH_OVERHEAD`` times for all CPUs are small and consistent since only
  225. the cache associated with power level 0 is flushed (L1).
  226. ``CPU_SUSPEND`` to deepest power level on all CPUs in sequence
  227. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  228. +-------+---------------------+--------------------+--------------------------+
  229. | CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
  230. +=======+=====================+====================+==========================+
  231. | 0 | 114 | 20 | 94 |
  232. +-------+---------------------+--------------------+--------------------------+
  233. | 1 | 114 | 20 | 94 |
  234. +-------+---------------------+--------------------+--------------------------+
  235. | 2 | 114 | 20 | 94 |
  236. +-------+---------------------+--------------------+--------------------------+
  237. | 3 | 114 | 20 | 94 |
  238. +-------+---------------------+--------------------+--------------------------+
  239. | 4 | 195 | 22 | 180 |
  240. +-------+---------------------+--------------------+--------------------------+
  241. | 5 | 21 | 17 | 6 |
  242. +-------+---------------------+--------------------+--------------------------+
  243. The ``CFLUSH_OVERHEAD`` times for lead CPU 4 and all CPUs in the non-lead cluster
  244. are large because all other CPUs in the cluster are powered down during the
  245. test. The ``CPU_SUSPEND`` call powers down to the cluster level, requiring a
  246. flush of both L1 and L2 caches.
  247. The ``CFLUSH_OVERHEAD`` time for CPU 4 is a lot larger than those for the little
  248. CPUs because the L2 cache size for the big cluster is lot larger (2MB) compared
  249. to the little cluster (1MB).
  250. The ``PSCI_ENTRY`` and ``CFLUSH_OVERHEAD`` times for CPU 5 are low because lead
  251. CPU 4 continues to run while CPU 5 is suspended. Hence CPU 5 only powers down to
  252. level 0, which only requires L1 cache flush.
  253. ``CPU_SUSPEND`` to power level 0 on all CPUs in sequence
  254. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  255. +-------+---------------------+--------------------+--------------------------+
  256. | CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
  257. +=======+=====================+====================+==========================+
  258. | 0 | 22 | 14 | 5 |
  259. +-------+---------------------+--------------------+--------------------------+
  260. | 1 | 22 | 14 | 5 |
  261. +-------+---------------------+--------------------+--------------------------+
  262. | 2 | 21 | 14 | 5 |
  263. +-------+---------------------+--------------------+--------------------------+
  264. | 3 | 22 | 14 | 5 |
  265. +-------+---------------------+--------------------+--------------------------+
  266. | 4 | 17 | 14 | 6 |
  267. +-------+---------------------+--------------------+--------------------------+
  268. | 5 | 18 | 15 | 6 |
  269. +-------+---------------------+--------------------+--------------------------+
  270. Here the times are small and consistent since there is no contention and it is
  271. only necessary to flush the cache to power level 0 (L1). This is the best case
  272. scenario.
  273. The ``PSCI_ENTRY`` times for CPUs in the big cluster are slightly smaller than
  274. for the CPUs in little cluster due to greater CPU performance.
  275. The ``PSCI_EXIT`` times are generally lower than in the last test because the
  276. cluster remains powered on throughout the test and there is less code to execute
  277. on power on (for example, no need to enter CCI coherency)
  278. ``CPU_OFF`` on all non-lead CPUs in sequence then ``CPU_SUSPEND`` on lead CPU to deepest power level
  279. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  280. The test sequence here is as follows:
  281. 1. Call ``CPU_ON`` and ``CPU_OFF`` on each non-lead CPU in sequence.
  282. 2. Program wake up timer and suspend the lead CPU to the deepest power level.
  283. 3. Call ``CPU_ON`` on non-lead CPU to get the timestamps from each CPU.
  284. +-------+---------------------+--------------------+--------------------------+
  285. | CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
  286. +=======+=====================+====================+==========================+
  287. | 0 | 110 | 28 | 93 |
  288. +-------+---------------------+--------------------+--------------------------+
  289. | 1 | 110 | 28 | 93 |
  290. +-------+---------------------+--------------------+--------------------------+
  291. | 2 | 110 | 28 | 93 |
  292. +-------+---------------------+--------------------+--------------------------+
  293. | 3 | 111 | 28 | 93 |
  294. +-------+---------------------+--------------------+--------------------------+
  295. | 4 | 195 | 22 | 181 |
  296. +-------+---------------------+--------------------+--------------------------+
  297. | 5 | 20 | 23 | 6 |
  298. +-------+---------------------+--------------------+--------------------------+
  299. The ``CFLUSH_OVERHEAD`` times for all little CPUs are large because all other
  300. CPUs in that cluster are powerered down during the test. The ``CPU_OFF`` call
  301. powers down to the cluster level, requiring a flush of both L1 and L2 caches.
  302. The ``PSCI_ENTRY`` and ``CFLUSH_OVERHEAD`` times for CPU 5 are small because
  303. lead CPU 4 is running and CPU 5 only powers down to level 0, which only requires
  304. an L1 cache flush.
  305. The ``CFLUSH_OVERHEAD`` time for CPU 4 is a lot larger than those for the little
  306. CPUs because the L2 cache size for the big cluster is lot larger (2MB) compared
  307. to the little cluster (1MB).
  308. The ``PSCI_EXIT`` times for CPUs in the big cluster are slightly smaller than
  309. for CPUs in the little cluster due to greater CPU performance. These times
  310. generally are greater than the ``PSCI_EXIT`` times in the ``CPU_SUSPEND`` tests
  311. because there is more code to execute in the "on finisher" compared to the
  312. "suspend finisher" (for example, GIC redistributor register programming).
  313. ``PSCI_VERSION`` on all CPUs in parallel
  314. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  315. Since very little code is associated with ``PSCI_VERSION``, this test
  316. approximates the round trip latency for handling a fast SMC at EL3 in TF.
  317. +-------+-------------------+
  318. | CPU | TOTAL TIME (ns) |
  319. +=======+===================+
  320. | 0 | 3020 |
  321. +-------+-------------------+
  322. | 1 | 2940 |
  323. +-------+-------------------+
  324. | 2 | 2980 |
  325. +-------+-------------------+
  326. | 3 | 3060 |
  327. +-------+-------------------+
  328. | 4 | 520 |
  329. +-------+-------------------+
  330. | 5 | 720 |
  331. +-------+-------------------+
  332. The times for the big CPUs are less than the little CPUs due to greater CPU
  333. performance.
  334. We suspect the time for lead CPU 4 is shorter than CPU 5 due to subtle cache
  335. effects, given that these measurements are at the nano-second level.
  336. --------------
  337. *Copyright (c) 2019-2023, Arm Limited and Contributors. All rights reserved.*
  338. .. _Juno R1 platform: https://developer.arm.com/documentation/100122/latest/
  339. .. _TF master as of 31/01/2017: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/?id=c38b36d
  340. .. _v2.9-rc0: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/?h=v2.9-rc0