[Cbe-oss-dev] [PATCH 07/11 v3]MARS: Remove api argument params structs

Yuji Mano yuji.mano at am.sony.com
Thu Sep 18 05:12:47 EST 2008


Kazunori Asayama wrote:
> Yuji Mano wrote:
>> This removes the mars_params and mars_task_params structure previously passed
>> into the mars context and mars task APIs.
>> 
>> Parameter arguments are now passed in directly.
>> 
>> Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
>> 
>> ---
>> v3:
>>  - revert v2 change and keep num_mpus_max() function but cache the result of
>>    spe_cpu_info_get (so we can use the cached spe count later if needed)
>> v2:
>>  - replace num_mpus_max() with mpu_check() that avoids calling spe_cpu_info_get
>>    multiple times
>> 
>>  include/host/mars/mars_context.h |   23 +++---------------
>>  include/host/mars/mars_task.h    |   32 +++++++------------------
>>  src/host/lib/mars_context.c      |   49 +++++++++++++++++----------------------
>>  src/host/lib/mars_task.c         |   34 +++++++++++----------------
>>  4 files changed, 50 insertions(+), 88 deletions(-)
> (snip)
>> --- a/src/host/lib/mars_context.c
>> +++ b/src/host/lib/mars_context.c
>> @@ -48,9 +48,17 @@
>>  
>>  extern struct spe_program_handle mars_kernel_entry;
>>  
>> -static int num_mpus_max(void)
>> +static uint32_t num_mpus_max(void)
>>  {
>> -	return spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
>> +	static int count = -1;
>> +
>> +	if (count < 0) {
>> +		count = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
>> +		if (count < 0)
>> +			count = 0;
>> +	}
>> +
>> +	return count;
>>  }
> 
> This doesn't seem to be thread-safe?
> 

Yes it is not thread-safe. This fix allows spe_cpu_info_get() to be called only once,
even after we allow for shared contexts and mars_initialize() may be called multiple
times.

I can fix this so that spe_cpu_info_get() gets called once per each mars_initialize()
call, but I think once we have the global shared context we still have the same
problem?

Regards,
Yuji





More information about the cbe-oss-dev mailing list