Changeset 0232b28 in rtems


Ignore:
Timestamp:
Jul 4, 2017, 6:59:37 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
76d1198
Parents:
1ec9c86
git-author:
Sebastian Huber <sebastian.huber@…> (07/04/17 06:59:37)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/07/17 05:36:31)
Message:

score: Use processor mask for set affinity

Update #3059.

Files:
8 edited

Legend:

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

    r1ec9c86 r0232b28  
    208208    const Scheduler_Control *,
    209209    Thread_Control *,
    210     size_t,
    211     const cpu_set_t *
     210    const Processor_mask *
    212211  );
    213212#endif
     
    508507#if defined(RTEMS_SMP)
    509508  /**
    510    * @brief Set affinity for the default scheduler.
     509   * @brief Default implementation of the set affinity scheduler operation.
    511510   *
    512511   * @param[in] scheduler The scheduler instance.
    513512   * @param[in] thread The associated thread.
    514    * @param[in] cpusetsize The size of the cpuset.
    515    * @param[in] cpuset Affinity new affinity set.
    516    *
    517    * @retval 0 Successful
    518    *
    519    *  This method always returns successful and does not save
    520    *  the cpuset.
     513   * @param[in] affinity The new processor affinity set for the thread.
     514   *
     515   * @retval true The processor set of the scheduler is a subset of the affinity set.
     516   * @retval false Otherwise.
    521517   */
    522518  bool _Scheduler_default_Set_affinity(
    523519    const Scheduler_Control *scheduler,
    524520    Thread_Control          *thread,
    525     size_t                   cpusetsize,
    526     const cpu_set_t         *cpuset
     521    const Processor_mask    *affinity
    527522  );
    528523
  • cpukit/score/include/rtems/score/schedulerimpl.h

    r1ec9c86 r0232b28  
    610610  const Scheduler_Control *scheduler,
    611611  Thread_Control          *the_thread,
    612   size_t                   cpusetsize,
    613   const cpu_set_t         *cpuset
    614 )
    615 {
    616   uint32_t cpu_count = _SMP_Get_processor_count();
    617   uint32_t cpu_index;
    618   bool     ok = true;
    619 
    620   for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
    621 #if defined(RTEMS_SMP)
    622     const Per_CPU_Control   *cpu;
    623     const Scheduler_Control *scheduler_of_cpu;
    624 
    625     cpu = _Per_CPU_Get_by_index( cpu_index );
    626     scheduler_of_cpu = _Scheduler_Get_by_CPU( cpu );
    627 
    628     ok = ok
    629       && ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
    630         || ( !CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
    631           && scheduler != scheduler_of_cpu ) );
    632 #else
    633     (void) scheduler;
    634 
    635     ok = ok && CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset );
    636 #endif
    637   }
    638 
    639   return ok;
     612  const Processor_mask    *affinity
     613)
     614{
     615  return _Processor_mask_Is_subset(
     616    affinity,
     617    _Scheduler_Get_processors( scheduler )
     618  );
    640619}
    641620
  • cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h

    r1ec9c86 r0232b28  
    142142 * @param[in] scheduler The scheduler of the thread.
    143143 * @param[in] thread The associated thread.
    144  * @param[in] cpusetsize The size of the cpuset.
    145  * @param[in] cpuset Affinity new affinity set.
     144 * @param[in] affinity The new affinity set.
    146145 *
    147146 * @retval true if successful
     
    151150  const Scheduler_Control *scheduler,
    152151  Thread_Control          *thread,
    153   size_t                   cpusetsize,
    154   const cpu_set_t         *cpuset
     152  const Processor_mask    *affinity
    155153);
    156154
  • cpukit/score/src/schedulerdefaultsetaffinity.c

    r1ec9c86 r0232b28  
    2525  const Scheduler_Control *scheduler,
    2626  Thread_Control          *thread,
    27   size_t                   cpusetsize,
    28   const cpu_set_t         *cpuset
     27  const Processor_mask    *affinity
    2928)
    3029{
     
    3231    scheduler,
    3332    thread,
    34     cpusetsize,
    35     cpuset
     33    affinity
    3634  );
    3735}
  • cpukit/score/src/schedulerpriorityaffinitysmp.c

    r1ec9c86 r0232b28  
    615615  const Scheduler_Control *scheduler,
    616616  Thread_Control          *thread,
    617   size_t                   cpusetsize,
    618   const cpu_set_t         *cpuset
     617  const Processor_mask    *affinity
    619618)
    620619{
    621620  Scheduler_priority_affinity_SMP_Node *node;
    622621  States_Control                        current_state;
    623 
     622  cpu_set_t                             cpuset;
     623  size_t                                cpusetsize;
     624
     625  cpusetsize = sizeof( cpuset );
     626  _Processor_mask_To_cpu_set_t( affinity, cpusetsize, &cpuset );
    624627  /*
    625628   * Validate that the cpset meets basic requirements.
    626629   */
    627   if ( !_CPU_set_Is_valid( cpuset, cpusetsize ) ) {
     630  if ( !_CPU_set_Is_valid( &cpuset, cpusetsize ) ) {
    628631    return false;
    629632  }
     
    635638   * doing anything.
    636639   */
    637   if ( CPU_EQUAL_S( cpusetsize, cpuset, node->Affinity.set ) )
     640  if ( CPU_EQUAL_S( cpusetsize, &cpuset, node->Affinity.set ) )
    638641    return true;
    639642
     
    644647  }
    645648
    646   CPU_COPY( cpuset, node->Affinity.set );
     649  CPU_COPY( &cpuset, node->Affinity.set );
    647650
    648651  if ( _States_Is_ready( current_state ) ) {
  • cpukit/score/src/schedulersetaffinity.c

    r1ec9c86 r0232b28  
    11/*
    2  * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    2020
    2121bool _Scheduler_Set_affinity(
    22   Thread_Control  *the_thread,
    23   size_t           cpusetsize,
    24   const cpu_set_t *cpuset
     22  Thread_Control       *the_thread,
     23  size_t                cpusetsize,
     24  const cpu_set_t      *cpuset
    2525)
    2626{
    27   const Scheduler_Control *scheduler;
    28   ISR_lock_Context         lock_context;
    29   bool                     ok;
     27  Processor_mask             affinity;
     28  Processor_mask_Copy_status status;
     29  const Scheduler_Control   *scheduler;
     30  ISR_lock_Context           lock_context;
     31  bool                       ok;
    3032
    31   if ( !_CPU_set_Is_large_enough( cpusetsize ) ) {
     33  status = _Processor_mask_From_cpu_set_t( &affinity, cpusetsize, cpuset );
     34  if ( !_Processor_mask_Is_at_most_partial_loss( status ) ) {
    3235    return false;
    3336  }
     
    4043    scheduler,
    4144    the_thread,
    42     cpusetsize,
    43     cpuset
     45    &affinity
    4446  );
     47
     48  if ( ok ) {
     49    _Processor_mask_Assign( &the_thread->Scheduler.Affinity, &affinity );
     50  }
    4551#else
    4652  ok = _Scheduler_default_Set_affinity_body(
    4753    scheduler,
    4854    the_thread,
    49     cpusetsize,
    50     cpuset
     55    &affinity
    5156  );
    5257#endif
  • testsuites/smptests/smpaffinity01/init.c

    r1ec9c86 r0232b28  
    6060  /* Verify rtems_task_set_affinity validates cpusetsize */
    6161  puts( "Init - rtems_task_set_affinity - Invalid cpusetsize - RTEMS_INVALID_NUMBER" );
    62   sc = rtems_task_set_affinity( Init_id,  sizeof(cpu_set_t) * 2, &cpuset );
     62  sc = rtems_task_set_affinity( Init_id,  1, &cpuset );
    6363  rtems_test_assert( sc == RTEMS_INVALID_NUMBER );
    6464
  • testsuites/smptests/smppsxaffinity02/init.c

    r1ec9c86 r0232b28  
    6767  /* Verify pthread_setaffinity_np validates cpusetsize */
    6868  puts( "Init - pthread_setaffinity_np - Invalid cpusetsize - EINVAL" );
    69   sc = pthread_setaffinity_np( Init_id,  sizeof(cpu_set_t) * 2, &cpuset );
     69  sc = pthread_setaffinity_np( Init_id,  1, &cpuset );
    7070  rtems_test_assert( sc == EINVAL );
    7171
Note: See TracChangeset for help on using the changeset viewer.