From patchwork Sat Feb 20 08:35:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 62450 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp225201lbl; Sat, 20 Feb 2016 00:36:58 -0800 (PST) X-Received: by 10.140.19.52 with SMTP id 49mr21736891qgg.103.1455957417931; Sat, 20 Feb 2016 00:36:57 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 32si7662188qgf.17.2016.02.20.00.36.57; Sat, 20 Feb 2016 00:36:57 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 82C2061973; Sat, 20 Feb 2016 08:36:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id B713B675D0; Sat, 20 Feb 2016 08:35:33 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 20A2665116; Sat, 20 Feb 2016 08:35:28 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id F418765105 for ; Sat, 20 Feb 2016 08:35:24 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id j78so67416857lfb.1 for ; Sat, 20 Feb 2016 00:35:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jR8JQSc4m8iZOOtxY2/UNZUjS81SZzW3LrD3F54OKUc=; b=Kjv87jK78CN+AEKDEYcanme3bXihjMwkzRfe0IAjYZHVsKT75E33t8amx5r+1fk9fX iz2KNWKMElyp2kt/yCXqi5FPYME9OU7hZvUD9FTDWeiCulgtcM58bHwKqsFWOMZTKNge 9R1sAnkielipnRAGSGg13BO7P7futsgCgdj/0Cw7N5/CPI+Dl2YAdxUhQiT/H5JMHh8h zPzHAU91lSLdYzCbYwPOqyIBQL76g3Xl9xmvoqweZXkTmEktr2latmcX45OXJyq8ALFT r8bb4jRHWhPRlE2Es4/Zg2JAXFpZf+0vjGLDoUhaP4xiiGlQBGhI90XiyWQQU/tGaWqv xVRQ== X-Gm-Message-State: AG10YOR1IZJImuqy/XXr8QhEFzj21tCmiwuiHf9WpD3TO2TOtTBz07oxqDmURyiHvzuEjjAmS8A= X-Received: by 10.25.28.209 with SMTP id c200mr5752855lfc.29.1455957323966; Sat, 20 Feb 2016 00:35:23 -0800 (PST) Received: from localhost.localdomain (ppp91-76-173-134.pppoe.mtu-net.ru. [91.76.173.134]) by smtp.gmail.com with ESMTPSA id 34sm1994206lfv.35.2016.02.20.00.35.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Feb 2016 00:35:23 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Sat, 20 Feb 2016 11:35:17 +0300 Message-Id: <1455957318-9392-3-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 In-Reply-To: <1455957318-9392-1-git-send-email-maxim.uvarov@linaro.org> References: <1455957318-9392-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 2/3] performance: scheduling: cleanly destroy resources X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" Signed-off-by: Maxim Uvarov --- test/performance/odp_scheduling.c | 52 ++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 1f6d62d..a95df15 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -806,13 +806,15 @@ int main(int argc, char *argv[]) int num_workers; odp_cpumask_t cpumask; odp_pool_t pool; - odp_queue_t queue; + odp_queue_t plain_queue; int i, j; int prios; odp_shm_t shm; test_globals_t *globals; char cpumaskstr[ODP_CPUMASK_STR_SIZE]; odp_pool_param_t params; + int ret = 0; + char name[] = "sched_XX_YY"; printf("\nODP example starts\n\n"); @@ -872,14 +874,12 @@ int main(int argc, char *argv[]) shm = odp_shm_reserve("test_globals", sizeof(test_globals_t), ODP_CACHE_LINE_SIZE, 0); - - globals = odp_shm_addr(shm); - - if (globals == NULL) { + if (shm == ODP_SHM_INVALID) { LOG_ERR("Shared memory reserve failed.\n"); return -1; } + globals = odp_shm_addr(shm); memset(globals, 0, sizeof(test_globals_t)); /* @@ -904,9 +904,9 @@ int main(int argc, char *argv[]) /* * Create a queue for plain queue test */ - queue = odp_queue_create("plain_queue", NULL); + plain_queue = odp_queue_create("plain_queue", NULL); - if (queue == ODP_QUEUE_INVALID) { + if (plain_queue == ODP_QUEUE_INVALID) { LOG_ERR("Plain queue create failed.\n"); return -1; } @@ -917,12 +917,12 @@ int main(int argc, char *argv[]) prios = odp_schedule_num_prio(); for (i = 0; i < prios; i++) { - if (i != ODP_SCHED_PRIO_HIGHEST && - i != ODP_SCHED_PRIO_LOWEST) - continue; - + odp_queue_t queue; odp_queue_param_t param; - char name[] = "sched_XX_YY"; + + if (i != ODP_SCHED_PRIO_HIGHEST && + i != ODP_SCHED_PRIO_LOWEST) + continue; name[6] = '0' + i/10; name[7] = '0' + i - 10*(i/10); @@ -952,7 +952,6 @@ int main(int argc, char *argv[]) odp_barrier_init(&globals->barrier, num_workers); if (args.proc_mode) { - int ret; odph_linux_process_t proc[MAX_WORKERS]; /* Fork worker processes */ @@ -983,5 +982,30 @@ int main(int argc, char *argv[]) printf("ODP example complete\n\n"); } - return 0; + for (i = 0; i < prios; i++) { + odp_queue_t queue; + + if (i != ODP_SCHED_PRIO_HIGHEST && + i != ODP_SCHED_PRIO_LOWEST) + continue; + + name[6] = '0' + i / 10; + name[7] = '0' + i - 10 * (i / 10); + + for (j = 0; j < QUEUES_PER_PRIO; j++) { + name[9] = '0' + j / 10; + name[10] = '0' + j - 10 * (j / 10); + + queue = odp_queue_lookup(name); + odp_queue_destroy(queue); + } + } + + odp_shm_free(shm); + odp_queue_destroy(plain_queue); + odp_pool_destroy(pool); + odp_term_local(); + odp_term_global(); + + return ret; }