Browse Source

starpu_sched_ctx_list_task_counters_increment_all re-enters sched_ctx.c from sched policies, assume sched_ctx is write locked

Olivier Aumage 8 years ago
parent
commit
fc73abb2b5
2 changed files with 3 additions and 3 deletions
  1. 2 2
      src/core/sched_ctx.c
  2. 1 1
      src/core/sched_ctx.h

+ 2 - 2
src/core/sched_ctx.c

@@ -2262,13 +2262,14 @@ void starpu_sched_ctx_list_task_counters_reset(unsigned sched_ctx_id, int worker
 		_starpu_sched_ctx_list_pop_all_event(worker->sched_ctx_list, sched_ctx_id);
 }
 
+/* sched_ctx must be write locked when calling this function */
 void starpu_sched_ctx_list_task_counters_increment_all(struct starpu_task *task, unsigned sched_ctx_id)
 {
 	/* Note that with 1 ctx we will default to the global context,
 	   hence our counters are useless */
 	if (_starpu_get_nsched_ctxs() > 1)
 	{
-		_starpu_sched_ctx_lock_write(sched_ctx_id);
+		STARPU_SCHED_CTX_CHECK_LOCK(sched_ctx_id);
 		struct starpu_worker_collection *workers = starpu_sched_ctx_get_worker_collection(sched_ctx_id);
 		struct starpu_sched_ctx_iterator it;
 
@@ -2278,7 +2279,6 @@ void starpu_sched_ctx_list_task_counters_increment_all(struct starpu_task *task,
 			int worker = workers->get_next(workers, &it);
 			starpu_sched_ctx_list_task_counters_increment(sched_ctx_id, worker);
 		}
-		_starpu_sched_ctx_unlock_write(sched_ctx_id);
 	}
 }
 

+ 1 - 1
src/core/sched_ctx.h

@@ -270,7 +270,7 @@ static inline int _starpu_sched_ctx_check_write_locked(unsigned sched_ctx_id)
 	struct _starpu_sched_ctx *sched_ctx = _starpu_get_sched_ctx_struct(sched_ctx_id);
 	return sched_ctx->lock_write_owner == pthread_self();
 }
-#define STARPU_SCHED_CTX_CHECK_LOCK(ctx) STARPU_ASSERT(_starpu_sched_ctx_check_write_locked((ctx)))
+#define STARPU_SCHED_CTX_CHECK_LOCK(sched_ctx_id) STARPU_ASSERT(_starpu_sched_ctx_check_write_locked((sched_ctx_id)))
 
 static inline void _starpu_sched_ctx_lock_write(unsigned sched_ctx_id)
 {