diff mbox

example: timer: clean up prescheduled events

Message ID 1429533151-15217-1-git-send-email-ola.liljedahl@linaro.org
State Accepted
Commit 07833034064c1b2be38fea3f2a1bc2dff8965ecc
Headers show

Commit Message

Ola Liljedahl April 20, 2015, 12:32 p.m. UTC
Fixes https://bugs.linaro.org/show_bug.cgi?id=1450

Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
---
(This document/code contribution attached is provided under the terms of
agreement LES-LTM-21309)

 example/timer/odp_timer_test.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

Comments

Mike Holmes April 20, 2015, 5:15 p.m. UTC | #1
I think the current patch solves the bug, there are no longer failures to
terminate threads which is a bug in the implementation.

It sounds like there is a new lower priority bug to clean out the example
which throws up EXAMPLE_ERR.

If that makes sense I am happy to add reviewed by.

On 20 April 2015 at 08:32, Ola Liljedahl <ola.liljedahl@linaro.org> wrote:

> Fixes https://bugs.linaro.org/show_bug.cgi?id=1450
>
> Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
>

Tested-


> ---
> (This document/code contribution attached is provided under the terms of
> agreement LES-LTM-21309)
>
>  example/timer/odp_timer_test.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>
> diff --git a/example/timer/odp_timer_test.c
> b/example/timer/odp_timer_test.c
> index 6b60ec4..fd31466 100644
> --- a/example/timer/odp_timer_test.c
> +++ b/example/timer/odp_timer_test.c
> @@ -79,6 +79,41 @@ struct test_timer {
>  static struct test_timer tt[256];
>
>  /** @private test timeout */
> +static void free_event(odp_event_t ev)
> +{
> +       switch (odp_event_type(ev)) {
> +       case ODP_EVENT_BUFFER:
> +               odp_buffer_free(odp_buffer_from_event(ev));
> +               break;
> +       case ODP_EVENT_PACKET:
> +               odp_packet_free(odp_packet_from_event(ev));
> +               break;
> +       case ODP_EVENT_TIMEOUT:
> +               odp_timeout_free(odp_timeout_from_event(ev));
> +               break;
> +       case ODP_EVENT_CRYPTO_COMPL:
> +               odp_crypto_compl_free(odp_crypto_compl_from_event(ev));
> +               break;
> +       default:
> +               fprintf(stderr, "Unrecognized event type %d\n",
> +                       odp_event_type(ev));
> +               abort();
> +       }
> +}
> +
> +/** @private test timeout */
> +static void remove_prescheduled_events(void)
> +{
> +       odp_event_t ev;
> +       odp_queue_t queue;
> +       odp_schedule_pause();
> +       while ((ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT)) !=
> +                       ODP_EVENT_INVALID) {
> +               free_event(ev);
> +       }
> +}
> +
> +/** @private test timeout */
>  static void test_abs_timeouts(int thr, test_args_t *args)
>  {
>         uint64_t period;
> @@ -173,6 +208,9 @@ static void test_abs_timeouts(int thr, test_args_t
> *args)
>         /* Since we have cancelled the timer, there is no timeout event to
>          * return from odp_timer_free() */
>         (void)odp_timer_free(ttp->tim);
> +
> +       /* Remove any prescheduled events */
> +       remove_prescheduled_events();
>  }
>
>
> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
Ola Liljedahl April 21, 2015, 11:14 a.m. UTC | #2
On 20 April 2015 at 19:15, Mike Holmes <mike.holmes@linaro.org> wrote:

> I think the current patch solves the bug, there are no longer failures to
> terminate threads which is a bug in the implementation.
>
> It sounds like there is a new lower priority bug to clean out the example
> which throws up EXAMPLE_ERR.
>
> If that makes sense I am happy to add reviewed by.
>
Makes sense to me.


>
> On 20 April 2015 at 08:32, Ola Liljedahl <ola.liljedahl@linaro.org> wrote:
>
>> Fixes https://bugs.linaro.org/show_bug.cgi?id=1450
>>
>> Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
>>
>
> Tested-
>
>
>> ---
>> (This document/code contribution attached is provided under the terms of
>> agreement LES-LTM-21309)
>>
>>  example/timer/odp_timer_test.c | 38
>> ++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 38 insertions(+)
>>
>> diff --git a/example/timer/odp_timer_test.c
>> b/example/timer/odp_timer_test.c
>> index 6b60ec4..fd31466 100644
>> --- a/example/timer/odp_timer_test.c
>> +++ b/example/timer/odp_timer_test.c
>> @@ -79,6 +79,41 @@ struct test_timer {
>>  static struct test_timer tt[256];
>>
>>  /** @private test timeout */
>> +static void free_event(odp_event_t ev)
>> +{
>> +       switch (odp_event_type(ev)) {
>> +       case ODP_EVENT_BUFFER:
>> +               odp_buffer_free(odp_buffer_from_event(ev));
>> +               break;
>> +       case ODP_EVENT_PACKET:
>> +               odp_packet_free(odp_packet_from_event(ev));
>> +               break;
>> +       case ODP_EVENT_TIMEOUT:
>> +               odp_timeout_free(odp_timeout_from_event(ev));
>> +               break;
>> +       case ODP_EVENT_CRYPTO_COMPL:
>> +               odp_crypto_compl_free(odp_crypto_compl_from_event(ev));
>> +               break;
>> +       default:
>> +               fprintf(stderr, "Unrecognized event type %d\n",
>> +                       odp_event_type(ev));
>> +               abort();
>> +       }
>> +}
>> +
>> +/** @private test timeout */
>> +static void remove_prescheduled_events(void)
>> +{
>> +       odp_event_t ev;
>> +       odp_queue_t queue;
>> +       odp_schedule_pause();
>> +       while ((ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT)) !=
>> +                       ODP_EVENT_INVALID) {
>> +               free_event(ev);
>> +       }
>> +}
>> +
>> +/** @private test timeout */
>>  static void test_abs_timeouts(int thr, test_args_t *args)
>>  {
>>         uint64_t period;
>> @@ -173,6 +208,9 @@ static void test_abs_timeouts(int thr, test_args_t
>> *args)
>>         /* Since we have cancelled the timer, there is no timeout event to
>>          * return from odp_timer_free() */
>>         (void)odp_timer_free(ttp->tim);
>> +
>> +       /* Remove any prescheduled events */
>> +       remove_prescheduled_events();
>>  }
>>
>>
>> --
>> 1.9.1
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
>
> --
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
>
>
>
Mike Holmes April 21, 2015, 11:30 a.m. UTC | #3
On 20 April 2015 at 08:32, Ola Liljedahl <ola.liljedahl@linaro.org> wrote:

