[Cbe-oss-dev] [PATCH 4/10 v2] MARS: task barrier fix notify

Kazunori Asayama asayama at sm.sony.co.jp
Mon Sep 1 12:46:25 EST 2008


Yuji Mano wrote:
> This fixes a bug in task barrier's notify function so it only sends a signal to
> workload id's that are in the wait list.
> 
> This also fixes a bug where the barrier count was not being properly reset once
> the barrier is released.
> 
> Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>

(snip)

> @@ -74,13 +75,19 @@ int mars_task_barrier_notify(uint64_t ba
>  
>  	mars_mutex_lock_get(barrier_ea, (struct mars_mutex *)&barrier);
>  
> -	/* set the necessary bits */
> -	barrier.count++;
> +	/* check if barrier notify limit reached */
> +	MARS_CHECK_CLEANUP_RET(barrier.notified_count < barrier.total,
> +		mars_mutex_unlock_put(barrier_ea,
> +				(struct mars_mutex *)&barrier),
> +		MARS_ERROR_LIMIT);
>  
> -	/* barrier count reached total so release barrier */
> -	if (barrier.count == barrier.total) {
> +	/* increment notified count */
> +	barrier.notified_count++;

(snip)

> @@ -130,6 +139,12 @@ int mars_task_barrier_wait(uint64_t barr
>  		return MARS_SUCCESS;
>  	}
>  
> +	/* all tasks have called wait so reset barrier */
> +	if (barrier.waited_count == barrier.total) {
> +		barrier.notified_count = 0;
> +		barrier.waited_count = 0;
> +	}
> +
>  	mars_mutex_unlock_put(barrier_ea, (struct mars_mutex *)&barrier);
>  
>  	return MARS_SUCCESS;

The tasks with barrier.waited_count != barrier.total can call the next
mars_task_barrier_notify before the counters are reset, and that causes
a MARS_ERROR_LIMIT error. So we should:

  a. delay returning from mars_task_barrier_wait until all tasks finish
     the current wait.

     or

  b. block mars_task_barrier_notify until all tasks finish the previous
     wait.

-- 
(ASAYAMA Kazunori
  (asayama at sm.sony.co.jp))
t



More information about the cbe-oss-dev mailing list