[rtems commit] libdl/rtl-obj.c: synchronize cache should not depend on CPU_CACHE_LINE_BYTES.

Pavel Pisa ppisa at rtems.org
Tue Oct 4 21:14:27 UTC 2016


Module:    rtems
Branch:    4.11
Commit:    9d423d9c96e33d9bf50810449352e708283f4971
Changeset: http://git.rtems.org/rtems/commit/?id=9d423d9c96e33d9bf50810449352e708283f4971

Author:    Pavel Pisa <pisa at cmp.felk.cvut.cz>
Date:      Mon Oct  3 11:01:39 2016 +0200

libdl/rtl-obj.c: synchronize cache should not depend on CPU_CACHE_LINE_BYTES.

The CPU_CACHE_LINE_BYTES has been introduced after 4.11 branch
fork and is not available for all architectures on RTEMS 4.11.

Use of rtems_cache_get_maximal_line_size() is more descriptive
choice. The min/max data/instruction cache line size is not critical
there, value is used for optimization only to use single operation
for decently following sections.

---

 cpukit/libdl/rtl-obj.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cpukit/libdl/rtl-obj.c b/cpukit/libdl/rtl-obj.c
index f61d4e5..bdcebce 100644
--- a/cpukit/libdl/rtl-obj.c
+++ b/cpukit/libdl/rtl-obj.c
@@ -566,6 +566,7 @@ typedef struct
   uint32_t mask;
   void     *start_va;
   void     *end_va;
+  size_t   cache_line_size;
 } rtems_rtl_obj_sect_sync_ctx_t;
 
 static bool
@@ -582,10 +583,10 @@ rtems_rtl_obj_sect_sync_handler (rtems_chain_node* node, void* data)
   if (sync_ctx->end_va == sync_ctx->start_va) {
     sync_ctx->start_va = sect->base;
   } else {
-    old_end = (uintptr_t)sync_ctx->end_va & ~(CPU_CACHE_LINE_BYTES - 1);
-    new_start = (uintptr_t)sect->base & ~(CPU_CACHE_LINE_BYTES - 1);
+    old_end = (uintptr_t)sync_ctx->end_va & ~(sync_ctx->cache_line_size - 1);
+    new_start = (uintptr_t)sect->base & ~(sync_ctx->cache_line_size - 1);
     if ( (sect->base <  sync_ctx->start_va) ||
-         (new_start - old_end > CPU_CACHE_LINE_BYTES) ) {
+         (new_start - old_end > sync_ctx->cache_line_size) ) {
       rtems_cache_instruction_sync_after_code_change(sync_ctx->start_va,
                              sync_ctx->end_va - sync_ctx->start_va + 1);
       sync_ctx->start_va = sect->base;
@@ -605,6 +606,8 @@ rtems_rtl_obj_synchronize_cache (rtems_rtl_obj_t*    obj)
   if (rtems_cache_get_instruction_line_size() == 0)
     return;
 
+  sync_ctx.cache_line_size = rtems_cache_get_maximal_line_size();
+
   sync_ctx.mask = RTEMS_RTL_OBJ_SECT_TEXT | RTEMS_RTL_OBJ_SECT_CONST |
                   RTEMS_RTL_OBJ_SECT_DATA | RTEMS_RTL_OBJ_SECT_BSS |
                   RTEMS_RTL_OBJ_SECT_EXEC;




More information about the vc mailing list