> Fixes https://bugs.linaro.org/show_bug.cgi?id=1450
>
> Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
>

Reviewed-by: Mike Holmes <mike.holmes@linaro.org>


> ---
> (This document/code contribution attached is provided under the terms of
> agreement LES-LTM-21309)
>
>  example/timer/odp_timer_test.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
>
> diff --git a/example/timer/odp_timer_test.c
> b/example/timer/odp_timer_test.c
> index 6b60ec4..fd31466 100644
> --- a/example/timer/odp_timer_test.c
> +++ b/example/timer/odp_timer_test.c
> @@ -79,6 +79,41 @@ struct test_timer {
>  static struct test_timer tt[256];
>
>  /** @private test timeout */
> +static void free_event(odp_event_t ev)
> +{
> +       switch (odp_event_type(ev)) {
> +       case ODP_EVENT_BUFFER:
> +               odp_buffer_free(odp_buffer_from_event(ev));
> +               break;
> +       case ODP_EVENT_PACKET:
> +               odp_packet_free(odp_packet_from_event(ev));
> +               break;
> +       case ODP_EVENT_TIMEOUT:
> +               odp_timeout_free(odp_timeout_from_event(ev));
> +               break;
> +       case ODP_EVENT_CRYPTO_COMPL:
> +               odp_crypto_compl_free(odp_crypto_compl_from_event(ev));
> +               break;
> +       default:
> +               fprintf(stderr, "Unrecognized event type %d\n",
> +                       odp_event_type(ev));
> +               abort();
> +       }
> +}
> +
> +/** @private test timeout */
> +static void remove_prescheduled_events(void)
> +{
> +       odp_event_t ev;
> +       odp_queue_t queue;
> +       odp_schedule_pause();
> +       while ((ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT)) !=
> +                       ODP_EVENT_INVALID) {
> +               free_event(ev);
> +       }
> +}
> +
> +/** @private test timeout */
>  static void test_abs_timeouts(int thr, test_args_t *args)
>  {
>         uint64_t period;
> @@ -173,6 +208,9 @@ static void test_abs_timeouts(int thr, test_args_t
> *args)
>         /* Since we have cancelled the timer, there is no timeout event to
>          * return from odp_timer_free() */
>         (void)odp_timer_free(ttp->tim);
> +
> +       /* Remove any prescheduled events */
> +       remove_prescheduled_events();
>  }
>
>
> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c
index 6b60ec4..fd31466 100644
--- a/example/timer/odp_timer_test.c
+++ b/example/timer/odp_timer_test.c
@@ -79,6 +79,41 @@  struct test_timer {
 static struct test_timer tt[256];
 
 /** @private test timeout */
+static void free_event(odp_event_t ev)
+{
+	switch (odp_event_type(ev)) {
+	case ODP_EVENT_BUFFER:
+		odp_buffer_free(odp_buffer_from_event(ev));
+		break;
+	case ODP_EVENT_PACKET:
+		odp_packet_free(odp_packet_from_event(ev));
+		break;
+	case ODP_EVENT_TIMEOUT:
+		odp_timeout_free(odp_timeout_from_event(ev));
+		break;
+	case ODP_EVENT_CRYPTO_COMPL:
+		odp_crypto_compl_free(odp_crypto_compl_from_event(ev));
+		break;
+	default:
+		fprintf(stderr, "Unrecognized event type %d\n",
+			odp_event_type(ev));
+		abort();
+	}
+}
+
+/** @private test timeout */
+static void remove_prescheduled_events(void)
+{
+	odp_event_t ev;
+	odp_queue_t queue;
+	odp_schedule_pause();
+	while ((ev = odp_schedule(&queue, ODP_SCHED_NO_WAIT)) !=
+			ODP_EVENT_INVALID) {
+		free_event(ev);
+	}
+}
+
+/** @private test timeout */
 static void test_abs_timeouts(int thr, test_args_t *args)
 {
 	uint64_t period;
@@ -173,6 +208,9 @@  static void test_abs_timeouts(int thr, test_args_t *args)
 	/* Since we have cancelled the timer, there is no timeout event to
 	 * return from odp_timer_free() */
 	(void)odp_timer_free(ttp->tim);
+
+	/* Remove any prescheduled events */
+	remove_prescheduled_events();
 }