diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-19 11:52:47 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-19 11:52:47 +0200 |
commit | 776464aad46cd317b9707870acc5f6be5531e15a (patch) | |
tree | 64bad3a04e29630a0795c22faa63c9c0ae5e9aed /cpukit | |
parent | Remove CONFIGURE_HAS_OWN_CONFIGURATION_TABLE (diff) | |
download | rtems-776464aad46cd317b9707870acc5f6be5531e15a.tar.bz2 |
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.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/score/src/wkspace.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/cpukit/score/src/wkspace.c b/cpukit/score/src/wkspace.c index 823e357009..ea2ab84849 100644 --- a/cpukit/score/src/wkspace.c +++ b/cpukit/score/src/wkspace.c @@ -129,22 +129,26 @@ static uintptr_t _Workspace_Space_for_per_CPU_data( uintptr_t page_size ) static void _Workspace_Allocate_per_CPU_data( void ) { #ifdef RTEMS_SMP - Per_CPU_Control *cpu; - uintptr_t size; - uint32_t cpu_index; - uint32_t cpu_max; - - cpu = _Per_CPU_Get_by_index( 0 ); - cpu->data = RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ); + uintptr_t size; size = RTEMS_LINKER_SET_SIZE( _Per_CPU_Data ); - cpu_max = rtems_configuration_get_maximum_processors(); - for ( cpu_index = 1 ; cpu_index < cpu_max ; ++cpu_index ) { - cpu = _Per_CPU_Get_by_index( cpu_index ); - cpu->data = _Workspace_Allocate_aligned( size, CPU_CACHE_LINE_BYTES ); - _Assert( cpu->data != NULL ); - memcpy( cpu->data, RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ), size); + if ( size > 0 ) { + Per_CPU_Control *cpu; + uint32_t cpu_index; + uint32_t cpu_max; + + cpu = _Per_CPU_Get_by_index( 0 ); + cpu->data = RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ); + + cpu_max = rtems_configuration_get_maximum_processors(); + + for ( cpu_index = 1 ; cpu_index < cpu_max ; ++cpu_index ) { + cpu = _Per_CPU_Get_by_index( cpu_index ); + cpu->data = _Workspace_Allocate_aligned( size, CPU_CACHE_LINE_BYTES ); + _Assert( cpu->data != NULL ); + memcpy( cpu->data, RTEMS_LINKER_SET_BEGIN( _Per_CPU_Data ), size); + } } #endif } |