diff mbox

[PATCHv2] linux-generic: pktio: handle transient output queue nonempty conditions

Message ID 1459605169-1563-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit 9b5192b36717e3c9fbdcf644e08cf5f22d07689b
Headers show

Commit Message

Bill Fischofer April 2, 2016, 1:52 p.m. UTC
Out queues should be empty. Add an assert to verify this to ensure
that memory is not leaked as part of destroy_out_queues(). This addresses
bug https://bugs.linaro.org/show_bug.cgi?id=2089

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
Changes for v2:

Switch to ODP_ASSERT() rather than risk looping in the unlikely event that
an output queue is non-empty. This prevents the memory leak while catching
the bug condition that would have resulted in the leak without this check.

 platform/linux-generic/odp_packet_io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Maxim Uvarov April 4, 2016, 8:02 p.m. UTC | #1
In other termination code we have ODP_ERR().  For mostly all things 
which is called from odp_term_global.
But I like current ASSERT() more but it's more easy to debug that code 
and clean up such things then follow
bunch of error debug prints. If no objections I'm going to apply this 
simple patch.

Maxim.

On 04/02/16 16:52, Bill Fischofer wrote:
> Out queues should be empty. Add an assert to verify this to ensure
> that memory is not leaked as part of destroy_out_queues(). This addresses
> bug https://bugs.linaro.org/show_bug.cgi?id=2089
>
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
> Changes for v2:
>
> Switch to ODP_ASSERT() rather than risk looping in the unlikely event that
> an output queue is non-empty. This prevents the memory leak while catching
> the bug condition that would have resulted in the leak without this check.
>
>   platform/linux-generic/odp_packet_io.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
> index 9192be2..7b1b137 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -296,11 +296,12 @@ static void destroy_in_queues(pktio_entry_t *entry, int num)
>   
>   static void destroy_out_queues(pktio_entry_t *entry, int num)
>   {
> -	int i;
> +	int i, rc;
>   
>   	for (i = 0; i < num; i++) {
>   		if (entry->s.out_queue[i].queue != ODP_QUEUE_INVALID) {
> -			odp_queue_destroy(entry->s.out_queue[i].queue);
> +			rc = odp_queue_destroy(entry->s.out_queue[i].queue);
> +			ODP_ASSERT(rc == 0);
>   			entry->s.out_queue[i].queue = ODP_QUEUE_INVALID;
>   		}
>   	}
Bill Fischofer April 14, 2016, 12:50 p.m. UTC | #2
ping.  This still needs a merge.

On Mon, Apr 4, 2016 at 3:02 PM, Maxim Uvarov <maxim.uvarov@linaro.org>
wrote:

> In other termination code we have ODP_ERR().  For mostly all things which

> is called from odp_term_global.

> But I like current ASSERT() more but it's more easy to debug that code and

> clean up such things then follow

> bunch of error debug prints. If no objections I'm going to apply this

> simple patch.

>

> Maxim.

>

>

> On 04/02/16 16:52, Bill Fischofer wrote:

>

>> Out queues should be empty. Add an assert to verify this to ensure

>> that memory is not leaked as part of destroy_out_queues(). This addresses

>> bug https://bugs.linaro.org/show_bug.cgi?id=2089

>>

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

>> ---

>> Changes for v2:

>>

>> Switch to ODP_ASSERT() rather than risk looping in the unlikely event that

>> an output queue is non-empty. This prevents the memory leak while catching

>> the bug condition that would have resulted in the leak without this check.

>>

>>   platform/linux-generic/odp_packet_io.c | 5 +++--

>>   1 file changed, 3 insertions(+), 2 deletions(-)

>>

>> diff --git a/platform/linux-generic/odp_packet_io.c

>> b/platform/linux-generic/odp_packet_io.c

>> index 9192be2..7b1b137 100644

>> --- a/platform/linux-generic/odp_packet_io.c

>> +++ b/platform/linux-generic/odp_packet_io.c

>> @@ -296,11 +296,12 @@ static void destroy_in_queues(pktio_entry_t *entry,

>> int num)

>>     static void destroy_out_queues(pktio_entry_t *entry, int num)

>>   {

>> -       int i;

>> +       int i, rc;

>>         for (i = 0; i < num; i++) {

>>                 if (entry->s.out_queue[i].queue != ODP_QUEUE_INVALID) {

>> -                       odp_queue_destroy(entry->s.out_queue[i].queue);

>> +                       rc =

>> odp_queue_destroy(entry->s.out_queue[i].queue);

>> +                       ODP_ASSERT(rc == 0);

>>                         entry->s.out_queue[i].queue = ODP_QUEUE_INVALID;

>>                 }

>>         }

>>

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

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

>
Maxim Uvarov April 22, 2016, 8:46 p.m. UTC | #3
Merged.

Maxim.

On 04/14/16 15:50, Bill Fischofer wrote:
> ping.  This still needs a merge.
>
> On Mon, Apr 4, 2016 at 3:02 PM, Maxim Uvarov <maxim.uvarov@linaro.org 
> <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     In other termination code we have ODP_ERR().  For mostly all
>     things which is called from odp_term_global.
>     But I like current ASSERT() more but it's more easy to debug that
>     code and clean up such things then follow
>     bunch of error debug prints. If no objections I'm going to apply
>     this simple patch.
>
>     Maxim.
>
>
>     On 04/02/16 16:52, Bill Fischofer wrote:
>
>         Out queues should be empty. Add an assert to verify this to ensure
>         that memory is not leaked as part of destroy_out_queues().
>         This addresses
>         bug https://bugs.linaro.org/show_bug.cgi?id=2089
>
>         Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org
>         <mailto:bill.fischofer@linaro.org>>
>         ---
>         Changes for v2:
>
>         Switch to ODP_ASSERT() rather than risk looping in the
>         unlikely event that
>         an output queue is non-empty. This prevents the memory leak
>         while catching
>         the bug condition that would have resulted in the leak without
>         this check.
>
>           platform/linux-generic/odp_packet_io.c | 5 +++--
>           1 file changed, 3 insertions(+), 2 deletions(-)
>
>         diff --git a/platform/linux-generic/odp_packet_io.c
>         b/platform/linux-generic/odp_packet_io.c
>         index 9192be2..7b1b137 100644
>         --- a/platform/linux-generic/odp_packet_io.c
>         +++ b/platform/linux-generic/odp_packet_io.c
>         @@ -296,11 +296,12 @@ static void
>         destroy_in_queues(pktio_entry_t *entry, int num)
>             static void destroy_out_queues(pktio_entry_t *entry, int num)
>           {
>         -       int i;
>         +       int i, rc;
>                 for (i = 0; i < num; i++) {
>                         if (entry->s.out_queue[i].queue !=
>         ODP_QUEUE_INVALID) {
>         -  odp_queue_destroy(entry->s.out_queue[i].queue);
>         +                       rc =
>         odp_queue_destroy(entry->s.out_queue[i].queue);
>         +                       ODP_ASSERT(rc == 0);
>                                 entry->s.out_queue[i].queue =
>         ODP_QUEUE_INVALID;
>                         }
>                 }
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 9192be2..7b1b137 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -296,11 +296,12 @@  static void destroy_in_queues(pktio_entry_t *entry, int num)
 
 static void destroy_out_queues(pktio_entry_t *entry, int num)
 {
-	int i;
+	int i, rc;
 
 	for (i = 0; i < num; i++) {
 		if (entry->s.out_queue[i].queue != ODP_QUEUE_INVALID) {
-			odp_queue_destroy(entry->s.out_queue[i].queue);
+			rc = odp_queue_destroy(entry->s.out_queue[i].queue);
+			ODP_ASSERT(rc == 0);
 			entry->s.out_queue[i].queue = ODP_QUEUE_INVALID;
 		}
 	}