diff mbox

[API-NEXT,PATCHv2] linux-generic: pool: reset origin_qe on buffer allocation

Message ID 1480547328-24996-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit bacd73a34768ce859f8136f29bda70bbccbdb45e
Headers show

Commit Message

Bill Fischofer Nov. 30, 2016, 11:08 p.m. UTC
Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2622 by
re-initializing origin_qe to NULL when a buffer is allocated. This step
was omitted in the switch to ring pool allocation introduced in
commit ID c8cf1d87783d4b4c628f219803b78731b8d4ade4

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

---
Changes in v2:
- Review comments from Maxim. Move init to earlier loops for completeness and
  efficiency.

 platform/linux-generic/odp_pool.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

-- 
2.7.4

Comments

Yi He Dec. 1, 2016, 3:25 a.m. UTC | #1
yes, I agree this fix can help pass make check in recent development and
future bisect maybe.

Reviewed-and-tested-by: Yi He <yi.he@linaro.org>

On 1 December 2016 at 07:08, Bill Fischofer <bill.fischofer@linaro.org>
wrote:

> Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2622 by

> re-initializing origin_qe to NULL when a buffer is allocated. This step

> was omitted in the switch to ring pool allocation introduced in

> commit ID c8cf1d87783d4b4c628f219803b78731b8d4ade4

>

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

> ---

> Changes in v2:

> - Review comments from Maxim. Move init to earlier loops for completeness

> and

>   efficiency.

>

>  platform/linux-generic/odp_pool.c | 17 ++++++++++-------

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

>

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

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

> index 4be3827..8c38c93 100644

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

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

> @@ -588,6 +588,7 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t

> buf[],

>         uint32_t mask, i;

>         pool_cache_t *cache;

>         uint32_t cache_num, num_ch, num_deq, burst;

> +       odp_buffer_hdr_t *hdr;

>

>         ring  = &pool->ring.hdr;

>         mask  = pool->ring_mask;

> @@ -608,8 +609,13 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t

> buf[],

>         }

>

>         /* Get buffers from the cache */

> -       for (i = 0; i < num_ch; i++)

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

>                 buf[i] = cache->buf[cache_num - num_ch + i];

> +               hdr = buf_hdl_to_hdr(buf[i]);

> +               hdr->origin_qe = NULL;

> +               if (buf_hdr)

> +                       buf_hdr[i] = hdr;

> +       }

>

>         /* If needed, get more from the global pool */

>         if (odp_unlikely(num_deq)) {

> @@ -629,9 +635,11 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t

> buf[],

>                         uint32_t idx = num_ch + i;

>

>                         buf[idx] = (odp_buffer_t)(uintptr_t)data[i];

> +                       hdr = buf_hdl_to_hdr(buf[idx]);

> +                       hdr->origin_qe = NULL;

>

>                         if (buf_hdr) {

> -                               buf_hdr[idx] = buf_hdl_to_hdr(buf[idx]);

> +                               buf_hdr[idx] = hdr;

>                                 /* Prefetch newly allocated and soon to be

> used

>                                  * buffer headers. */

>                                 odp_prefetch(buf_hdr[idx]);

> @@ -648,11 +656,6 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t

> buf[],

>                 cache->num = cache_num - num_ch;

>         }

>

> -       if (buf_hdr) {

> -               for (i = 0; i < num_ch; i++)

> -                       buf_hdr[i] = buf_hdl_to_hdr(buf[i]);

> -       }

> -

>         return num_ch + num_deq;

>  }

>

> --

> 2.7.4

>

>
Maxim Uvarov Dec. 1, 2016, 10:06 p.m. UTC | #2
Merged,
Maxim.

On 12/01/16 06:25, Yi He wrote:
> yes, I agree this fix can help pass make check in recent development and

> future bisect maybe.

> 

> Reviewed-and-tested-by: Yi He <yi.he@linaro.org>

> 

> On 1 December 2016 at 07:08, Bill Fischofer <bill.fischofer@linaro.org>

> wrote:

> 

>> Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2622 by

>> re-initializing origin_qe to NULL when a buffer is allocated. This step

>> was omitted in the switch to ring pool allocation introduced in

>> commit ID c8cf1d87783d4b4c628f219803b78731b8d4ade4

>>

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

