[rtems commit] score: Default to non-inline SMP lock ops

Sebastian Huber sebh at rtems.org
Fri Nov 4 10:08:33 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Nov  3 17:00:28 2016 +0100

score: Default to non-inline SMP lock ops

Use non-inline SMP lock acquire and release operations by default.
Provide inline variants for the hot spots, e.g. mutex acquire/release.

---

 cpukit/score/include/rtems/score/smplock.h | 118 ++++++++++++++++-------------
 cpukit/score/src/smplock.c                 |  43 ++---------
 2 files changed, 71 insertions(+), 90 deletions(-)

diff --git a/cpukit/score/include/rtems/score/smplock.h b/cpukit/score/include/rtems/score/smplock.h
index eddbb32..c2214e6 100644
--- a/cpukit/score/include/rtems/score/smplock.h
+++ b/cpukit/score/include/rtems/score/smplock.h
@@ -28,8 +28,9 @@
 #include <rtems/score/smplockticket.h>
 #include <rtems/score/isrlevel.h>
 
-#if defined(RTEMS_PROFILING) || defined(RTEMS_DEBUG)
-#define RTEMS_SMP_LOCK_DO_NOT_INLINE
+#if defined(RTEMS_DEBUG)
+#include <rtems/score/assert.h>
+#include <rtems/score/smp.h>
 #endif
 
 #ifdef __cplusplus
