Changeset 8fa14da0 in rtems


Ignore:
Timestamp:
Apr 18, 2019, 6:38:00 AM (2 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
85d6e845
Parents:
1a971d8
git-author:
Sebastian Huber <sebastian.huber@…> (04/18/19 06:38:00)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/20/19 06:52:25)
Message:

score: Move per-processor job data structures

This enables re-use for other purposes, e.g. replacement for
SMP_MESSAGE_TEST.

Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/score/percpu.h

    r1a971d8 r8fa14da0  
    7777
    7878struct Scheduler_Context;
    79 
    80 struct Per_CPU_Job;
    8179
    8280/**
     
    176174} Per_CPU_State;
    177175
     176typedef void ( *Per_CPU_Job_handler )( void *arg );
     177
     178/**
     179 * @brief Context for per-processor jobs.
     180 *
     181 * This is separate from Per_CPU_Job to save stack memory in
     182 * _SMP_Multicast_action().
     183 */
     184typedef struct {
     185  /**
     186   * @brief The job handler.
     187   */
     188  Per_CPU_Job_handler handler;
     189
     190  /**
     191   * @brief The job handler argument.
     192   */
     193  void *arg;
     194} Per_CPU_Job_context;
     195
     196/*
     197 * Value for the Per_CPU_Job::done member to indicate that a job is done
     198 * (handler was called on the target processor).  Must not be a valid pointer
     199 * value since it overlaps with the Per_CPU_Job::next member.
     200 */
     201#define PER_CPU_JOB_DONE 1
     202
     203/**
     204 * @brief A per-processor job.
     205 *
     206 * This structure must be as small as possible due to stack space constraints
     207 * in _SMP_Multicast_action().
     208 */
     209typedef struct Per_CPU_Job {
     210  union {
     211    /**
     212     * @brief The next job in the corresponding per-processor job list.
     213     */
     214    struct Per_CPU_Job *next;
     215
     216    /**
     217     * @brief Indication if the job is done.
     218     *
     219     * A job is done if this member has the value PER_CPU_JOB_DONE.  This
     220     * assumes that PER_CPU_JOB_DONE is not a valid pointer value.
     221     */
     222    Atomic_Ulong done;
     223  };
     224
     225  /**
     226   * @brief Pointer to the job context to get the handler and argument.
     227   */
     228  const Per_CPU_Job_context *context;
     229} Per_CPU_Job;
     230
    178231#endif /* defined( RTEMS_SMP ) */
    179232
     
    317370
    318371  /**
    319    * @brief Indicetes if an ISR thread dispatch is disabled.
     372   * @brief Indicates if an ISR thread dispatch is disabled.
    320373   *
    321374   * This flag is context switched with each thread.  It indicates that this
  • cpukit/score/src/smpmulticastaction.c

    r1a971d8 r8fa14da0  
    3333#include <rtems/score/assert.h>
    3434
    35 typedef struct Per_CPU_Job Per_CPU_Job;
    36 
    37 typedef struct Per_CPU_Jobs Per_CPU_Jobs;
    38 
    39 /*
    40  * Value for the Per_CPU_Job::done member to indicate that a job is done
    41  * (handler was called on the target processor).  Must not be a valid pointer
    42  * value since it overlaps with the Per_CPU_Job::next member.
    43  */
    44 #define PER_CPU_JOB_DONE 1
    45 
    46 /**
    47  * @brief A per-processor job.
    48  */
    49 struct Per_CPU_Job {
    50   union {
    51     /**
    52      * @brief The next job in the corresponding per-processor job list.
    53      */
    54     Per_CPU_Job *next;
    55 
    56     /**
    57      * @brief Indication if the job is done.
    58      *
    59      * A job is done if this member has the value PER_CPU_JOB_DONE.  This
    60      * assumes that PER_CPU_JOB_DONE is not a valid pointer value.
    61      */
    62     Atomic_Ulong done;
    63   };
    64 
    65   /**
    66    * @brief Back pointer to the jobs to get the handler and argument.
    67    */
    68   Per_CPU_Jobs *jobs;
    69 };
    70 
    71 /**
    72  * @brief A collection of jobs, one for each processor.
    73  */
    74 struct Per_CPU_Jobs {
    75   /**
    76    * @brief The job handler.
    77    */
    78   SMP_Action_handler handler;
    79 
    80   /**
    81    * @brief The job handler argument.
    82    */
    83   void *arg;
    84 
    85   /**
    86    * @brief One job for each potential processor.
    87    */
    88   Per_CPU_Job Jobs[ CPU_MAXIMUM_PROCESSORS ];
    89 };
    90 
    9135#define _Per_CPU_Jobs_ISR_disable_and_acquire( cpu, lock_context ) \
    9236  _ISR_lock_ISR_disable_and_acquire( &( cpu )->Jobs.Lock, lock_context )
     
    10347
    10448  while ( ( job = cpu->Jobs.head ) != NULL ) {
    105     Per_CPU_Jobs *jobs;
     49    const Per_CPU_Job_context *context;
    10650
    10751    cpu->Jobs.head = job->next;
    10852    _Per_CPU_Jobs_release_and_ISR_enable( cpu, &lock_context );
    10953
    110     jobs = job->jobs;
    111     ( *jobs->handler )( jobs->arg );
     54    context = job->context;
     55    ( *context->handler )( context->arg );
    11256    _Atomic_Store_ulong( &job->done, PER_CPU_JOB_DONE, ATOMIC_ORDER_RELEASE );
    11357
     
    13983}
    14084
     85typedef struct {
     86  Per_CPU_Job_context Context;
     87  Per_CPU_Job         Jobs[ CPU_MAXIMUM_PROCESSORS ];
     88} SMP_Multicast_jobs;
     89
    14190static void _SMP_Issue_action_jobs(
    14291  const Processor_mask *targets,
    143   Per_CPU_Jobs         *jobs,
     92  SMP_Multicast_jobs   *jobs,
    14493  uint32_t              cpu_max
    14594)
     
    156105      _Atomic_Store_ulong( &job->done, 0, ATOMIC_ORDER_RELAXED );
    157106      _Assert( job->next == NULL );
    158       job->jobs = jobs;
     107      job->context = &jobs->Context;
    159108
    160109      cpu = _Per_CPU_Get_by_index( cpu_index );
     
    176125
    177126static void _SMP_Wait_for_action_jobs(
    178   const Processor_mask *targets,
    179   const Per_CPU_Jobs  *jobs,
    180   uint32_t              cpu_max
     127  const Processor_mask     *targets,
     128  const SMP_Multicast_jobs *jobs,
     129  uint32_t                  cpu_max
    181130)
    182131{
     
    224173)
    225174{
    226   Per_CPU_Jobs jobs;
    227   uint32_t     cpu_max;
     175  SMP_Multicast_jobs jobs;
     176  uint32_t           cpu_max;
    228177
    229178  cpu_max = _SMP_Get_processor_maximum();
    230   _Assert( cpu_max <= CPU_MAXIMUM_PROCESSORS );
    231 
    232   jobs.handler = handler;
    233   jobs.arg = arg;
     179  _Assert( cpu_max <= RTEMS_ARRAY_SIZE( jobs.Jobs ) );
     180
     181  jobs.Context.handler = handler;
     182  jobs.Context.arg = arg;
    234183
    235184  _SMP_Issue_action_jobs( targets, &jobs, cpu_max );
Note: See TracChangeset for help on using the changeset viewer.