Changeset 776464a in rtems


Ignore:
Timestamp:
Sep 19, 2018, 9:52:47 AM (13 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
b3cf79b
Parents:
68f339b6
Message:

score: Allocate per-CPU data only if necessary

The _Workspace_Allocate_aligned() would returns a non-NULL pointer for a
zero size allocation request if there is enough memory available. This
conflicts with the size estimate of zero in
_Workspace_Space_for_per_CPU_data() if the per-CPU data set is empty.

Update #3507.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/src/wkspace.c

    r68f339b6 r776464a  
    130130{
    131131#ifdef RTEMS_SMP
    132   Per_CPU_Control *cpu;
    133   uintptr_t        size;
    134   uint32_t         cpu_index;
    135   uint32_t         cpu_max;
    136 
    137   cpu = _Per_CPU_Get_by_index( 0 );
    138   cpu->data = RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data );
     132  uintptr_t size;
    139133
    140134  size = RTEMS_LINKER_SET_SIZE( _Per_CPU_Data );
    141   cpu_max = rtems_configuration_get_maximum_processors();
    142 
    143   for ( cpu_index = 1 ; cpu_index < cpu_max ; ++cpu_index ) {
    144     cpu = _Per_CPU_Get_by_index( cpu_index );
    145     cpu->data = _Workspace_Allocate_aligned( size, CPU_CACHE_LINE_BYTES );
    146     _Assert( cpu->data != NULL );
    147     memcpy( cpu->data, RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ), size);
     135
     136  if ( size > 0 ) {
     137    Per_CPU_Control *cpu;
     138    uint32_t         cpu_index;
     139    uint32_t         cpu_max;
     140
     141    cpu = _Per_CPU_Get_by_index( 0 );
     142    cpu->data = RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data );
     143
     144    cpu_max = rtems_configuration_get_maximum_processors();
     145
     146    for ( cpu_index = 1 ; cpu_index < cpu_max ; ++cpu_index ) {
     147      cpu = _Per_CPU_Get_by_index( cpu_index );
     148      cpu->data = _Workspace_Allocate_aligned( size, CPU_CACHE_LINE_BYTES );
     149      _Assert( cpu->data != NULL );
     150      memcpy( cpu->data, RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ), size);
     151    }
    148152  }
    149153#endif
Note: See TracChangeset for help on using the changeset viewer.