Changeset a3ad4af in rtems


Ignore:
Timestamp:
Oct 10, 2017, 9:22:21 AM (18 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
b2dbb634
Parents:
db3a3de
git-author:
Sebastian Huber <sebastian.huber@…> (10/10/17 09:22:21)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/11/17 05:37:54)
Message:

posix: Validate affinity sets by the scheduler

Update #2514.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/pthreadcreate.c

    rdb3a3de ra3ad4af  
    3030#include <rtems/posix/pthreadattrimpl.h>
    3131#include <rtems/score/assert.h>
    32 #include <rtems/score/cpusetimpl.h>
    3332#include <rtems/score/threadimpl.h>
    3433#include <rtems/score/apimutex.h>
     
    171170  }
    172171
    173 #if defined(RTEMS_SMP)
    174   status = _CPU_set_Is_valid(the_attr->affinityset, the_attr->affinitysetsize);
    175   if ( !status )
    176     return EINVAL;
    177 #endif
     172  if ( the_attr->affinityset == NULL ) {
     173    return EINVAL;
     174  }
    178175
    179176  /*
     
    224221  the_thread->Life.state |= THREAD_LIFE_CHANGE_DEFERRED;
    225222
    226 #if defined(RTEMS_SMP)
    227223  _ISR_lock_ISR_disable( &lock_context );
    228224   status = _Scheduler_Set_affinity(
     
    237233     return EINVAL;
    238234   }
    239 #endif
    240235
    241236  /*
  • cpukit/score/src/schedulerpriorityaffinitysmp.c

    rdb3a3de ra3ad4af  
    2424#include <rtems/score/schedulersmpimpl.h>
    2525#include <rtems/score/schedulerprioritysmpimpl.h>
    26 #include <rtems/score/wkspace.h>
    27 #include <rtems/score/cpusetimpl.h>
    28 
    2926#include <rtems/score/priority.h>
    3027
     
    607604)
    608605{
     606  Scheduler_Context                    *context;
    609607  Scheduler_priority_affinity_SMP_Node *node;
    610608  States_Control                        current_state;
     609  Processor_mask                        my_affinity;
    611610  cpu_set_t                             cpuset;
    612   size_t                                cpusetsize;
    613 
    614   cpusetsize = sizeof( cpuset );
    615   _Processor_mask_To_cpu_set_t( affinity, cpusetsize, &cpuset );
    616   /*
    617    * Validate that the cpset meets basic requirements.
    618    */
    619   if ( !_CPU_set_Is_valid( &cpuset, cpusetsize ) ) {
     611
     612  context = _Scheduler_Get_context( scheduler );
     613  _Processor_mask_And( &my_affinity, &context->Processors, affinity );
     614
     615  if ( _Processor_mask_Count( &my_affinity ) == 0 ) {
    620616    return false;
    621617  }
    622618
     619  _Processor_mask_To_cpu_set_t( &my_affinity, sizeof( cpuset ), &cpuset );
    623620  node = _Scheduler_priority_affinity_SMP_Node_downcast( node_base );
    624621
     
    627624   * doing anything.
    628625   */
    629   if ( CPU_EQUAL_S( cpusetsize, &cpuset, node->Affinity.set ) )
     626  if ( CPU_EQUAL( &cpuset, node->Affinity.set ) )
    630627    return true;
    631628
  • testsuites/smptests/smppsxaffinity02/init.c

    rdb3a3de ra3ad4af  
    4646  cpu_set_t           cpuset;
    4747
    48   /* Verify pthread_setaffinity_np checks that all cpu's exist. */
     48  /* Verify pthread_setaffinity_np checks that more cpu's don't hurt. */
    4949  CPU_FILL(&cpuset);
    50   puts( "Init - pthread_setaffinity_np - Invalid cpu - EINVAL" );
     50  puts( "Init - pthread_setaffinity_np - Lots of cpus - SUCCESS" );
    5151  sc = pthread_setaffinity_np( Init_id, sizeof(cpu_set_t), &cpuset );
    52   rtems_test_assert( sc == EINVAL );
     52  rtems_test_assert( sc == 0 );
    5353
    5454  /* Verify pthread_setaffinity_np checks that at least one cpu is set */
  • testsuites/smptests/smppsxaffinity02/smppsxaffinity02.scn

    rdb3a3de ra3ad4af  
    1 *** SMP POSIX AFFINITY ATTRIBUTE TEST 2 ***
    2 Init - pthread_setaffinity_np - Invalid cpu - EINVAL
     1*** BEGIN OF TEST SMPPSXAFFINITY 2 ***
     2Init - pthread_setaffinity_np - Lots of cpus - SUCCESS
    33Init - pthread_setaffinity_np - no cpu - EINVAL
    44Init - pthread_setaffinity_np - Invalid thread - ESRCH
     
    1212Init - Verify Medium priority tasks
    1313Init - Create  Low priority tasks
    14 Init - Verify Medium priority tasks
     14Init - Verify Low priority tasks
    1515Init - Change affinity on Low priority tasks
    1616Init - Validate affinity on Low priority tasks
    17 *** SMP POSIX AFFINITY ATTRIBUTE TEST 2 ***
     17*** END OF TEST SMPPSXAFFINITY 2 ***
Note: See TracChangeset for help on using the changeset viewer.