[PATCH 1/6] score: Remove unused macros

2019-04-11 Thread Sebastian Huber
---
 cpukit/include/rtems/score/percpu.h | 28 
 1 file changed, 28 deletions(-)

diff --git a/cpukit/include/rtems/score/percpu.h 
b/cpukit/include/rtems/score/percpu.h
index 4ffefae292..8e33aaee4a 100644
--- a/cpukit/include/rtems/score/percpu.h
+++ b/cpukit/include/rtems/score/percpu.h
@@ -566,34 +566,6 @@ extern Per_CPU_Control_envelope _Per_CPU_Information[] 
CPU_STRUCTURE_ALIGNMENT;
   } while ( 0 )
 #endif
 
-#if defined( RTEMS_SMP )
-#define _Per_CPU_ISR_disable_and_acquire( cpu, isr_cookie ) \
-  do { \
-_ISR_Local_disable( isr_cookie ); \
-_Per_CPU_Acquire( cpu ); \
-  } while ( 0 )
-#else
-#define _Per_CPU_ISR_disable_and_acquire( cpu, isr_cookie ) \
-  do { \
-_ISR_Local_disable( isr_cookie ); \
-(void) ( cpu ); \
-  } while ( 0 )
-#endif
-
-#if defined( RTEMS_SMP )
-#define _Per_CPU_Release_and_ISR_enable( cpu, isr_cookie ) \
-  do { \
-_Per_CPU_Release( cpu ); \
-_ISR_Local_enable( isr_cookie ); \
-  } while ( 0 )
-#else
-#define _Per_CPU_Release_and_ISR_enable( cpu, isr_cookie ) \
-  do { \
-(void) ( cpu ); \
-_ISR_Local_enable( isr_cookie ); \
-  } while ( 0 )
-#endif
-
 #if defined( RTEMS_SMP )
 #define _Per_CPU_Acquire_all( isr_cookie ) \
   do { \
-- 
2.16.4

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 3/6] score: Use an ISR lock for Per_CPU_Control::Lock

2019-04-11 Thread Sebastian Huber
The use of a hand crafted lock for Per_CPU_Control::Lock was necessary
at some point in the SMP support development, but it is no longer
justified.
---
 cpukit/include/rtems/score/percpu.h   | 161 +-
 cpukit/include/rtems/score/schedulersmpimpl.h |  12 +-
 cpukit/include/rtems/score/threadimpl.h   |   6 +-
 cpukit/include/rtems/score/userextimpl.h  |   5 +-
 cpukit/posix/src/pspinlock.c  |  11 +-
 cpukit/posix/src/pspinunlock.c|  13 ++-
 cpukit/score/src/schedulersmp.c   |  13 ++-
 cpukit/score/src/smp.c|   6 +-
 cpukit/score/src/threaddispatch.c |  17 +--
 cpukit/score/src/userextaddset.c  |   6 +-
 cpukit/score/src/userextremoveset.c   |   6 +-
 11 files changed, 133 insertions(+), 123 deletions(-)

diff --git a/cpukit/include/rtems/score/percpu.h 
b/cpukit/include/rtems/score/percpu.h
index 8e33aaee4a..d7232c632f 100644
--- a/cpukit/include/rtems/score/percpu.h
+++ b/cpukit/include/rtems/score/percpu.h
@@ -28,7 +28,6 @@
   #include 
   #include 
   #include 
-  #include 
   #include 
   #include 
 #endif
