Add two timestamps to measure PSCI cache flush overhead
authordp-arm <dimitris.papastamos@arm.com>
Tue, 15 Nov 2016 13:25:30 +0000 (13:25 +0000)
committerdp-arm <dimitris.papastamos@arm.com>
Wed, 14 Dec 2016 09:53:14 +0000 (09:53 +0000)
Testing showed that the time spent in a cluster power down
operation is dominated by cache flushes.  Add two more timestamps
in runtime instrumentation to keep track of the time spent
flushing the L1/L2 caches.

Change-Id: I4c5a04e7663543225a85d3c6b271d7b706deffc4
Signed-off-by: dp-arm <dimitris.papastamos@arm.com>
include/lib/runtime_instr.h
lib/psci/psci_off.c
lib/psci/psci_suspend.c

index d4090027ac15970a1dd705698e436706d6d42bb7..4d05ba4b4271e9a6fc4d492425a113c42d13aec5 100644 (file)
 #ifndef __RUNTIME_INSTR_H__
 #define __RUNTIME_INSTR_H__
 
-#define RT_INSTR_TOTAL_IDS             4
 #define RT_INSTR_ENTER_PSCI            0
 #define RT_INSTR_EXIT_PSCI             1
 #define RT_INSTR_ENTER_HW_LOW_PWR      2
 #define RT_INSTR_EXIT_HW_LOW_PWR       3
+#define RT_INSTR_ENTER_CFLUSH          4
+#define RT_INSTR_EXIT_CFLUSH           5
+#define RT_INSTR_TOTAL_IDS             6
 
 #ifndef __ASSEMBLY__
 PMF_DECLARE_CAPTURE_TIMESTAMP(rt_instr_svc)
index 1cc6ede3d983a6b1a35258aa0784ba316fa85df5..897bf319af12eba21a3b2653bbaddd38c8d9d02b 100644 (file)
@@ -107,12 +107,29 @@ int psci_do_cpu_off(unsigned int end_pwrlvl)
        psci_stats_update_pwr_down(end_pwrlvl, &state_info);
 #endif
 
+#if ENABLE_RUNTIME_INSTRUMENTATION
+
+       /*
+        * Flush cache line so that even if CPU power down happens
+        * the timestamp update is reflected in memory.
+        */
+       PMF_CAPTURE_TIMESTAMP(rt_instr_svc,
+               RT_INSTR_ENTER_CFLUSH,
+               PMF_CACHE_MAINT);
+#endif
+
        /*
         * Arch. management. Perform the necessary steps to flush all
         * cpu caches.
         */
        psci_do_pwrdown_cache_maintenance(psci_find_max_off_lvl(&state_info));
 
+#if ENABLE_RUNTIME_INSTRUMENTATION
+       PMF_CAPTURE_TIMESTAMP(rt_instr_svc,
+               RT_INSTR_EXIT_CFLUSH,
+               PMF_NO_CACHE_MAINT);
+#endif
+
        /*
         * Plat. management: Perform platform specific actions to turn this
         * cpu off e.g. exit cpu coherency, program the power controller etc.
index 10d2481da4b14e5af72916737aa575d4ef5c5197..dc2ab7748b54f74f3e2b6fdc03c5989529d4d0dd 100644 (file)
@@ -109,6 +109,17 @@ static void psci_suspend_to_pwrdown_start(unsigned int end_pwrlvl,
         */
        cm_init_my_context(ep);
 
+#if ENABLE_RUNTIME_INSTRUMENTATION
+
+       /*
+        * Flush cache line so that even if CPU power down happens
+        * the timestamp update is reflected in memory.
+        */
+       PMF_CAPTURE_TIMESTAMP(rt_instr_svc,
+               RT_INSTR_ENTER_CFLUSH,
+               PMF_CACHE_MAINT);
+#endif
+
        /*
         * Arch. management. Perform the necessary steps to flush all
         * cpu caches. Currently we assume that the power level correspond
@@ -117,6 +128,12 @@ static void psci_suspend_to_pwrdown_start(unsigned int end_pwrlvl,
         * and the cpu-ops power down to perform from the platform.
         */
        psci_do_pwrdown_cache_maintenance(max_off_lvl);
+
+#if ENABLE_RUNTIME_INSTRUMENTATION
+       PMF_CAPTURE_TIMESTAMP(rt_instr_svc,
+               RT_INSTR_EXIT_CFLUSH,
+               PMF_NO_CACHE_MAINT);
+#endif
 }
 
 /*******************************************************************************