[Cbe-oss-dev] [PATCH 14/22]MARS/task: optimize elf loading

Yuji Mano yuji.mano at am.sony.com
Fri Mar 20 07:54:31 EST 2009


This patch updates the task module so that it avoids reloading the text segment
of an ELF if it is already cached in MPU storage.

The task module writes the EA of the currently loaded ELF between the workload
module stack and task base address.

Upon the task module's next execution, if the task module was cached (meaning no
other workload module was loaded in to overwrite the mpu storage workload module
memory area) it checks the previously written ELF ea to see if it is the same ea
as the current ELF that needs to be loaded. If the workload is cached, the check
is not necessary since not only is the ELF text segment cached but the whole
MPU storage state is cached.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
 task/src/mpu/module/Makefile.am   |    2 +-
 task/src/mpu/module/task_module.c |   24 ++++++++++++++++++++----
 2 files changed, 21 insertions(+), 5 deletions(-)

--- a/task/src/mpu/module/Makefile.am
+++ b/task/src/mpu/module/Makefile.am
@@ -48,7 +48,7 @@ if DEBUG
 else
  extra_cppflags += "-DNDEBUG"
  # release kernel is 12K
- extra_ldflags += -Wl,--defsym=__stack=0x3ff0 -Wl,--section-start,.init=0x3000
+ extra_ldflags += -Wl,--defsym=__stack=0x3fe0 -Wl,--section-start,.init=0x3000
  CFLAGS += -Os
 endif
 
--- a/task/src/mpu/module/task_module.c
+++ b/task/src/mpu/module/task_module.c
@@ -284,19 +284,34 @@ static void task_run(void)
 
 void __module_main(void)
 {
-	int task_cached;
+	int task_cached = 0;
+	int text_cached = 0;
+	uint64_t *cached_text_ea = (uint64_t *)(MARS_TASK_BASE_ADDR - 16);
 
 	/* get task context */
 	task = get_task();
 
-	/* check if task context is cached in mpu storage */
-	task_cached = mars_module_workload_query(mars_module_get_workload_id(),
+	/* check if this workload module was in the cache */
+	if (mars_module_workload_query(mars_module_get_workload_id(),
+				       MARS_WORKLOAD_QUERY_IS_MODULE_CACHED)) {
+		/* check if task context is cached in mpu storage */
+		task_cached = mars_module_workload_query(
+					mars_module_get_workload_id(),
 					MARS_WORKLOAD_QUERY_IS_CONTEXT_CACHED);
 
+		/* check if text is cached in mpu storage */
+		text_cached = task_cached || (*cached_text_ea == task->text_ea);
+	}
+
 	/* only reload the readonly text segment if different from cached */
-	if (!task_cached)
+	if (!text_cached) {
+		/* set info of current cached text */
+		*cached_text_ea = task->text_ea;
+
+		/* dma text segment from host storage to mpu storage */
 		dma((void *)MARS_TASK_BASE_ADDR,
 		    task->text_ea, task->text_size, 0);
+	}
 
 	/* if stack pointer is uninitialized run fresh, otherwise resume */
 	if (!task->stack)






More information about the cbe-oss-dev mailing list