[PATCH 1/4] score: Add _CPU_Get_current_per_CPU_control()

Gedare Bloom gedare at rtems.org
Tue Apr 22 14:24:22 UTC 2014


On Tue, Apr 22, 2014 at 10:16 AM, Gedare Bloom <gedare at rtems.org> wrote:
> What is the need/use for this optimization?
>
Rather, will it be useful anywhere other than SPARC which has so many
extra registers?

> On Tue, Apr 22, 2014 at 4:46 AM, Sebastian Huber
> <sebastian.huber at embedded-brains.de> wrote:
>> Add optional method _CPU_Get_current_per_CPU_control() to obtain the
>> per-CPU control of the current processor.
>>
>> This is optional.  Not every CPU port needs this.  It is only an
>> optional optimization variant.  In case this macro is undefined, the
>> default implementation using the current processor index will be used.
>> ---
>>  cpukit/score/cpu/no_cpu/rtems/score/cpu.h |   18 ++++++++++++++++++
>>  cpukit/score/include/rtems/score/percpu.h |   10 +++++++---
>>  2 files changed, 25 insertions(+), 3 deletions(-)
>>
>> diff --git a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
>> index 5241b5b..959fb58 100644
>> --- a/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
>> +++ b/cpukit/score/cpu/no_cpu/rtems/score/cpu.h
>> @@ -1462,6 +1462,24 @@ CPU_Counter_ticks _CPU_Counter_difference(
>>    CPU_Counter_ticks first
>>  );
>>
>> +/**
>> + * @brief Special register pointing to the per-CPU control of the current
>> + * processor.
>> + *
>> + * This is optional.  Not every CPU port needs this.  It is only an optional
>> + * optimization variant.
>> + */
>> +register struct Per_CPU_Control *_CPU_Per_CPU_current asm( "rX" );
>> +
>> +/**
>> + * @brief Optional method to obtain the per-CPU control of the current processor.
>> + *
>> + * This is optional.  Not every CPU port needs this.  It is only an optional
>> + * optimization variant.  In case this macro is undefined, the default
>> + * implementation using the current processor index will be used.
>> + */
>> +#define _CPU_Get_current_per_CPU_control() ( _CPU_Per_CPU_current )
>> +
>>  #ifdef RTEMS_SMP
>>    /**
>>     * @brief Performs CPU specific SMP initialization in the context of the boot
>> diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h
>> index afc3803..a1b0a38 100644
>> --- a/cpukit/score/include/rtems/score/percpu.h
>> +++ b/cpukit/score/include/rtems/score/percpu.h
>> @@ -235,7 +235,7 @@ typedef struct {
>>   *
>>   *  This structure is used to hold per core state information.
>>   */
>> -typedef struct {
>> +typedef struct Per_CPU_Control {
>>    /**
>>     * @brief CPU port specific control.
>>     */
>> @@ -437,8 +437,12 @@ extern Per_CPU_Control_envelope _Per_CPU_Information[] CPU_STRUCTURE_ALIGNMENT;
>>   * we can use _Per_CPU_Get_snapshot()).  All other places must use
>>   * _Per_CPU_Get() so that we can add checks for RTEMS_DEBUG.
>>   */
>> -#define _Per_CPU_Get_snapshot() \
>> -  ( &_Per_CPU_Information[ _SMP_Get_current_processor() ].per_cpu )
>> +#if defined( _CPU_Get_current_per_CPU_control )
>> +  #define _Per_CPU_Get_snapshot() _CPU_Get_current_per_CPU_control()
>> +#else
>> +  #define _Per_CPU_Get_snapshot() \
>> +    ( &_Per_CPU_Information[ _SMP_Get_current_processor() ].per_cpu )
>> +#endif
>>
>>  #if defined( RTEMS_SMP )
>>  static inline Per_CPU_Control *_Per_CPU_Get( void )
>> --
>> 1.7.7
>>
>> _______________________________________________
>> rtems-devel mailing list
>> rtems-devel at rtems.org
>> http://www.rtems.org/mailman/listinfo/rtems-devel



More information about the devel mailing list