@@ -116,6 +117,22 @@ typedef struct {
   #define SMP_LOCK_INITIALIZER( name ) { SMP_TICKET_LOCK_INITIALIZER }
 #endif
 
+static inline void _SMP_lock_Initialize_inline(
+  SMP_lock_Control *lock,
+  const char       *name
+)
+{
+  _SMP_ticket_lock_Initialize( &lock->Ticket_lock );
+#if defined(RTEMS_DEBUG)
+  lock->owner = SMP_LOCK_NO_OWNER;
+#endif
+#if defined(RTEMS_PROFILING)
+  _SMP_lock_Stats_initialize( &lock->Stats, name );
+#else
+  (void) name;
+#endif
+}
+
 /**
  * @brief Initializes an SMP lock.
  *
@@ -128,26 +145,22 @@ typedef struct {
 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
 void _SMP_lock_Initialize(
   SMP_lock_Control *lock,
-  const char *name
+  const char *      name
 );
-
-static inline void _SMP_lock_Initialize_body(
 #else
 static inline void _SMP_lock_Initialize(
-#endif
   SMP_lock_Control *lock,
-  const char *name
+  const char       *name
 )
 {
-  _SMP_ticket_lock_Initialize( &lock->Ticket_lock );
-#if defined(RTEMS_DEBUG)
-  lock->owner = SMP_LOCK_NO_OWNER;
-#endif
-#if defined(RTEMS_PROFILING)
-  _SMP_lock_Stats_initialize( &lock->Stats, name );
-#else
-  (void) name;
+  _SMP_lock_Initialize_inline( lock, name );
+}
 #endif
+
+static inline void _SMP_lock_Destroy_inline( SMP_lock_Control *lock )
+{
+  _SMP_ticket_lock_Destroy( &lock->Ticket_lock );
+  _SMP_lock_Stats_destroy( &lock->Stats );
 }
 
 /**
@@ -159,14 +172,31 @@ static inline void _SMP_lock_Initialize(
  */
 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
 void _SMP_lock_Destroy( SMP_lock_Control *lock );
-
-static inline void _SMP_lock_Destroy_body( SMP_lock_Control *lock )
 #else
 static inline void _SMP_lock_Destroy( SMP_lock_Control *lock )
+{
+  _SMP_lock_Destroy_inline( lock );
+}
 #endif
+
+static inline void _SMP_lock_Acquire_inline(
+  SMP_lock_Control *lock,
+  SMP_lock_Context *context
+)
 {
-  _SMP_ticket_lock_Destroy( &lock->Ticket_lock );
-  _SMP_lock_Stats_destroy( &lock->Stats );
+#if defined(RTEMS_DEBUG)
+  context->lock_used_for_acquire = lock;
+#else
+  (void) context;
+#endif
+  _SMP_ticket_lock_Acquire(
+    &lock->Ticket_lock,
+    &lock->Stats,
+    &context->Stats_context
+  );
+#if defined(RTEMS_DEBUG)
+  lock->owner = _SMP_Get_current_processor();
+#endif
 }
 
 /**
@@ -180,24 +210,26 @@ static inline void _SMP_lock_Destroy( SMP_lock_Control *lock )
  * @param[in] context The local SMP lock context for an acquire and release
  * pair.
  */
-#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
 void _SMP_lock_Acquire(
   SMP_lock_Control *lock,
   SMP_lock_Context *context
 );
 
-static inline void _SMP_lock_Acquire_body(
-#else
-static inline void _SMP_lock_Acquire(
-#endif
+static inline void _SMP_lock_Release_inline(
   SMP_lock_Control *lock,
   SMP_lock_Context *context
 )
 {
+#if defined(RTEMS_DEBUG)
+  _Assert( context->lock_used_for_acquire == lock );
+  context->lock_used_for_acquire = NULL;
+  _Assert( lock->owner == _SMP_Get_current_processor() );
+  lock->owner = SMP_LOCK_NO_OWNER;
+#else
   (void) context;
-  _SMP_ticket_lock_Acquire(
+#endif
+  _SMP_ticket_lock_Release(
     &lock->Ticket_lock,
-    &lock->Stats,
     &context->Stats_context
   );
 }
@@ -209,25 +241,18 @@ static inline void _SMP_lock_Acquire(
  * @param[in] context The local SMP lock context for an acquire and release
  * pair.
  */
-#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
 void _SMP_lock_Release(
   SMP_lock_Control *lock,
   SMP_lock_Context *context
 );
 
-static inline void _SMP_lock_Release_body(
-#else
-static inline void _SMP_lock_Release(
-#endif
+static inline void _SMP_lock_ISR_disable_and_acquire_inline(
   SMP_lock_Control *lock,
   SMP_lock_Context *context
 )
 {
-  (void) context;
-  _SMP_ticket_lock_Release(
-    &lock->Ticket_lock,
-    &context->Stats_context
-  );
+  _ISR_Local_disable( context->isr_level );
+  _SMP_lock_Acquire_inline( lock, context );
 }
 
 /**
@@ -237,22 +262,18 @@ static inline void _SMP_lock_Release(
  * @param[in] context The local SMP lock context for an acquire and release
  * pair.
  */
-#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
 void _SMP_lock_ISR_disable_and_acquire(
   SMP_lock_Control *lock,
   SMP_lock_Context *context
 );
 
-static inline void _SMP_lock_ISR_disable_and_acquire_body(
-#else
-static inline void _SMP_lock_ISR_disable_and_acquire(
-#endif
+static inline void _SMP_lock_Release_and_ISR_enable_inline(
   SMP_lock_Control *lock,
   SMP_lock_Context *context
 )
 {
-  _ISR_Local_disable( context->isr_level );
-  _SMP_lock_Acquire( lock, context );
+  _SMP_lock_Release_inline( lock, context );
+  _ISR_Local_enable( context->isr_level );
 }
 
 /**
@@ -262,21 +283,10 @@ static inline void _SMP_lock_ISR_disable_and_acquire(
  * @param[in] context The local SMP lock context for an acquire and release
  * pair.
  */
-#if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
 void _SMP_lock_Release_and_ISR_enable(
   SMP_lock_Control *lock,
   SMP_lock_Context *context
 );
-#else
-static inline void _SMP_lock_Release_and_ISR_enable(
-  SMP_lock_Control *lock,
-  SMP_lock_Context *context
-)
-{
-  _SMP_lock_Release( lock, context );
-  _ISR_Local_enable( context->isr_level );
-}
-#endif
 
 #if defined(RTEMS_DEBUG)
 /**
diff --git a/cpukit/score/src/smplock.c b/cpukit/score/src/smplock.c
index f6cc8b6..73fa67d 100644
--- a/cpukit/score/src/smplock.c
+++ b/cpukit/score/src/smplock.c
@@ -17,36 +17,28 @@
 #endif
 
 #include <rtems/score/smplock.h>
-#include <rtems/score/assert.h>
-#include <rtems/score/smp.h>
 
 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
-
 void _SMP_lock_Initialize(
   SMP_lock_Control *lock,
   const char *name
 )
 {
-  _SMP_lock_Initialize_body( lock, name );
+  _SMP_lock_Initialize_inline( lock, name );
 }
 
 void _SMP_lock_Destroy( SMP_lock_Control *lock )
 {
-  _SMP_lock_Destroy_body( lock );
+  _SMP_lock_Destroy_inline( lock );
 }
+#endif
 
 void _SMP_lock_Acquire(
   SMP_lock_Control *lock,
   SMP_lock_Context *context
 )
 {
-#if defined(RTEMS_DEBUG)
-  context->lock_used_for_acquire = lock;
-#endif
-  _SMP_lock_Acquire_body( lock, context );
-#if defined(RTEMS_DEBUG)
-  lock->owner = _SMP_Get_current_processor();
-#endif
+  _SMP_lock_Acquire_inline( lock, context );
 }
 
 void _SMP_lock_Release(
@@ -54,13 +46,7 @@ void _SMP_lock_Release(
   SMP_lock_Context *context
 )
 {
-#if defined(RTEMS_DEBUG)
-  _Assert( context->lock_used_for_acquire == lock );
-  context->lock_used_for_acquire = NULL;
-  _Assert( lock->owner == _SMP_Get_current_processor() );
-  lock->owner = SMP_LOCK_NO_OWNER;
-#endif
-  _SMP_lock_Release_body( lock, context );
+  _SMP_lock_Release_inline( lock, context );
 }
 
 void _SMP_lock_ISR_disable_and_acquire(
@@ -68,13 +54,7 @@ void _SMP_lock_ISR_disable_and_acquire(
   SMP_lock_Context *context
 )
 {
-#if defined(RTEMS_DEBUG)
-  context->lock_used_for_acquire = lock;
-#endif
-  _SMP_lock_ISR_disable_and_acquire_body( lock, context );
-#if defined(RTEMS_DEBUG)
-  lock->owner = _SMP_Get_current_processor();
-#endif
+  _SMP_lock_ISR_disable_and_acquire_inline( lock, context );
 }
 
 void _SMP_lock_Release_and_ISR_enable(
@@ -82,14 +62,7 @@ void _SMP_lock_Release_and_ISR_enable(
   SMP_lock_Context *context
 )
 {
-#if defined(RTEMS_DEBUG)
-  _Assert( context->lock_used_for_acquire == lock );
-  context->lock_used_for_acquire = NULL;
-  _Assert( lock->owner == _SMP_Get_current_processor() );
-  lock->owner = SMP_LOCK_NO_OWNER;
-#endif
-  _SMP_lock_Release_body( lock, context );
-  _ISR_Local_enable( context->isr_level );
+  _SMP_lock_Release_and_ISR_enable_inline( lock, context );
 }
 
 #if defined(RTEMS_DEBUG)
@@ -98,5 +71,3 @@ bool _SMP_lock_Is_owner( const SMP_lock_Control *lock )
   return lock->owner == _SMP_Get_current_processor();
 }
 #endif
-
-#endif /* defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) */




More information about the vc mailing list