@@ -333,7 +332,7 @@ typedef struct Per_CPU_Control {
*
* It is volatile since interrupts may alter this flag.
*
-   * This field is not protected by a lock and must be accessed only by this
+   * This member is not protected by a lock and must be accessed only by this
* processor.  Code (e.g. scheduler and post-switch action requests) running
* on another processors must use an inter-processor interrupt to set the
* thread dispatch necessary indicator to true.
@@ -352,7 +351,8 @@ typedef struct Per_CPU_Control {
   /**
* @brief This is the thread executing on this processor.
*
-   * This field is not protected by a lock.  The only writer is this processor.
+   * This member is not protected by a lock.  The only writer is this
+   * processor.
*
* On SMP configurations a thread may be registered as executing on more than
* one processor in case a thread migration is in progress.  On SMP
@@ -364,10 +364,10 @@ typedef struct Per_CPU_Control {
   /**
* @brief This is the heir thread for this processor.
*
-   * This field is not protected by a lock.  The only writer after multitasking
-   * start is the scheduler owning this processor.  It is assumed that stores
-   * to pointers are atomic on all supported SMP architectures.  The CPU port
-   * specific code (inter-processor interrupt handling and
+   * This member is not protected by a lock.  The only writer after
+   * multitasking start is the scheduler owning this processor.  It is assumed
+   * that stores to pointers are atomic on all supported SMP architectures.
+   * The CPU port specific code (inter-processor interrupt handling and
* _CPU_SMP_Send_interrupt()) must guarantee that this processor observes the
* last value written.
*
@@ -418,39 +418,31 @@ typedef struct Per_CPU_Control {
 
   #if defined( RTEMS_SMP )
 /**
- * @brief This lock protects some parts of the low-level thread 
dispatching.
+ * @brief This lock protects some members of this structure.
+ */
+ISR_lock_Control Lock;
+
+/**
+ * @brief Lock context used to acquire all per-CPU locks.
  *
- * We must use a ticket lock here since we cannot transport a local context
- * through the context switch.
+ * This member is protected by the Per_CPU_Control::Lock lock.
  *
- * @see _Thread_Dispatch().
+ * @see _Per_CPU_Acquire_all().
  */
-SMP_ticket_lock_Control Lock;
-
-#if defined( RTEMS_PROFILING )
-  /**
-   * @brief Lock statistics for the per-CPU lock.
-   */
-  SMP_lock_Stats Lock_stats;
-
-  /**
-   * @brief Lock statistics context for the per-CPU lock.
-   */
-  SMP_lock_Stats_context Lock_stats_context;
-#endif
+ISR_lock_Context Lock_context;
 
 /**
  * @brief Chain of threads in need for help.
  *
- * This field is protected by the Per_CPU_Control::Lock lock.
+ * This member is protected by the Per_CPU_Control::Lock lock.
  */
 Chain_Control Threads_in_need_for_help;
 
 /**
  * @brief Bit field for SMP messages.
  *
- * This bit field is not protected locks.  Atomic operations are used to
- * set and get the message bits.
+ * This member is not protected locks.  Atomic operations are used to set
+ * and get the message bits.
  */
 Atomic_Ulong message;
 
@@ -488,7 +480,7 @@ typedef struct Per_CPU_Control {
 /**
  * @brief Indicates the current state of the CPU.
  *
- * This field is protected by the _Per_CPU_State_lock lock.
+ * This member is protected by the _Per_CPU_State_lock lock.
  *
  * @see _Per_CPU_State_change().
  */
@@ -539,62 +531,11 @@ typedef struct {
  */
 extern Per_CPU_Control_envelope _Per_CPU_Information[] CPU_STRUCTURE_ALIGNMENT;
 
-#if defined( RTEMS_SMP )
-#d

[PATCH 2/6] score: Add _ISR_lock_Set_name()

2019-04-11 Thread Sebastian Huber
Add _ISR_lock_Set_name() to optimize the initialization of
zero-initialized locks.
---
 cpukit/include/rtems/score/isrlock.h | 15 +++
 cpukit/include/rtems/score/smplock.h | 21 -
 cpukit/score/src/smp.c   |  2 +-
 testsuites/sptests/sp37/init.c   | 22 +-
 4 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/cpukit/include/rtems/score/isrlock.h 
b/cpukit/include/rtems/score/isrlock.h
index b1aea62bf0..de85286de7 100644
--- a/cpukit/include/rtems/score/isrlock.h
+++ b/cpukit/include/rtems/score/isrlock.h
@@ -199,6 +199,21 @@ RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level(
   #define _ISR_lock_Destroy( _lock )
 #endif
 
+/**
+ * @brief Sets the name of an ISR lock.
+ *
+ * @param[out] _lock The ISR lock control.
+ * @param _name The name for the ISR lock.  This name must be a string
+ *   persistent throughout the life time of this lock.  The name is only used
+ *   if profiling is enabled.
+ */
+#if defined( RTEMS_SMP )
+  #define _ISR_lock_Set_name( _lock, _name ) \
+_SMP_lock_Set_name( &( _lock )->Lock, _name )
+#else
+  #define _ISR_lock_Set_name( _lock, _name )
+#endif
+
 /**
  * @brief Acquires an ISR lock.
  *
diff --git a/cpukit/include/rtems/score/smplock.h 
b/cpukit/include/rtems/score/smplock.h
index 1c37db465b..b1f5a6de28 100644
--- a/cpukit/include/rtems/score/smplock.h
+++ b/cpukit/include/rtems/score/smplock.h
@@ -149,7 +149,7 @@ static inline void _SMP_lock_Initialize_inline(
 #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE)
 void _SMP_lock_Initialize(
   SMP_lock_Control *lock,
-  const char *  name
+  const char   *name
 );
 #else
 #define _SMP_lock_Initialize( lock, name ) \
@@ -176,6 +176,25 @@ void _SMP_lock_Destroy( SMP_lock_Control *lock );
   _SMP_lock_Destroy_inline( lock )
 #endif
 
+/**
+ * @brief Sets the name of an SMP lock.
+ *
+ * @param[out] lock The SMP lock control.
+ * @param name The name for the SMP lock statistics.  This name must be
+ *   persistent throughout the life time of this statistics block.
+ */
+static inline void _SMP_lock_Set_name(
+  SMP_lock_Control *lock,
+  const char   *name
+)
+{
+#if defined(RTEMS_PROFILING)
+  lock->Stats.name = name;
+#else
+  (void) name;
+#endif
+}
+
 #if defined(RTEMS_DEBUG)
 static inline uint32_t _SMP_lock_Who_am_I( void )
 {
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index 780b33c740..bfc23d5ce3 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -116,7 +116,7 @@ void _SMP_Handler_initialize( void )
   for ( cpu_index = 0 ; cpu_index < cpu_config_max; ++cpu_index ) {
 Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
 
-_ISR_lock_Initialize( &cpu->Watchdog.Lock, "Watchdog" );
+_ISR_lock_Set_name( &cpu->Watchdog.Lock, "Watchdog" );
 _SMP_ticket_lock_Initialize( &cpu->Lock );
 _SMP_lock_Stats_initialize( &cpu->Lock_stats, "Per-CPU" );
 _Chain_Initialize_empty( &cpu->Threads_in_need_for_help );
diff --git a/testsuites/sptests/sp37/init.c b/testsuites/sptests/sp37/init.c
index 1a63298d3b..22c7d4f2ef 100644
--- a/testsuites/sptests/sp37/init.c
+++ b/testsuites/sptests/sp37/init.c
@@ -169,24 +169,36 @@ static void test_isr_level( void )
 
 static void test_isr_locks( void )
 {
+  static const char name[] = "test";
   ISR_Level normal_interrupt_level = _ISR_Get_level();
-  ISR_lock_Control initialized = ISR_LOCK_INITIALIZER("test");
+  ISR_lock_Control initialized = ISR_LOCK_INITIALIZER( name );
+  ISR_lock_Control zero_initialized;
   union {
 ISR_lock_Control lock;
 uint8_t bytes[ sizeof( ISR_lock_Control ) ];
   } container;
   ISR_lock_Context lock_context;
   size_t i;
-  const uint8_t *initialized_bytes;
+  const uint8_t *bytes;
   ISR_Level interrupt_level;
 
   memset( &container, 0xff, sizeof( container ) );
-  _ISR_lock_Initialize( &container.lock, "test" );
-  initialized_bytes = (const uint8_t *) &initialized;
+  _ISR_lock_Initialize( &container.lock, name );
+  bytes = (const uint8_t *) &initialized;
 
   for ( i = 0; i < sizeof( container ); ++i ) {
 if ( container.bytes[ i ] != 0xff ) {
-  rtems_test_assert( container.bytes[ i ] == initialized_bytes[ i] );
+  rtems_test_assert( container.bytes[ i ] == bytes[ i ] );
+}
+  }
+
+  memset( &zero_initialized, 0, sizeof( zero_initialized ) );
+  _ISR_lock_Set_name( &zero_initialized, name );
+  bytes = (const uint8_t *) &zero_initialized;
+
+  for ( i = 0; i < sizeof( container ); ++i ) {
+if ( container.bytes[ i ] != 0xff ) {
+  rtems_test_assert( container.bytes[ i ] == bytes[ i ] );
 }
   }
 
-- 
2.16.4

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 6/6] score: Improve _SMP_Multicast_action()

2019-04-11 Thread Sebastian Huber
Let it work during system initialization.
---
 cpukit/include/rtems/score/smpimpl.h  |  3 +-
 cpukit/score/src/percpu.c |  1 +
 cpukit/score/src/smpmulticastaction.c | 20 +++
 testsuites/smptests/smpmulticast01/init.c | 59 ++-
 4 files changed, 34 insertions(+), 49 deletions(-)

diff --git a/cpukit/include/rtems/score/smpimpl.h 
b/cpukit/include/rtems/score/smpimpl.h
index a501339176..c0a3ccb610 100644
--- a/cpukit/include/rtems/score/smpimpl.h
+++ b/cpukit/include/rtems/score/smpimpl.h
@@ -78,7 +78,8 @@ typedef enum {
   SMP_FATAL_SHUTDOWN,
   SMP_FATAL_SHUTDOWN_RESPONSE,
   SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED,
-  SMP_FATAL_SCHEDULER_PIN_OR_UNPIN_NOT_SUPPORTED
+  SMP_FATAL_SCHEDULER_PIN_OR_UNPIN_NOT_SUPPORTED,
+  SMP_FATAL_INVALID_CPU_STATE_TO_PERFORM_JOBS
 } SMP_Fatal_code;
 
 static inline void _SMP_Fatal( SMP_Fatal_code code )
diff --git a/cpukit/score/src/percpu.c b/cpukit/score/src/percpu.c
index 0e4c0678e7..e4c3b881e5 100644
--- a/cpukit/score/src/percpu.c
+++ b/cpukit/score/src/percpu.c
@@ -99,6 +99,7 @@ static void _Per_CPU_State_busy_wait(
   && state != PER_CPU_STATE_SHUTDOWN
   ) {
 _Per_CPU_State_before_multitasking_action( cpu );
+_Per_CPU_Perform_jobs( cpu );
 _CPU_SMP_Processor_event_receive();
 state = cpu->state;
   }
diff --git a/cpukit/score/src/smpmulticastaction.c 
b/cpukit/score/src/smpmulticastaction.c
index 2288dbe939..69bc87d7e0 100644
--- a/cpukit/score/src/smpmulticastaction.c
+++ b/cpukit/score/src/smpmulticastaction.c
@@ -31,7 +31,6 @@
 
 #include 
 #include 
-#include 
 
 typedef struct Per_CPU_Job {
   struct Per_CPU_Job *next;
@@ -138,11 +137,23 @@ static void _SMP_Wait_for_action_jobs(
   for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
 if ( _Processor_mask_Is_set( targets, cpu_index ) ) {
   const Per_CPU_Job *job;
+  Per_CPU_Control   *cpu;
 
   job = &jobs[ cpu_index ];
+  cpu = _Per_CPU_Get_by_index( cpu_index );
 
   while ( _Atomic_Load_uint( &job->done, ATOMIC_ORDER_ACQUIRE ) == 0 ) {
-_Per_CPU_Try_perform_jobs( cpu_self );
+switch ( cpu->state ) {
+  case PER_CPU_STATE_INITIAL:
+  case PER_CPU_STATE_READY_TO_START_MULTITASKING:
+  case PER_CPU_STATE_REQUEST_START_MULTITASKING:
+  case PER_CPU_STATE_UP:
+_Per_CPU_Try_perform_jobs( cpu_self );
+break;
+  default:
+_SMP_Fatal( SMP_FATAL_INVALID_CPU_STATE_TO_PERFORM_JOBS );
+break;
+}
   }
 }
   }
@@ -161,11 +172,6 @@ void _SMP_Multicast_action(
   cpu_max = _SMP_Get_processor_maximum();
   _Assert( cpu_max <= CPU_MAXIMUM_PROCESSORS );
 
-  if ( ! _System_state_Is_up( _System_state_Get() ) ) {
-( *handler )( arg );
-return;
-  }
-
   if ( targets == NULL ) {
 targets = _SMP_Get_online_processors();
   }
diff --git a/testsuites/smptests/smpmulticast01/init.c 
b/testsuites/smptests/smpmulticast01/init.c
index e599a78bde..c421767b1c 100644
--- a/testsuites/smptests/smpmulticast01/init.c
+++ b/testsuites/smptests/smpmulticast01/init.c
@@ -104,18 +104,15 @@ static void action(void *arg)
 
 static void test_unicast(
   test_context *ctx,
-  void (*multicast_action)(const Processor_mask *, SMP_Action_handler, void *),
-  bool before_multitasking
+  void (*multicast_action)(const Processor_mask *, SMP_Action_handler, void *)
 )
 {
   uint32_t step;
   uint32_t i;
   uint32_t n;
-  uint32_t self;
 
   T_plan(1);
   step = 0;
-  self = rtems_scheduler_get_processor();
   n = rtems_scheduler_get_processor_maximum();
 
   for (i = 0; i < n; ++i) {
@@ -134,18 +131,10 @@ static void test_unicast(
   ++step;
   id = _Atomic_Load_uint(&ctx->id[j], ATOMIC_ORDER_RELAXED);
 
-  if (before_multitasking) {
-if (j == self) {
-  T_quiet_eq_uint(j + 1, id);
-} else {
-  T_quiet_eq_uint(0, id);
-}
+  if (j == i) {
+T_quiet_eq_uint(j + 1, id);
   } else {
-if (j == i) {
-  T_quiet_eq_uint(j + 1, id);
-} else {
-  T_quiet_eq_uint(0, id);
-}
+T_quiet_eq_uint(0, id);
   }
 }
   }
@@ -155,18 +144,15 @@ static void test_unicast(
 
 static void test_broadcast(
   test_context *ctx,
-  void (*multicast_action)(const Processor_mask *, SMP_Action_handler, void *),
-  bool before_multitasking
+  void (*multicast_action)(const Processor_mask *, SMP_Action_handler, void *)
 )
 {
   uint32_t step;
   uint32_t i;
   uint32_t n;
-  uint32_t self;
 
   T_plan(1);
   step = 0;
-  self = rtems_scheduler_get_processor();
   n = rtems_scheduler_get_processor_maximum();
 
   for (i = 0; i < n; ++i) {
@@ -181,16 +167,7 @@ static void test_broadcast(
 
   ++step;
   id = _Atomic_Load_uint(&ctx->id[j], ATOMIC_ORDER_RELAXED);
-
-  if (before_multitasking) {
-if (j == self) {
-  T_quiet_eq_uint(j + 1, id);
-} else {
-  T_quiet

[PATCH 4/6] score: Use processor mask in _SMP_Multicast_action

2019-04-11 Thread Sebastian Huber
Processor_mask is the internal data type to deal with processor sets.
---
 bsps/shared/cache/cacheimpl.h  |   4 +-
 cpukit/include/rtems/score/smpimpl.h   |  19 +-
 cpukit/score/src/smpmulticastaction.c  |  24 +-
 testsuites/smptests/Makefile.am|  11 +
 testsuites/smptests/configure.ac   |   1 +
 testsuites/smptests/smpcache01/init.c  |  58 ++---
 testsuites/smptests/smpmulticast01/init.c  | 288 +
 .../smptests/smpmulticast01/smpmulticast01.doc |  12 +
 .../smptests/smpmulticast01/smpmulticast01.scn |  54 
 9 files changed, 404 insertions(+), 67 deletions(-)
 create mode 100644 testsuites/smptests/smpmulticast01/init.c
 create mode 100644 testsuites/smptests/smpmulticast01/smpmulticast01.doc
 create mode 100644 testsuites/smptests/smpmulticast01/smpmulticast01.scn

diff --git a/bsps/shared/cache/cacheimpl.h b/bsps/shared/cache/cacheimpl.h
index cb7f02d4ec..dbed9c8a19 100644
--- a/bsps/shared/cache/cacheimpl.h
+++ b/bsps/shared/cache/cacheimpl.h
@@ -329,7 +329,7 @@ rtems_cache_invalidate_multiple_instruction_lines(
 #if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
   smp_cache_area area = { i_addr, n_bytes };
 
-  _SMP_Multicast_action( 0, NULL, smp_cache_inst_inv, &area );
+  _SMP_Multicast_action( NULL, smp_cache_inst_inv, &area );
 #else
   _CPU_cache_invalidate_instruction_range( i_addr, n_bytes );
 #endif
@@ -345,7 +345,7 @@ rtems_cache_invalidate_entire_instruction( void )
 {
 #if defined(CPU_INSTRUCTION_CACHE_ALIGNMENT)
 #if defined(RTEMS_SMP) && defined(CPU_CACHE_NO_INSTRUCTION_CACHE_SNOOPING)
-  _SMP_Multicast_action( 0, NULL, smp_cache_inst_inv_all, NULL );
+  _SMP_Multicast_action( NULL, smp_cache_inst_inv_all, NULL );
 #else
  _CPU_cache_invalidate_entire_instruction();
 #endif
diff --git a/cpukit/include/rtems/score/smpimpl.h 
b/cpukit/include/rtems/score/smpimpl.h
index 117b78cb74..6b59b9497d 100644
--- a/cpukit/include/rtems/score/smpimpl.h
+++ b/cpukit/include/rtems/score/smpimpl.h
@@ -249,20 +249,19 @@ void _SMP_Send_message_multicast(
 typedef void ( *SMP_Action_handler )( void *arg );
 
 /**
- *  @brief Initiates an SMP multicast action to a set of processors.
+ * @brief Initiates an SMP multicast action to a set of target processors.
  *
- *  The current processor may be part of the set.
+ * The current processor may be part of the set.
  *
- *  @param[in] setsize The size of the set of target processors of the message.
- *  @param[in] cpus The set of target processors of the message.
- *  @param[in] handler The multicast action handler.
- *  @param[in] arg The multicast action argument.
+ * @param targets The set of target processors for the action.  If @c NULL,
+ *   then the action will be performed on all online processors.
+ * @param handler The multicast action handler.
+ * @param arg The multicast action argument.
  */
 void _SMP_Multicast_action(
-  const size_t setsize,
-  const cpu_set_t *cpus,
-  SMP_Action_handler handler,
-  void *arg
+  const Processor_mask *targets,
+  SMP_Action_handlerhandler,
+  void *arg
 );
 
 /**
diff --git a/cpukit/score/src/smpmulticastaction.c 
b/cpukit/score/src/smpmulticastaction.c
index 0cf675f795..0b9641c3db 100644
--- a/cpukit/score/src/smpmulticastaction.c
+++ b/cpukit/score/src/smpmulticastaction.c
@@ -89,14 +89,12 @@ _SMP_Multicasts_try_process( void )
 }
 
 void _SMP_Multicast_action(
-  const size_t setsize,
-  const cpu_set_t *cpus,
-  SMP_Action_handler handler,
-  void *arg
+  const Processor_mask *targets,
+  SMP_Action_handlerhandler,
+  void *arg
 )
 {
   SMP_Multicast_action node;
-  Processor_mask   targets;
   ISR_lock_Context lock_context;
   uint32_t i;
 
@@ -105,29 +103,21 @@ void _SMP_Multicast_action(
 return;
   }
 
-  if( cpus == NULL ) {
-_Processor_mask_Assign( &targets, _SMP_Get_online_processors() );
-  } else {
-_Processor_mask_Zero( &targets );
-
-for ( i = 0; i < _SMP_Get_processor_maximum(); ++i ) {
-  if ( CPU_ISSET_S( i, setsize, cpus ) ) {
-_Processor_mask_Set( &targets, i );
-  }
-}
+  if( targets == NULL ) {
+targets = _SMP_Get_online_processors();
   }
 
   _Chain_Initialize_node( &node.Node );
   node.handler = handler;
   node.arg = arg;
-  _Processor_mask_Assign( &node.targets, &targets );
+  _Processor_mask_Assign( &node.targets, targets );
   _Atomic_Store_ulong( &node.done, 0, ATOMIC_ORDER_RELAXED );
 
   _ISR_lock_ISR_disable_and_acquire( &_SMP_Multicast.Lock, &lock_context );
   _Chain_Prepend_unprotected( &_SMP_Multicast.Actions, &node.Node );
   _ISR_lock_Release_and_ISR_enable( &_SMP_Multicast.Lock, &lock_context );
 
-  _SMP_Send_message_multicast( &targets, SMP_MESSAGE_MULTICAST_ACTION );
+  _SMP_Send_message_multicast( targets, SMP_MESSAGE_MULTICAST_ACTION );
   _SMP_Multicasts_try_process();
 
   while ( _Atomic_Load_ulong( &node.done, ATOM

[PATCH 5/6] score: Rework SMP multicast action

2019-04-11 Thread Sebastian Huber
---
 cpukit/include/rtems/score/percpu.h   |  32 +
 cpukit/include/rtems/score/smpimpl.h  |  13 +-
 cpukit/score/src/smpmulticastaction.c | 203 +++---
 testsuites/smptests/smpcache01/init.c |   5 +-
 testsuites/smptests/smpmulticast01/init.c |   3 +
 5 files changed, 170 insertions(+), 86 deletions(-)

diff --git a/cpukit/include/rtems/score/percpu.h 
b/cpukit/include/rtems/score/percpu.h
index d7232c632f..a0eb46c045 100644
--- a/cpukit/include/rtems/score/percpu.h
+++ b/cpukit/include/rtems/score/percpu.h
@@ -74,6 +74,8 @@ struct _Thread_Control;
 
 struct Scheduler_Context;
 
+struct Per_CPU_Job;
+
 /**
  *  @defgroup PerCPU RTEMS Per CPU Information
  *
@@ -494,6 +496,29 @@ typedef struct Per_CPU_Control {
  */
 Atomic_Uintptr before_multitasking_action;
 
+/**
+ * @brief FIFO list of jobs to be performed by this processor.
+ *
+ * The members are protected by the Per_CPU_Control::Lock lock.
+ *
+ * @see _SMP_Multicast_action().
+ */
+struct {
+  /**
+   * @brief Head of the FIFO list of jobs to be performed by this
+   * processor.
+   */
+  struct Per_CPU_Job *head;
+
+  /**
+   * @brief Tail of the FIFO list of jobs to be performed by this
+   * processor.
+   *
+   * This member is only valid if the head is not @c NULL.
+   */
+  struct Per_CPU_Job **tail;
+} Jobs;
+
 /**
  * @brief Indicates if the processor has been successfully started via
  * _CPU_SMP_Start_processor().
@@ -710,6 +735,13 @@ bool _Per_CPU_State_wait_for_non_initial_state(
   uint32_t timeout_in_ns
 );
 
+/**
+ * @brief Performs the jobs of the specified processor.
+ *
+ * @param[in, out] cpu The jobs of this processor will be performed.
+ */
+void _Per_CPU_Perform_jobs( Per_CPU_Control *cpu );
+
 #endif /* defined( RTEMS_SMP ) */
 
 /*
diff --git a/cpukit/include/rtems/score/smpimpl.h 
b/cpukit/include/rtems/score/smpimpl.h
index 6b59b9497d..a501339176 100644
--- a/cpukit/include/rtems/score/smpimpl.h
+++ b/cpukit/include/rtems/score/smpimpl.h
@@ -51,11 +51,11 @@ extern "C" {
 #define SMP_MESSAGE_TEST 0x2UL
 
 /**
- * @brief SMP message to request a multicast action.
+ * @brief SMP message to perform per-CPU jobs.
  *
  * @see _SMP_Send_message().
  */
-#define SMP_MESSAGE_MULTICAST_ACTION 0x4UL
+#define SMP_MESSAGE_PERFORM_JOBS 0x4UL
 
 /**
  * @brief SMP message to request a clock tick.
@@ -157,11 +157,6 @@ static inline void _SMP_Set_test_message_handler(
   _SMP_Test_message_handler = handler;
 }
 
-/**
- * @brief Processes all pending multicast actions.
- */
-void _SMP_Multicast_actions_process( void );
-
 /**
  * @brief Interrupt handler for inter-processor interrupts.
  *
@@ -195,8 +190,8 @@ static inline long unsigned 
_SMP_Inter_processor_interrupt_handler(
   ( *_SMP_Test_message_handler )( cpu_self );
 }
 
-if ( ( message & SMP_MESSAGE_MULTICAST_ACTION ) != 0 ) {
-  _SMP_Multicast_actions_process();
+if ( ( message & SMP_MESSAGE_PERFORM_JOBS ) != 0 ) {
+  _Per_CPU_Perform_jobs( cpu_self );
 }
   }
 
diff --git a/cpukit/score/src/smpmulticastaction.c 
b/cpukit/score/src/smpmulticastaction.c
index 0b9641c3db..2288dbe939 100644
--- a/cpukit/score/src/smpmulticastaction.c
+++ b/cpukit/score/src/smpmulticastaction.c
@@ -1,91 +1,151 @@
 /*
- * Copyright (c) 2014 Aeroflex Gaisler AB.  All rights reserved.
+ * SPDX-License-Identifier: BSD-2-Clause
  *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Copyright (C) 2019 embedded brains GmbH
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */

Re: [rtems-test] powerpc/psim: RTEMS_POSIX_API: Passed:560 Failed:14 Timeout:5 Invalid:0 Wrong:0

2019-04-11 Thread Chris Johns
Hi Joel,

Thank you for running these tests and publishing the results.

On 12/4/19 8:10 am, j...@rtems.org wrote:
> Testing time : 0:10:37.757133
> Average test time: 0:00:01.084621
> 
> Host
> 
> Linux-3.10.0-862.11.6.el7.x86_64-x86_64-with-centos-7.5.1804-Core (Linux 
> rtbf64c.rtems.com 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 
> 2018 x86_64 x86_64)
> 
> Configuration
> =
> Version: 5.0.0.ad87de4a67d8ce7e75d0b844efc03b98c3ecda1a
> Build  : RTEMS_POSIX_API
> Tools  : 7.4.0 20181206 (RTEMS 5, RSB 
> 9a3e12e5820918057633798c3fe2a1f952fb4e56, Newlib 1d35a003f)
> 
> Summary
> ===
> 
> Passed:560
> Failed: 14
> User Input:  6
> Expected Fail:   0
> Indeterminate:   0
> Benchmark:   3
> Timeout: 5
> Invalid: 0
> Wrong Version:   0
> Wrong Build: 0
> Wrong Tools: 0
> --
> Total: 588
> 
> Failures:
>  fsimfsgeneric01.exe
>  block11.exe
>  devfs02.exe
>  rbheap01.exe
>  termios01.exe
>  psx12.exe
>  psxchroot01.exe
>  psximfs02.exe
>  psxpipe01.exe
>  spconfig02.exe
>  spfatal31.exe
>  spmountmgr01.exe
>  spprivenv01.exe
>  spstdthreads01.exe
> User Input:
>  dl10.exe
>  monitor.exe
>  termios.exe
>  top.exe
>  capture.exe
>  fileio.exe
> Benchmark:
>  whetstone.exe
>  dhrystone.exe
>  linpack.exe
> Timeouts:
>  fsrfsbitmap01.exe
>  dl08.exe
>  dl09.exe

The `dl.*` test timeouts look like the test is running too long and if you have
a number of tests running at once this could be the reason.

I see a couple of possible solutions, adding timeout control to the tests which
rtems-test can see of I can drop the loop count to 10. The loop count is the
simplest.

The loop lets me see a repeating set of addresses being used so I can check for
leaks.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [rtems-test] powerpc/psim: RTEMS_POSIX_API: Passed:560 Failed:14 Timeout:5 Invalid:0 Wrong:0

2019-04-11 Thread Joel Sherrill
On Thu, Apr 11, 2019 at 5:16 PM Chris Johns  wrote:

> Hi Joel,
>
> Thank you for running these tests and publishing the results.
>

:) I'm trying to build up my "rtems-cron" script. Not the fanciest way to
decide when to test things but it will know how to test them.

It will eventually run Coverity

Any advice on knowing in a script if git needs to update a repo or a pull
updated? I thought this would work but it didn't show the rtems updates
today:

git rev-list HEAD...origin/master --count


> On 12/4/19 8:10 am, j...@rtems.org wrote:
> > Testing time : 0:10:37.757133
> > Average test time: 0:00:01.084621
> >
> > Host
> > 
> > Linux-3.10.0-862.11.6.el7.x86_64-x86_64-with-centos-7.5.1804-Core (Linux
> rtbf64c.rtems.com 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04
> UTC 2018 x86_64 x86_64)
> >
> > Configuration
> > =
> > Version: 5.0.0.ad87de4a67d8ce7e75d0b844efc03b98c3ecda1a
> > Build  : RTEMS_POSIX_API
> > Tools  : 7.4.0 20181206 (RTEMS 5, RSB
> 9a3e12e5820918057633798c3fe2a1f952fb4e56, Newlib 1d35a003f)
> >
> > Summary
> > ===
> >
> > Passed:560
> > Failed: 14
> > User Input:  6
> > Expected Fail:   0
> > Indeterminate:   0
> > Benchmark:   3
> > Timeout: 5
> > Invalid: 0
> > Wrong Version:   0
> > Wrong Build: 0
> > Wrong Tools: 0
> > --
> > Total: 588
> >
> > Failures:
> >  fsimfsgeneric01.exe
> >  block11.exe
> >  devfs02.exe
> >  rbheap01.exe
> >  termios01.exe
> >  psx12.exe
> >  psxchroot01.exe
> >  psximfs02.exe
> >  psxpipe01.exe
> >  spconfig02.exe
> >  spfatal31.exe
> >  spmountmgr01.exe
> >  spprivenv01.exe
> >  spstdthreads01.exe
> > User Input:
> >  dl10.exe
> >  monitor.exe
> >  termios.exe
> >  top.exe
> >  capture.exe
> >  fileio.exe
> > Benchmark:
> >  whetstone.exe
> >  dhrystone.exe
> >  linpack.exe
> > Timeouts:
> >  fsrfsbitmap01.exe
> >  dl08.exe
> >  dl09.exe
>
> The `dl.*` test timeouts look like the test is running too long and if you
> have
> a number of tests running at once this could be the reason.
>

When run by hand, dl08 passes with this much time used:

real0m7.194s
user0m5.997s
sys 0m0.703s

 dl09 is less. Those aren't very long. I don't know why they timeout with
the tester.

fsrfsbitmap01 is over 4.5 minutes of host CPU time and stuck here:

=
 23. Cleared bit still set: bit = 126

 Testing bitmap_map functions with zero initialized bitmap control pointer

 Allocate most of memory - attempt to fail while open bitmap - expect ENOMEM
=

I will let it continue overnight but this one is either hung or needs
tweaking to
consume most of memory a single large allocation and then force the the rfs
bitmap error.


> I see a couple of possible solutions, adding timeout control to the tests
> which
> rtems-test can see of I can drop the loop count to 10. The loop count is
> the
> simplest.
>
> The loop lets me see a repeating set of addresses being used so I can
> check for
> leaks.
>

I don't think that's the issue. The dl tests run quickly by hand.

>
> Chris
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [rtems-test] powerpc/psim: RTEMS_POSIX_API: Passed:560 Failed:14 Timeout:5 Invalid:0 Wrong:0

2019-04-11 Thread Joel Sherrill
On Thu, Apr 11, 2019 at 5:35 PM Joel Sherrill  wrote:

>
>
> On Thu, Apr 11, 2019 at 5:16 PM Chris Johns  wrote:
>
>> Hi Joel,
>>
>> Thank you for running these tests and publishing the results.
>>
>
> :) I'm trying to build up my "rtems-cron" script. Not the fanciest way to
> decide when to test things but it will know how to test them.
>
> It will eventually run Coverity
>
> Any advice on knowing in a script if git needs to update a repo or a pull
> updated? I thought this would work but it didn't show the rtems updates
> today:
>
> git rev-list HEAD...origin/master --count
>
>
>> On 12/4/19 8:10 am, j...@rtems.org wrote:
>> > Testing time : 0:10:37.757133
>> > Average test time: 0:00:01.084621
>> >
>> > Host
>> > 
>> > Linux-3.10.0-862.11.6.el7.x86_64-x86_64-with-centos-7.5.1804-Core
>> (Linux rtbf64c.rtems.com 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14
>> 21:49:04 UTC 2018 x86_64 x86_64)
>> >
>> > Configuration
>> > =
>> > Version: 5.0.0.ad87de4a67d8ce7e75d0b844efc03b98c3ecda1a
>> > Build  : RTEMS_POSIX_API
>> > Tools  : 7.4.0 20181206 (RTEMS 5, RSB
>> 9a3e12e5820918057633798c3fe2a1f952fb4e56, Newlib 1d35a003f)
>> >
>> > Summary
>> > ===
>> >
>> > Passed:560
>> > Failed: 14
>> > User Input:  6
>> > Expected Fail:   0
>> > Indeterminate:   0
>> > Benchmark:   3
>> > Timeout: 5
>> > Invalid: 0
>> > Wrong Version:   0
>> > Wrong Build: 0
>> > Wrong Tools: 0
>> > --
>> > Total: 588
>> >
>> > Failures:
>> >  fsimfsgeneric01.exe
>> >  block11.exe
>> >  devfs02.exe
>> >  rbheap01.exe
>> >  termios01.exe
>> >  psx12.exe
>> >  psxchroot01.exe
>> >  psximfs02.exe
>> >  psxpipe01.exe
>> >  spconfig02.exe
>> >  spfatal31.exe
>> >  spmountmgr01.exe
>> >  spprivenv01.exe
>> >  spstdthreads01.exe
>> > User Input:
>> >  dl10.exe
>> >  monitor.exe
>> >  termios.exe
>> >  top.exe
>> >  capture.exe
>> >  fileio.exe
>> > Benchmark:
>> >  whetstone.exe
>> >  dhrystone.exe
>> >  linpack.exe
>> > Timeouts:
>> >  fsrfsbitmap01.exe
>> >  dl08.exe
>> >  dl09.exe
>>
>> The `dl.*` test timeouts look like the test is running too long and if
>> you have
>> a number of tests running at once this could be the reason.
>>
>
> When run by hand, dl08 passes with this much time used:
>
> real0m7.194s
> user0m5.997s
> sys 0m0.703s
>
>  dl09 is less. Those aren't very long. I don't know why they timeout with
> the tester.
>
> fsrfsbitmap01 is over 4.5 minutes of host CPU time and stuck here:
>
> =
>  23. Cleared bit still set: bit = 126
>
>  Testing bitmap_map functions with zero initialized bitmap control pointer
>
>  Allocate most of memory - attempt to fail while open bitmap - expect
> ENOMEM
> =
>
> I will let it continue overnight but this one is either hung or needs
> tweaking to
> consume most of memory a single large allocation and then force the the
> rfs bitmap error.
>

Of course it failed as soon as I sent that email.

  Allocate most of memory - attempt to fail while open bitmap - expect
ENOMEM

*** FATAL ***
fatal source: 9 (RTEMS_FATAL_SOURCE_EXCEPTION)
exception vector 3 (0x3)
  next PC or address of fault = 0x0001980c
  saved MSR = 0xa072

It had consumed over 5 minutes of host time when that happened.

This fault was in rtems_bdbuf_read() in the true case of this if:

  if (rtems_bdbuf_is_read_ahead_active (dd))

doing  chain operation.

--joel

>
>
>> I see a couple of possible solutions, adding timeout control to the tests
>> which
>> rtems-test can see of I can drop the loop count to 10. The loop count is
>> the
>> simplest.
>>
>> The loop lets me see a repeating set of addresses being used so I can
>> check for
>> leaks.
>>
>
> I don't think that's the issue. The dl tests run quickly by hand.
>
>>
>> Chris
>>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [rtems-test] powerpc/psim: RTEMS_POSIX_API: Passed:560 Failed:14 Timeout:5 Invalid:0 Wrong:0

2019-04-11 Thread Chris Johns
On 12/4/19 8:35 am, Joel Sherrill wrote:
> Any advice on knowing in a script if git needs to update a repo or a pull
> updated? I thought this would work but it didn't show the rtems updates today:

This is what I do in the documentation automatic update ...

https://git.rtems.org/chrisj/rtems-admin.git/tree/docs/builder/rtems-docs-build-branches

I keep a local cache of the hash.

I also have a cron lock piece of shell script to avoid starting testing while it
is running. Doing this avoids having the check time being a multiple of the
total time something runs for. We can sort this out offline.

Chris
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel