From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 181A9A0528; Thu, 9 Jul 2020 15:49:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4FC5B1E93A; Thu, 9 Jul 2020 15:48:55 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 5CB8B1E924 for ; Thu, 9 Jul 2020 15:48:50 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200709134849euoutp02d43038f23482caf985dd05d8010ed4c2~gGbQyJsnj0760107601euoutp028 for ; Thu, 9 Jul 2020 13:48:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200709134849euoutp02d43038f23482caf985dd05d8010ed4c2~gGbQyJsnj0760107601euoutp028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1594302529; bh=L62l8vjdc/mUenW5FZgIVhIRM0nnakDs74jsGifdkCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b6+9nYFf/DA/qzppZIveG40w5QjsDjw7fSny88cyWSBtKmesqVrZQdIZ9dtazOTqv 9tXnxVSejt9QoetPJU4V4X5yeXlVrJj2Ng9IUMy8imdYguu7HsX2Agnn/IzU+purT+ L17klKSXiJyOZpq9CjLm+lkW4CMHCjxCRepfTugg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200709134849eucas1p120f36cf319df7e185d8ab51c840f95a6~gGbQfYG340727507275eucas1p1W; Thu, 9 Jul 2020 13:48:49 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 7E.95.06456.140270F5; Thu, 9 Jul 2020 14:48:49 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200709134848eucas1p27b4f137a91aa805e84f981802da2a226~gGbP7TAzn2009620096eucas1p2-; Thu, 9 Jul 2020 13:48:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200709134848eusmtrp1d725511c4fa3085bdc7252d460423319~gGbP6xn3s1312913129eusmtrp1G; Thu, 9 Jul 2020 13:48:48 +0000 (GMT) X-AuditID: cbfec7f2-7efff70000001938-7f-5f0720412f3c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D0.DE.06314.040270F5; Thu, 9 Jul 2020 14:48:48 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200709134848eusmtip2797172b8620476ec6653047788a9c8ca~gGbPhxa6f2591525915eusmtip2N; Thu, 9 Jul 2020 13:48:48 +0000 (GMT) From: Lukasz Wojciechowski To: Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com Date: Thu, 9 Jul 2020 15:48:23 +0200 Message-Id: <20200709134823.9176-5-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200709134823.9176-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKIsWRmVeSWpSXmKPExsWy7djP87qOCuzxBk83yFi8+7SdyeJZzzpG ByaPXwuWsnocfLeHKYApissmJTUnsyy1SN8ugSvj7oeXLAVPnCuWdE9iaWA8a9rFyMkhIWAi cf14H3MXIxeHkMAKRolV25ezQzhfGCW2rn7IBOF8ZpT49PgkM0xL28rdUInljBJtxzaywFW9 +LCBHaSKTcBW4sjMr6wgtogAi8TK799ZQGxmASOJl90TwSY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sjy8O/6zxQuxJpYVV+YeYpTgYFYS4XU6ezpOiDclsbIqtSg/vqg0J7X4EKMp0FUTmaVEk/OB MZBXEm9oamhuYWlobmxubGahJM7bIXAwRkggPbEkNTs1tSC1CKaPiYNTqoFx3vFDVZ2ntvZk MLnXnlFLrPLSCdm4cN6JI0c+1y9s2N1z5PCiU0vN9vRkd+glVNdMXhmt5igppxv3e8ODKLfv f+0up0yJ8ihx3Pj/unai2a0JDQmr6n/6WdvHxWz/LPmp4IvLHZlbThu6PN8p736858uyxFB2 h5CyRMZ/7yr+TrRJl8/ayhyrxFKckWioxVxUnAgABZatYUkCAAA= X-CMS-MailID: 20200709134848eucas1p27b4f137a91aa805e84f981802da2a226 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200709134848eucas1p27b4f137a91aa805e84f981802da2a226 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200709134848eucas1p27b4f137a91aa805e84f981802da2a226 References: <20200422214555.11837-1-l.wojciechow@partner.samsung.com> <20200709134823.9176-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v3 4/4] app/test: add mbuf perf tests X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds new test command mbuf_perf_autotest to test app, which executes six basic performance tests: * alloc_free - allocation and freeing mbufs one by one * bulk_alloc_free - as above but in bulks * data_manipulation - few command modifying mbuf * sanity_checks_without_header - only sanity checks with unset header flag * sanity_checks_with_header - as above but with header flag set * sanity_checks_with_header_in_chain - as above but all mbufs are chained into one list Purpose of this patch is to measure drop of performance, when using realtime checks with rte_log_can_log in rte_debug enabled configuration. Signed-off-by: Lukasz Wojciechowski --- app/test/Makefile | 1 + app/test/meson.build | 4 +- app/test/test_mbuf_perf.c | 273 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 app/test/test_mbuf_perf.c diff --git a/app/test/Makefile b/app/test/Makefile index e5440774b..09567a239 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -111,6 +111,7 @@ SRCS-y += test_mempool.c SRCS-y += test_mempool_perf.c SRCS-y += test_mbuf.c +SRCS-y += test_mbuf_perf.c SRCS-y += test_logs.c SRCS-y += test_memcpy.c diff --git a/app/test/meson.build b/app/test/meson.build index 39f295d73..b64bc4684 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -74,6 +74,7 @@ test_sources = files('commands.c', 'test_lpm_perf.c', 'test_malloc.c', 'test_mbuf.c', + 'test_mbuf_perf.c', 'test_member.c', 'test_member_perf.c', 'test_memcpy.c', @@ -295,7 +296,8 @@ perf_test_names = [ 'hash_readwrite_perf_autotest', 'hash_readwrite_lf_perf_autotest', 'trace_perf_autotest', - 'ipsec_perf_autotest', + 'ipsec_perf_autotest', + 'mbuf_perf_autotest', ] driver_test_names = [ diff --git a/app/test/test_mbuf_perf.c b/app/test/test_mbuf_perf.c new file mode 100644 index 000000000..42f2079ac --- /dev/null +++ b/app/test/test_mbuf_perf.c @@ -0,0 +1,273 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + */ + +#include +#include + +#include +#include +#include + +#include "test.h" + +#define NB_MBUF 1024 +#define MEMPOOL_CACHE_SIZE 0 +#define MBUF_DATA_SIZE 2048 +#define MBUF_PRIV_SIZE 128 +#define REPEAT (1024*1024) + +static int +case_mbuf_alloc_free(struct rte_mempool *pktmbuf_pool) +{ + unsigned int i; + int ret = TEST_SUCCESS; + int r; + + struct rte_mbuf *m[NB_MBUF]; + for (i = 0; i < NB_MBUF; i++) + m[i] = NULL; + + for (r = 0; r < REPEAT; r++) { + for (i = 0; i < NB_MBUF; i++) { + m[i] = rte_pktmbuf_alloc(pktmbuf_pool); + if (m[i] == NULL) { + printf("rte_pktmbuf_alloc() failed (%u)" + " at repetition %d\n", i, r); + ret = TEST_FAILED; + goto end; + } + } + for (i = 0; i < NB_MBUF; i++) { + if (m[i] != NULL) { + rte_pktmbuf_free(m[i]); + m[i] = NULL; + } + } + } + +end: + for (i = 0; i < NB_MBUF; i++) { + if (m[i] != NULL) + rte_pktmbuf_free(m[i]); + } + return ret; +} + +static int +case_mbuf_bulk_alloc_free(struct rte_mempool *pktmbuf_pool) +{ + int ret = TEST_SUCCESS; + int r; + struct rte_mbuf *m[NB_MBUF]; + + for (r = 0; r < REPEAT; r++) { + ret = rte_pktmbuf_alloc_bulk(pktmbuf_pool, m, NB_MBUF); + if (ret != 0) { + printf("rte_pktmbuf_alloc_bulk() failed" + " at repetition %d\n", r); + ret = TEST_FAILED; + break; + } + rte_pktmbuf_free_bulk(m, NB_MBUF); + } + return ret; +} + +static int +case_mbuf_data_manipulation(struct rte_mempool *pktmbuf_pool) +{ + unsigned int i; + int ret = TEST_SUCCESS; + int r; + + struct rte_mbuf *m[NB_MBUF]; + ret = rte_pktmbuf_alloc_bulk(pktmbuf_pool, m, NB_MBUF); + if (ret != 0) { + printf("rte_pktmbuf_alloc_bulk() failed\n"); + return TEST_FAILED; + } + + for (r = 0; r < REPEAT; r++) { + for (i = 0; i < NB_MBUF; i++) { + if (!rte_pktmbuf_is_contiguous(m[i])) { + printf("rte_pktmbuf_is_contiguous() failed" + " (%u)\n", i); + ret = TEST_FAILED; + goto end; + } + if (rte_pktmbuf_append(m[i], 0) == NULL) { + printf("rte_pktmbuf_append() failed" + " (%u)\n", i); + ret = TEST_FAILED; + goto end; + } + if (rte_pktmbuf_trim(m[i], 0) < 0) { + printf("rte_pktmbuf_trim() failed (%u)\n", i); + ret = TEST_FAILED; + goto end; + } + if (rte_pktmbuf_prepend(m[i], 0) == NULL) { + printf("rte_pktmbuf_prepend() failed" + " (%u)\n", i); + ret = TEST_FAILED; + goto end; + } + if (rte_pktmbuf_adj(m[i], 0) == NULL) { + printf("rte_pktmbuf_adj() failed (%u)\n", i); + ret = TEST_FAILED; + goto end; + } + } + } + +end: + rte_pktmbuf_free_bulk(m, NB_MBUF); + return ret; +} + +static int +case_mbuf_sanity_checks_without_header(struct rte_mempool *pktmbuf_pool) +{ + unsigned int i; + int ret = TEST_SUCCESS; + int r; + + struct rte_mbuf *m[NB_MBUF]; + ret = rte_pktmbuf_alloc_bulk(pktmbuf_pool, m, NB_MBUF); + if (ret != 0) { + printf("rte_pktmbuf_alloc_bulk() failed\n"); + return TEST_FAILED; + } + + for (r = 0; r < REPEAT; r++) + for (i = 0; i < NB_MBUF; i++) + rte_mbuf_sanity_check(m[i], 0); + + rte_pktmbuf_free_bulk(m, NB_MBUF); + return ret; +} + +static int +case_mbuf_sanity_checks_with_header(struct rte_mempool *pktmbuf_pool) +{ + unsigned int i; + int ret = TEST_SUCCESS; + int r; + + struct rte_mbuf *m[NB_MBUF]; + ret = rte_pktmbuf_alloc_bulk(pktmbuf_pool, m, NB_MBUF); + if (ret != 0) { + printf("rte_pktmbuf_alloc_bulk() failed\n"); + return TEST_FAILED; + } + + for (r = 0; r < REPEAT; r++) + for (i = 0; i < NB_MBUF; i++) + rte_mbuf_sanity_check(m[i], 1); + + rte_pktmbuf_free_bulk(m, NB_MBUF); + return ret; +} + +static int +case_mbuf_sanity_checks_with_header_in_chain(struct rte_mempool *pktmbuf_pool) +{ + unsigned int i; + int ret = TEST_SUCCESS; + int r; + + struct rte_mbuf *m[NB_MBUF]; + ret = rte_pktmbuf_alloc_bulk(pktmbuf_pool, m, NB_MBUF); + if (ret != 0) { + printf("rte_pktmbuf_alloc_bulk() failed\n"); + return TEST_FAILED; + } + + for (i = 1; i < NB_MBUF; i++) { + ret = rte_pktmbuf_chain(m[0], m[i]); + if (ret != 0) { + printf("rte_pktmbuf_chain() failed: %d\n", ret); + goto end; + } + m[i] = NULL; + } + + for (r = 0; r < REPEAT; r++) + rte_mbuf_sanity_check(m[0], 1); + +end: + rte_pktmbuf_free_bulk(m, NB_MBUF); + return ret; +} + +struct testcase { + int (*func)(struct rte_mempool *pktmbuf_pool); + const char *name; + double time; + int ret; +}; + +#define TC(F) {.func = F, .name = RTE_STR(F), .time = 0.0, .ret = TEST_SKIPPED} + +static int +test_mbuf_perf(void) +{ + int ret = TEST_SUCCESS; + struct timeval tv_begin, tv_end; + struct testcase cases[] = { + TC(case_mbuf_alloc_free), + TC(case_mbuf_bulk_alloc_free), + TC(case_mbuf_data_manipulation), + TC(case_mbuf_sanity_checks_without_header), + TC(case_mbuf_sanity_checks_with_header), + TC(case_mbuf_sanity_checks_with_header_in_chain), + }; + int i, n = RTE_DIM(cases); + const char *status_ok = "[ OK ]"; + const char *status_skip = "[SKIP]"; + const char *status_fail = "[FAIL]"; + const char *status; + struct rte_mempool *pktmbuf_pool = NULL; + + pktmbuf_pool = rte_pktmbuf_pool_create("test_pktmbuf_pool", + NB_MBUF, MEMPOOL_CACHE_SIZE, MBUF_PRIV_SIZE, + MBUF_DATA_SIZE, SOCKET_ID_ANY); + if (pktmbuf_pool == NULL) { + printf("cannot allocate mbuf pool\n"); + ret = TEST_FAILED; + goto end; + } + + for (i = 0; i < n; i++) { + printf("=== running %s ===\n", cases[i].name); + gettimeofday(&tv_begin, NULL); + cases[i].ret = cases[i].func(pktmbuf_pool); + gettimeofday(&tv_end, NULL); + cases[i].time = (double)(tv_end.tv_sec - tv_begin.tv_sec) + + ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000; + } + + printf("%-50s %-10s %s:\n", "TestName", "Status", "Time(seconds)"); + for (i = 0; i < n; i++) { + if (cases[i].ret == TEST_SKIPPED) + status = status_skip; + else if (cases[i].ret == TEST_SUCCESS) + status = status_ok; + else { + status = status_fail; + ret = TEST_FAILED; + } + printf("%-50s %-10s %8.3f\n", cases[i].name, status, + cases[i].time); + } + +end: + if (pktmbuf_pool != NULL) + rte_mempool_free(pktmbuf_pool); + + return ret; +} + +REGISTER_TEST_COMMAND(mbuf_perf_autotest, test_mbuf_perf); + -- 2.17.1