[rtems commit] score: Do not inline _Thread_Dispatch_enable()

Sebastian Huber sebh at rtems.org
Fri Aug 24 07:08:03 UTC 2018


Module:    rtems
Branch:    master
Commit:    ba0e9631a0e0a74a9c3d823d3d1bb60900da4891
Changeset: http://git.rtems.org/rtems/commit/?id=ba0e9631a0e0a74a9c3d823d3d1bb60900da4891

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Aug 10 07:34:03 2018 +0200

score: Do not inline _Thread_Dispatch_enable()

This function is slighly too complex for inlining with two if
statements.  The caller already needs a stack frame due to the potential
call to _Thread_Do_dispatch().  In _Thread_Dispatch_enable() the call to
_Thread_Do_dispatch() can be optimized to a tail call.

A text size comparision

  (text size after patch - text size before patch)
   / text size before patch

on sparc/erc32 with SMP enabled showed these results:

  Minimum -0.000697892 (fsdosfsname01.exe)
  Median -0.00745021 (psxtimes01.exe)
  Maximum -0.0233032 (spscheduler01.exe)

A text size comparision

  text size after patch - text size before patch

on sparc/erc32 with SMP enabled showed these results:

  Minimum -3312 (ada_sp09.exe)
  Median -1024 (tm15.exe)
  Maximum -592 (spglobalcon01.exe)

---

 cpukit/include/rtems/score/threaddispatch.h | 29 ++---------------------------
 cpukit/score/src/threaddispatch.c           | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/cpukit/include/rtems/score/threaddispatch.h b/cpukit/include/rtems/score/threaddispatch.h
index 69696f4..f5d5c48 100644
--- a/cpukit/include/rtems/score/threaddispatch.h
+++ b/cpukit/include/rtems/score/threaddispatch.h
@@ -205,36 +205,11 @@ RTEMS_INLINE_ROUTINE Per_CPU_Control *_Thread_Dispatch_disable( void )
 /**
  * @brief Enables thread dispatching.
  *
- * May perfrom a thread dispatch if necessary as a side-effect.
+ * May perform a thread dispatch if necessary as a side-effect.
  *
  * @param[in] cpu_self The current processor.
  */
-RTEMS_INLINE_ROUTINE void _Thread_Dispatch_enable( Per_CPU_Control *cpu_self )
-{
-  uint32_t disable_level = cpu_self->thread_dispatch_disable_level;
-
-  if ( disable_level == 1 ) {
-    ISR_Level level;
-
-    _ISR_Local_disable( level );
-
-    if (
-      cpu_self->dispatch_necessary
-#if defined(RTEMS_SCORE_ROBUST_THREAD_DISPATCH)
-        || !_ISR_Is_enabled( level )
-#endif
-    ) {
-      _Thread_Do_dispatch( cpu_self, level );
-    } else {
-      cpu_self->thread_dispatch_disable_level = 0;
-      _Profiling_Thread_dispatch_enable( cpu_self, 0 );
-      _ISR_Local_enable( level );
-    }
-  } else {
-    _Assert( disable_level > 0 );
-    cpu_self->thread_dispatch_disable_level = disable_level - 1;
-  }
-}
+void _Thread_Dispatch_enable( Per_CPU_Control *cpu_self );
 
 /**
  * @brief Unnests thread dispatching.
diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
index 9cd1e29..d6207bc 100644
--- a/cpukit/score/src/threaddispatch.c
+++ b/cpukit/score/src/threaddispatch.c
@@ -267,3 +267,30 @@ void _Thread_Dispatch_direct( Per_CPU_Control *cpu_self )
   _ISR_Local_disable( level );
   _Thread_Do_dispatch( cpu_self, level );
 }
+
+void _Thread_Dispatch_enable( Per_CPU_Control *cpu_self )
+{
+  uint32_t disable_level = cpu_self->thread_dispatch_disable_level;
+
+  if ( disable_level == 1 ) {
+    ISR_Level level;
+
+    _ISR_Local_disable( level );
+
+    if (
+      cpu_self->dispatch_necessary
+#if defined(RTEMS_SCORE_ROBUST_THREAD_DISPATCH)
+        || !_ISR_Is_enabled( level )
+#endif
+    ) {
+      _Thread_Do_dispatch( cpu_self, level );
+    } else {
+      cpu_self->thread_dispatch_disable_level = 0;
+      _Profiling_Thread_dispatch_enable( cpu_self, 0 );
+      _ISR_Local_enable( level );
+    }
+  } else {
+    _Assert( disable_level > 0 );
+    cpu_self->thread_dispatch_disable_level = disable_level - 1;
+  }
+}




More information about the vc mailing list