>> ---

>> Changes in v2:

>> - Review comments from Maxim. Move init to earlier loops for completeness

>> and

>>   efficiency.

>>

>>  platform/linux-generic/odp_pool.c | 17 ++++++++++-------

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

>>

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

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

>> index 4be3827..8c38c93 100644

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

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

>> @@ -588,6 +588,7 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t

>> buf[],

>>         uint32_t mask, i;

>>         pool_cache_t *cache;

>>         uint32_t cache_num, num_ch, num_deq, burst;

>> +       odp_buffer_hdr_t *hdr;

>>

>>         ring  = &pool->ring.hdr;

>>         mask  = pool->ring_mask;

>> @@ -608,8 +609,13 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t

>> buf[],

>>         }

>>

>>         /* Get buffers from the cache */

>> -       for (i = 0; i < num_ch; i++)

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

>>                 buf[i] = cache->buf[cache_num - num_ch + i];

>> +               hdr = buf_hdl_to_hdr(buf[i]);

>> +               hdr->origin_qe = NULL;

>> +               if (buf_hdr)

>> +                       buf_hdr[i] = hdr;

>> +       }

>>

>>         /* If needed, get more from the global pool */

>>         if (odp_unlikely(num_deq)) {

>> @@ -629,9 +635,11 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t

>> buf[],

>>                         uint32_t idx = num_ch + i;

>>

>>                         buf[idx] = (odp_buffer_t)(uintptr_t)data[i];

>> +                       hdr = buf_hdl_to_hdr(buf[idx]);

>> +                       hdr->origin_qe = NULL;

>>

>>                         if (buf_hdr) {

>> -                               buf_hdr[idx] = buf_hdl_to_hdr(buf[idx]);

>> +                               buf_hdr[idx] = hdr;

>>                                 /* Prefetch newly allocated and soon to be

>> used

>>                                  * buffer headers. */

>>                                 odp_prefetch(buf_hdr[idx]);

>> @@ -648,11 +656,6 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t

>> buf[],

>>                 cache->num = cache_num - num_ch;

>>         }

>>

>> -       if (buf_hdr) {

>> -               for (i = 0; i < num_ch; i++)

>> -                       buf_hdr[i] = buf_hdl_to_hdr(buf[i]);

>> -       }

>> -

>>         return num_ch + num_deq;

>>  }

>>

>> --

>> 2.7.4

>>

>>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c
index 4be3827..8c38c93 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -588,6 +588,7 @@  int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[],
 	uint32_t mask, i;
 	pool_cache_t *cache;
 	uint32_t cache_num, num_ch, num_deq, burst;
+	odp_buffer_hdr_t *hdr;
 
 	ring  = &pool->ring.hdr;
 	mask  = pool->ring_mask;
@@ -608,8 +609,13 @@  int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[],
 	}
 
 	/* Get buffers from the cache */
-	for (i = 0; i < num_ch; i++)
+	for (i = 0; i < num_ch; i++) {
 		buf[i] = cache->buf[cache_num - num_ch + i];
+		hdr = buf_hdl_to_hdr(buf[i]);
+		hdr->origin_qe = NULL;
+		if (buf_hdr)
+			buf_hdr[i] = hdr;
+	}
 
 	/* If needed, get more from the global pool */
 	if (odp_unlikely(num_deq)) {
@@ -629,9 +635,11 @@  int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[],
 			uint32_t idx = num_ch + i;
 
 			buf[idx] = (odp_buffer_t)(uintptr_t)data[i];
+			hdr = buf_hdl_to_hdr(buf[idx]);
+			hdr->origin_qe = NULL;
 
 			if (buf_hdr) {
-				buf_hdr[idx] = buf_hdl_to_hdr(buf[idx]);
+				buf_hdr[idx] = hdr;
 				/* Prefetch newly allocated and soon to be used
 				 * buffer headers. */
 				odp_prefetch(buf_hdr[idx]);
@@ -648,11 +656,6 @@  int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[],
 		cache->num = cache_num - num_ch;
 	}
 
-	if (buf_hdr) {
-		for (i = 0; i < num_ch; i++)
-			buf_hdr[i] = buf_hdl_to_hdr(buf[i]);
-	}
-
 	return num_ch + num_deq;
 }