blob: 621c8bf81041b7b04c3f9ad7f296438a1af27160 [file] [log] [blame]
Joel Hutton9e605632019-02-25 15:18:56 +00001This document summarises the findings of performance measurements of key
2operations in the ARM Trusted Firmware (TF) Power State Coordination Interface
3(PSCI) implementation, using the in-built Performance Measurement Framework
4(PMF) and runtime instrumentation timestamps.
5
6Method
7------
8
9We used the `Juno R1 platform`_ for these tests, which has 4 x Cortex-A53 and 2
10x Cortex-A57 clusters running at the following frequencies:
11
12+-----------------+--------------------+
13| Domain | Frequency (MHz) |
14+=================+====================+
15| Cortex-A57 | 900 (nominal) |
16+-----------------+--------------------+
17| Cortex-A53 | 650 (underdrive) |
18+-----------------+--------------------+
19| AXI subsystem | 533 |
20+-----------------+--------------------+
21
22Juno supports CPU, cluster and system power down states, corresponding to power
23levels 0, 1 and 2 respectively. It does not support any retention states.
24
25We used the upstream `TF master as of 31/01/2017`_, building the platform using
26the ``ENABLE_RUNTIME_INSTRUMENTATION`` option:
27
28::
29
30 make PLAT=juno ENABLE_RUNTIME_INSTRUMENTATION=1 \
31 SCP_BL2=<path/to/scp-fw.bin> \
32 BL33=<path/to/test-fw.bin> \
33 all fip
34
35When using the debug build of TF, there was no noticeable difference in the
36results.
37
38The tests are based on an ARM-internal test framework. The release build of this
39framework was used because the results in the debug build became skewed; the
40console output prevented some of the tests from executing in parallel.
41
42The tests consist of both parallel and sequential tests, which are broadly
43described as follows:
44
45- **Parallel Tests** This type of test powers on all the non-lead CPUs and
46 brings them and the lead CPU to a common synchronization point. The lead CPU
47 then initiates the test on all CPUs in parallel.
48
49- **Sequential Tests** This type of test powers on each non-lead CPU in
50 sequence. The lead CPU initiates the test on a non-lead CPU then waits for the
51 test to complete before proceeding to the next non-lead CPU. The lead CPU then
52 executes the test on itself.
53
54In the results below, CPUs 0-3 refer to CPUs in the little cluster (A53) and
55CPUs 4-5 refer to CPUs in the big cluster (A57). In all cases CPU 4 is the lead
56CPU.
57
58``PSCI_ENTRY`` refers to the time taken from entering the TF PSCI implementation
59to the point the hardware enters the low power state (WFI). Referring to the TF
60runtime instrumentation points, this corresponds to:
61``(RT_INSTR_ENTER_HW_LOW_PWR - RT_INSTR_ENTER_PSCI)``.
62
63``PSCI_EXIT`` refers to the time taken from the point the hardware exits the low
64power state to exiting the TF PSCI implementation. This corresponds to:
65``(RT_INSTR_EXIT_PSCI - RT_INSTR_EXIT_HW_LOW_PWR)``.
66
67``CFLUSH_OVERHEAD`` refers to the part of ``PSCI_ENTRY`` taken to flush the
68caches. This corresponds to: ``(RT_INSTR_EXIT_CFLUSH - RT_INSTR_ENTER_CFLUSH)``.
69
70Note there is very little variance observed in the values given (~1us), although
71the values for each CPU are sometimes interchanged, depending on the order in
72which locks are acquired. Also, there is very little variance observed between
73executing the tests sequentially in a single boot or rebooting between tests.
74
75Given that runtime instrumentation using PMF is invasive, there is a small
76(unquantified) overhead on the results. PMF uses the generic counter for
77timestamps, which runs at 50MHz on Juno.
78
79Results and Commentary
80----------------------
81
82``CPU_SUSPEND`` to deepest power level on all CPUs in parallel
83~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84
85+-------+---------------------+--------------------+--------------------------+
86| CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
87+=======+=====================+====================+==========================+
88| 0 | 27 | 20 | 5 |
89+-------+---------------------+--------------------+--------------------------+
90| 1 | 114 | 86 | 5 |
91+-------+---------------------+--------------------+--------------------------+
92| 2 | 202 | 58 | 5 |
93+-------+---------------------+--------------------+--------------------------+
94| 3 | 375 | 29 | 94 |
95+-------+---------------------+--------------------+--------------------------+
96| 4 | 20 | 22 | 6 |
97+-------+---------------------+--------------------+--------------------------+
98| 5 | 290 | 18 | 206 |
99+-------+---------------------+--------------------+--------------------------+
100
101A large variance in ``PSCI_ENTRY`` and ``PSCI_EXIT`` times across CPUs is
102observed due to TF PSCI lock contention. In the worst case, CPU 3 has to wait
103for the 3 other CPUs in the cluster (0-2) to complete ``PSCI_ENTRY`` and release
104the lock before proceeding.
105
106The ``CFLUSH_OVERHEAD`` times for CPUs 3 and 5 are higher because they are the
107last CPUs in their respective clusters to power down, therefore both the L1 and
108L2 caches are flushed.
109
110The ``CFLUSH_OVERHEAD`` time for CPU 5 is a lot larger than that for CPU 3
111because the L2 cache size for the big cluster is lot larger (2MB) compared to
112the little cluster (1MB).
113
114``CPU_SUSPEND`` to power level 0 on all CPUs in parallel
115~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116
117+-------+---------------------+--------------------+--------------------------+
118| CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
119+=======+=====================+====================+==========================+
120| 0 | 116 | 14 | 8 |
121+-------+---------------------+--------------------+--------------------------+
122| 1 | 204 | 14 | 8 |
123+-------+---------------------+--------------------+--------------------------+
124| 2 | 287 | 13 | 8 |
125+-------+---------------------+--------------------+--------------------------+
126| 3 | 376 | 13 | 9 |
127+-------+---------------------+--------------------+--------------------------+
128| 4 | 29 | 15 | 7 |
129+-------+---------------------+--------------------+--------------------------+
130| 5 | 21 | 15 | 8 |
131+-------+---------------------+--------------------+--------------------------+
132
133There is no lock contention in TF generic code at power level 0 but the large
134variance in ``PSCI_ENTRY`` times across CPUs is due to lock contention in Juno
135platform code. The platform lock is used to mediate access to a single SCP
136communication channel. This is compounded by the SCP firmware waiting for each
137AP CPU to enter WFI before making the channel available to other CPUs, which
138effectively serializes the SCP power down commands from all CPUs.
139
140On platforms with a more efficient CPU power down mechanism, it should be
141possible to make the ``PSCI_ENTRY`` times smaller and consistent.
142
143The ``PSCI_EXIT`` times are consistent across all CPUs because TF does not
144require locks at power level 0.
145
146The ``CFLUSH_OVERHEAD`` times for all CPUs are small and consistent since only
147the cache associated with power level 0 is flushed (L1).
148
149``CPU_SUSPEND`` to deepest power level on all CPUs in sequence
150~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
151
152+-------+---------------------+--------------------+--------------------------+
153| CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
154+=======+=====================+====================+==========================+
155| 0 | 114 | 20 | 94 |
156+-------+---------------------+--------------------+--------------------------+
157| 1 | 114 | 20 | 94 |
158+-------+---------------------+--------------------+--------------------------+
159| 2 | 114 | 20 | 94 |
160+-------+---------------------+--------------------+--------------------------+
161| 3 | 114 | 20 | 94 |
162+-------+---------------------+--------------------+--------------------------+
163| 4 | 195 | 22 | 180 |
164+-------+---------------------+--------------------+--------------------------+
165| 5 | 21 | 17 | 6 |
166+-------+---------------------+--------------------+--------------------------+
167
168The ``CLUSH_OVERHEAD`` times for lead CPU 4 and all CPUs in the non-lead cluster
169are large because all other CPUs in the cluster are powered down during the
170test. The ``CPU_SUSPEND`` call powers down to the cluster level, requiring a
171flush of both L1 and L2 caches.
172
173The ``CFLUSH_OVERHEAD`` time for CPU 4 is a lot larger than those for the little
174CPUs because the L2 cache size for the big cluster is lot larger (2MB) compared
175to the little cluster (1MB).
176
177The ``PSCI_ENTRY`` and ``CFLUSH_OVERHEAD`` times for CPU 5 are low because lead
178CPU 4 continues to run while CPU 5 is suspended. Hence CPU 5 only powers down to
179level 0, which only requires L1 cache flush.
180
181``CPU_SUSPEND`` to power level 0 on all CPUs in sequence
182~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183
184+-------+---------------------+--------------------+--------------------------+
185| CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
186+=======+=====================+====================+==========================+
187| 0 | 22 | 14 | 5 |
188+-------+---------------------+--------------------+--------------------------+
189| 1 | 22 | 14 | 5 |
190+-------+---------------------+--------------------+--------------------------+
191| 2 | 21 | 14 | 5 |
192+-------+---------------------+--------------------+--------------------------+
193| 3 | 22 | 14 | 5 |
194+-------+---------------------+--------------------+--------------------------+
195| 4 | 17 | 14 | 6 |
196+-------+---------------------+--------------------+--------------------------+
197| 5 | 18 | 15 | 6 |
198+-------+---------------------+--------------------+--------------------------+
199
200Here the times are small and consistent since there is no contention and it is
201only necessary to flush the cache to power level 0 (L1). This is the best case
202scenario.
203
204The ``PSCI_ENTRY`` times for CPUs in the big cluster are slightly smaller than
205for the CPUs in little cluster due to greater CPU performance.
206
207The ``PSCI_EXIT`` times are generally lower than in the last test because the
208cluster remains powered on throughout the test and there is less code to execute
209on power on (for example, no need to enter CCI coherency)
210
211``CPU_OFF`` on all non-lead CPUs in sequence then ``CPU_SUSPEND`` on lead CPU to deepest power level
212~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
213
214The test sequence here is as follows:
215
2161. Call ``CPU_ON`` and ``CPU_OFF`` on each non-lead CPU in sequence.
217
2182. Program wake up timer and suspend the lead CPU to the deepest power level.
219
2203. Call ``CPU_ON`` on non-lead CPU to get the timestamps from each CPU.
221
222+-------+---------------------+--------------------+--------------------------+
223| CPU | ``PSCI_ENTRY`` (us) | ``PSCI_EXIT`` (us) | ``CFLUSH_OVERHEAD`` (us) |
224+=======+=====================+====================+==========================+
225| 0 | 110 | 28 | 93 |
226+-------+---------------------+--------------------+--------------------------+
227| 1 | 110 | 28 | 93 |
228+-------+---------------------+--------------------+--------------------------+
229| 2 | 110 | 28 | 93 |
230+-------+---------------------+--------------------+--------------------------+
231| 3 | 111 | 28 | 93 |
232+-------+---------------------+--------------------+--------------------------+
233| 4 | 195 | 22 | 181 |
234+-------+---------------------+--------------------+--------------------------+
235| 5 | 20 | 23 | 6 |
236+-------+---------------------+--------------------+--------------------------+
237
238The ``CFLUSH_OVERHEAD`` times for all little CPUs are large because all other
239CPUs in that cluster are powerered down during the test. The ``CPU_OFF`` call
240powers down to the cluster level, requiring a flush of both L1 and L2 caches.
241
242The ``PSCI_ENTRY`` and ``CFLUSH_OVERHEAD`` times for CPU 5 are small because
243lead CPU 4 is running and CPU 5 only powers down to level 0, which only requires
244an L1 cache flush.
245
246The ``CFLUSH_OVERHEAD`` time for CPU 4 is a lot larger than those for the little
247CPUs because the L2 cache size for the big cluster is lot larger (2MB) compared
248to the little cluster (1MB).
249
250The ``PSCI_EXIT`` times for CPUs in the big cluster are slightly smaller than
251for CPUs in the little cluster due to greater CPU performance. These times
252generally are greater than the ``PSCI_EXIT`` times in the ``CPU_SUSPEND`` tests
253because there is more code to execute in the "on finisher" compared to the
254"suspend finisher" (for example, GIC redistributor register programming).
255
256``PSCI_VERSION`` on all CPUs in parallel
257~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
258
259Since very little code is associated with ``PSCI_VERSION``, this test
260approximates the round trip latency for handling a fast SMC at EL3 in TF.
261
262+-------+-------------------+
263| CPU | TOTAL TIME (ns) |
264+=======+===================+
265| 0 | 3020 |
266+-------+-------------------+
267| 1 | 2940 |
268+-------+-------------------+
269| 2 | 2980 |
270+-------+-------------------+
271| 3 | 3060 |
272+-------+-------------------+
273| 4 | 520 |
274+-------+-------------------+
275| 5 | 720 |
276+-------+-------------------+
277
278The times for the big CPUs are less than the little CPUs due to greater CPU
279performance.
280
281We suspect the time for lead CPU 4 is shorter than CPU 5 due to subtle cache
282effects, given that these measurements are at the nano-second level.
283
284.. _Juno R1 platform: https://www.arm.com/files/pdf/Juno_r1_ARM_Dev_datasheet.pdf
Joel Hutton0f79fb12019-02-26 16:23:54 +0000285.. _TF master as of 31/01/2017: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/tree/?id=c38b36d