From patchwork Wed Dec 17 15:00:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 42382 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 37C5826C8B for ; Wed, 17 Dec 2014 15:01:14 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id ex7sf6417175wid.11 for ; Wed, 17 Dec 2014 07:01:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=hr9mTCVeZbMkNI9QYVOhFhs+snPA/pRqdpQXu94Wpr4=; b=j9B0Wjjp8HJypp71N3WEivzLUHftry3roF/AlLyKmEy8R2DdQdNFtI4uVxPVx5NBY0 93Y+jPim6NpXMRuvEu6OeLGs/9tMruajFN5qIytJJWXY5lb5dOLnd8T5jwy47C7cg+tJ vC/zCVOWlk/1tjt0w/kuSw+am1SNbo67bqNZ7C9eHiU6+VOplUnqVyRbOcODm8UZ1GJx r8WVIwrA3SLG5HclrYyUeSASpFQPbs6a2103awhEqdD7AZ3jlOjfgheJy9LFVbLleR6q gwAITB/N0XPE+5HHS0/qhm+yTQBgPiApQ2McIJbsycPCAVdM361ADMH5BRePMc7Lefjx U9yA== X-Gm-Message-State: ALoCoQkkTHvV7mUu9kW7leQpzfo+SIhv4uw0DskZ8iK1zO5jwA350RIxIHhNHjuqbtZ5G8uH2d7R X-Received: by 10.112.140.137 with SMTP id rg9mr4902lbb.24.1418828473510; Wed, 17 Dec 2014 07:01:13 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.134 with SMTP id b6ls888584laa.27.gmail; Wed, 17 Dec 2014 07:01:13 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr41819422lal.29.1418828473366; Wed, 17 Dec 2014 07:01:13 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id cf4si4159590lad.21.2014.12.17.07.01.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Dec 2014 07:01:13 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so13355994lab.36 for ; Wed, 17 Dec 2014 07:01:13 -0800 (PST) X-Received: by 10.112.131.1 with SMTP id oi1mr33735488lbb.2.1418828473038; Wed, 17 Dec 2014 07:01:13 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp1390132lbb; Wed, 17 Dec 2014 07:01:12 -0800 (PST) X-Received: by 10.220.5.72 with SMTP id 8mr18332849vcu.6.1418828471551; Wed, 17 Dec 2014 07:01:11 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id ol9si1409648vcb.102.2014.12.17.07.01.09 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 17 Dec 2014 07:01:11 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y1G67-0008FR-1C; Wed, 17 Dec 2014 15:01:07 +0000 Received: from mail-la0-f54.google.com ([209.85.215.54]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y1G60-0008FM-Ai for lng-odp@lists.linaro.org; Wed, 17 Dec 2014 15:01:00 +0000 Received: by mail-la0-f54.google.com with SMTP id pv20so13210482lab.27 for ; Wed, 17 Dec 2014 07:00:54 -0800 (PST) X-Received: by 10.112.211.130 with SMTP id nc2mr22985425lbc.0.1418828454199; Wed, 17 Dec 2014 07:00:54 -0800 (PST) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id jj7sm1007021lbc.5.2014.12.17.07.00.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Dec 2014 07:00:53 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Wed, 17 Dec 2014 17:00:48 +0200 Message-Id: <1418828448-1327-1-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [RFC PATCH] linux-generic: add buffer pool termination X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: taras.kondratiuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 --- 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");