diff mbox

validation: scheduler: add missing ticketlock unlock

Message ID 1447861625-30217-1-git-send-email-stuart.haslam@linaro.org
State Accepted
Commit 0400653c51149737fd2746e7d8591b08a721339a
Headers show

Commit Message

Stuart Haslam Nov. 18, 2015, 3:47 p.m. UTC
The scheduler validation test occasionally deadlocks due to a missing
ticketlock unlock.

Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
---
 test/validation/scheduler/scheduler.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Bill Fischofer Nov. 18, 2015, 3:51 p.m. UTC | #1
On Wed, Nov 18, 2015 at 9:47 AM, Stuart Haslam <stuart.haslam@linaro.org>
wrote:

> The scheduler validation test occasionally deadlocks due to a missing

> ticketlock unlock.

>

> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>

>


Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>



> ---

>  test/validation/scheduler/scheduler.c | 15 ++++++++++-----

>  1 file changed, 10 insertions(+), 5 deletions(-)

>

> diff --git a/test/validation/scheduler/scheduler.c

> b/test/validation/scheduler/scheduler.c

> index f8effb3..2bd180c 100644

> --- a/test/validation/scheduler/scheduler.c

> +++ b/test/validation/scheduler/scheduler.c

> @@ -593,6 +593,7 @@ static void *schedule_common_(void *arg)

>         queue_context *qctx;

>         buf_contents *bctx, *bctx_cpy;

>         odp_pool_t pool;

> +       int locked;

>

>         globals = args->globals;

>         sync = args->sync;

> @@ -608,7 +609,6 @@ static void *schedule_common_(void *arg)

>                 odp_buffer_t buf, buf_cpy;

>                 odp_queue_t from = ODP_QUEUE_INVALID;

>                 int num = 0;

> -               int locked;

>

>                 odp_ticketlock_lock(&globals->lock);

>                 if (globals->buf_count == 0) {

> @@ -747,9 +747,12 @@ static void *schedule_common_(void *arg)

>         if (args->num_workers > 1)

>                 odp_barrier_wait(&globals->barrier);

>

> -       if (sync == ODP_SCHED_SYNC_ORDERED &&

> -           odp_ticketlock_trylock(&globals->lock) &&

> -           globals->buf_count_cpy > 0) {

> +       if (sync == ODP_SCHED_SYNC_ORDERED)

> +               locked = odp_ticketlock_trylock(&globals->lock);

> +       else

> +               locked = 0;

> +

> +       if (locked && globals->buf_count_cpy > 0) {

>                 odp_event_t ev;

>                 odp_queue_t pq;

>                 uint64_t seq;

> @@ -787,9 +790,11 @@ static void *schedule_common_(void *arg)

>                 }

>                 CU_ASSERT(bcount == buf_count);

>                 globals->buf_count_cpy = 0;

> -               odp_ticketlock_unlock(&globals->lock);

>         }

>

> +       if (locked)

> +               odp_ticketlock_unlock(&globals->lock);

> +

>         return NULL;

>  }

>

> --

> 2.1.1

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>
Maxim Uvarov Nov. 19, 2015, 9:57 a.m. UTC | #2
Merged,
Maxim.

