This patch doesn't apply to the current tip.

Bill

On Wed, Dec 17, 2014 at 9:00 AM, Taras Kondratiuk <
[email protected]> wrote:
>
> Buffer pool terminate throws an error in case of any pool still exist
> at ODP global termination stage.
>
> Based on "api: init: add a way to determine a last ODP thread termination"
> patch.
>
> Signed-off-by: Taras Kondratiuk <[email protected]>
> ---
>  platform/linux-generic/include/odp_internal.h |  2 ++
>  platform/linux-generic/odp_buffer_pool.c      | 37
> +++++++++++++++++++++++++--
>  platform/linux-generic/odp_init.c             | 10 +++++++-
>  platform/linux-generic/odp_linux.c            |  1 -
>  4 files changed, 46 insertions(+), 4 deletions(-)
>
> diff --git a/platform/linux-generic/include/odp_internal.h
> b/platform/linux-generic/include/odp_internal.h
> index 549d406..4fc8a5e 100644
> --- a/platform/linux-generic/include/odp_internal.h
> +++ b/platform/linux-generic/include/odp_internal.h
> @@ -29,6 +29,8 @@ int odp_shm_init_global(void);
>  int odp_shm_init_local(void);
>
>  int odp_buffer_pool_init_global(void);
> +int odp_buffer_pool_term_global(void);
> +int odp_buffer_pool_term_local(void);
>
>  int odp_pktio_init_global(void);
>  int odp_pktio_init_local(void);
> diff --git a/platform/linux-generic/odp_buffer_pool.c
> b/platform/linux-generic/odp_buffer_pool.c
> index e947dde..c19e980 100644
> --- a/platform/linux-generic/odp_buffer_pool.c
> +++ b/platform/linux-generic/odp_buffer_pool.c
> @@ -52,6 +52,7 @@ typedef struct pool_table_t {
>
>  /* The pool table */
>  static pool_table_t *pool_tbl;
> +static const char shm_name[] = "odp_buffer_pools";
>
>  /* Pool entry pointers (for inlining) */
>  void *pool_entry_ptr[ODP_CONFIG_BUFFER_POOLS];
> @@ -64,7 +65,7 @@ int odp_buffer_pool_init_global(void)
>         uint32_t i;
>         odp_shm_t shm;
>
> -       shm = odp_shm_reserve("odp_buffer_pools",
> +       shm = odp_shm_reserve(shm_name,
>                               sizeof(pool_table_t),
>                               sizeof(pool_entry_t), 0);
>
> @@ -92,10 +93,42 @@ int odp_buffer_pool_init_global(void)
>         return 0;
>  }
>
> +int odp_buffer_pool_term_global(void)
> +{
> +       odp_shm_t shm;
> +       int i;
> +       pool_entry_t *pool;
> +       int ret = 0;
> +
> +       for (i = 0; i < ODP_CONFIG_BUFFER_POOLS; i++) {
> +               pool = get_pool_entry(i);
> +
> +               POOL_LOCK(&pool->s.lock);
> +               if (pool->s.pool_shm != ODP_SHM_INVALID) {
> +                       ODP_ERR("Not destroyed pool: %s\n", pool->s.name);
> +                       ret = -1;
> +               }
> +               POOL_UNLOCK(&pool->s.lock);
> +       }
> +       if (ret)
> +               return ret;
> +
> +       shm = odp_shm_lookup(shm_name);
> +       if (shm == ODP_SHM_INVALID)
> +               return -1;
> +       ret = odp_shm_free(shm);
> +
> +       return ret;
> +}
> +
> +int odp_buffer_pool_term_local(void)
> +{
> +       _odp_flush_caches();
> +       return 0;
> +}
>  /**
>   * Buffer pool creation
>   */
> -
>  odp_buffer_pool_t odp_buffer_pool_create(const char *name,
>                                          odp_shm_t shm,
>                                          odp_buffer_pool_param_t *params)
> diff --git a/platform/linux-generic/odp_init.c
> b/platform/linux-generic/odp_init.c
> index 6c2fc8c..193cc52 100644
> --- a/platform/linux-generic/odp_init.c
> +++ b/platform/linux-generic/odp_init.c
> @@ -64,7 +64,10 @@ int odp_init_global(odp_init_t *params  ODP_UNUSED,
>
>  int odp_term_global(void)
>  {
> -       ODP_UNIMPLEMENTED();
> +       if (odp_buffer_pool_term_global()) {
> +               ODP_ERR("ODP buffer pool term failed.\n");
> +               return -1;
> +       }
>         return 0;
>  }
>
> @@ -90,6 +93,11 @@ int odp_init_local(void)
>
>  int odp_term_local(void)
>  {
> +       if (odp_buffer_pool_term_local()) {
> +               ODP_ERR("ODP buffer pool local term failed.\n");
> +               return -1;
> +       }
> +
>         if (odp_thread_term_local() == 0)
>                 return 1;
>
> diff --git a/platform/linux-generic/odp_linux.c
> b/platform/linux-generic/odp_linux.c
> index 229d24e..92b8d53 100644
> --- a/platform/linux-generic/odp_linux.c
> +++ b/platform/linux-generic/odp_linux.c
> @@ -44,7 +44,6 @@ static void *odp_run_start_routine(void *arg)
>         }
>
>         void *ret_ptr = start_args->start_routine(start_args->arg);
> -       _odp_flush_caches();
>         int ret = odp_term_local();
>         if (ret < 0)
>                 ODP_ERR("Local term failed\n");
> --
> 1.9.1
>
>
> _______________________________________________
> lng-odp mailing list
> [email protected]
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to