On 11/18/2015 18:51, Bill Fischofer wrote:
>
>
> On Wed, Nov 18, 2015 at 9:47 AM, Stuart Haslam 
> <stuart.haslam@linaro.org <mailto:stuart.haslam@linaro.org>> wrote:
>
>     The scheduler validation test occasionally deadlocks due to a missing
>     ticketlock unlock.
>
>     Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org
>     <mailto:stuart.haslam@linaro.org>>
>
>
> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>>
>
>     ---
>      test/validation/scheduler/scheduler.c | 15 ++++++++++-----
>      1 file changed, 10 insertions(+), 5 deletions(-)
>
>     diff --git a/test/validation/scheduler/scheduler.c
>     b/test/validation/scheduler/scheduler.c
>     index f8effb3..2bd180c 100644
>     --- a/test/validation/scheduler/scheduler.c
>     +++ b/test/validation/scheduler/scheduler.c
>     @@ -593,6 +593,7 @@ static void *schedule_common_(void *arg)
>             queue_context *qctx;
>             buf_contents *bctx, *bctx_cpy;
>             odp_pool_t pool;
>     +       int locked;
>
>             globals = args->globals;
>             sync = args->sync;
>     @@ -608,7 +609,6 @@ static void *schedule_common_(void *arg)
>                     odp_buffer_t buf, buf_cpy;
>                     odp_queue_t from = ODP_QUEUE_INVALID;
>                     int num = 0;
>     -               int locked;
>
>     odp_ticketlock_lock(&globals->lock);
>                     if (globals->buf_count == 0) {
>     @@ -747,9 +747,12 @@ static void *schedule_common_(void *arg)
>             if (args->num_workers > 1)
>     odp_barrier_wait(&globals->barrier);
>
>     -       if (sync == ODP_SCHED_SYNC_ORDERED &&
>     -           odp_ticketlock_trylock(&globals->lock) &&
>     -           globals->buf_count_cpy > 0) {
>     +       if (sync == ODP_SCHED_SYNC_ORDERED)
>     +               locked = odp_ticketlock_trylock(&globals->lock);
>     +       else
>     +               locked = 0;
>     +
>     +       if (locked && globals->buf_count_cpy > 0) {
>                     odp_event_t ev;
>                     odp_queue_t pq;
>                     uint64_t seq;
>     @@ -787,9 +790,11 @@ static void *schedule_common_(void *arg)
>                     }
>                     CU_ASSERT(bcount == buf_count);
>                     globals->buf_count_cpy = 0;
>     -  odp_ticketlock_unlock(&globals->lock);
>             }
>
>     +       if (locked)
>     +  odp_ticketlock_unlock(&globals->lock);
>     +
>             return NULL;
>      }
>
>     --
>     2.1.1
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c
index f8effb3..2bd180c 100644
--- a/test/validation/scheduler/scheduler.c
+++ b/test/validation/scheduler/scheduler.c
@@ -593,6 +593,7 @@  static void *schedule_common_(void *arg)
 	queue_context *qctx;
 	buf_contents *bctx, *bctx_cpy;
 	odp_pool_t pool;
+	int locked;
 
 	globals = args->globals;
 	sync = args->sync;
@@ -608,7 +609,6 @@  static void *schedule_common_(void *arg)
 		odp_buffer_t buf, buf_cpy;
 		odp_queue_t from = ODP_QUEUE_INVALID;
 		int num = 0;
-		int locked;
 
 		odp_ticketlock_lock(&globals->lock);
 		if (globals->buf_count == 0) {
@@ -747,9 +747,12 @@  static void *schedule_common_(void *arg)
 	if (args->num_workers > 1)
 		odp_barrier_wait(&globals->barrier);
 
-	if (sync == ODP_SCHED_SYNC_ORDERED &&
-	    odp_ticketlock_trylock(&globals->lock) &&
-	    globals->buf_count_cpy > 0) {
+	if (sync == ODP_SCHED_SYNC_ORDERED)
+		locked = odp_ticketlock_trylock(&globals->lock);
+	else
+		locked = 0;
+
+	if (locked && globals->buf_count_cpy > 0) {
 		odp_event_t ev;
 		odp_queue_t pq;
 		uint64_t seq;
@@ -787,9 +790,11 @@  static void *schedule_common_(void *arg)
 		}
 		CU_ASSERT(bcount == buf_count);
 		globals->buf_count_cpy = 0;
-		odp_ticketlock_unlock(&globals->lock);
 	}
 
+	if (locked)
+		odp_ticketlock_unlock(&globals->lock);
+
 	return NULL;
 }