From: Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com
Subject: [dpdk-dev] [PATCH v3 4/4] app/test: add mbuf perf tests
Date: Thu, 9 Jul 2020 15:48:23 +0200 [thread overview]
Message-ID: <20200709134823.9176-5-l.wojciechow@partner.samsung.com> (raw)
In-Reply-To: <20200709134823.9176-1-l.wojciechow@partner.samsung.com>
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 <l.wojciechow@partner.samsung.com>
---
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 <stdio.h>
+#include <sys/time.h>
+
+#include <rte_common.h>
+#include <rte_mbuf.h>
+#include <rte_memory.h>
+
+#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
next prev parent reply other threads:[~2020-07-09 13:49 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200417215755eucas1p25660167c57c26ef04a82a8bb981e07b5@eucas1p2.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 00/17] introduce global debug flag Lukasz Wojciechowski
[not found] ` <CGME20200417215756eucas1p107941824d555cdc91899d529d3c4ee67@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 01/17] config: " Lukasz Wojciechowski
[not found] ` <CGME20200417215756eucas1p13a995889338901b81bf2a59a5a4f1260@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 02/17] config: remove unused config flags Lukasz Wojciechowski
[not found] ` <CGME20200417215759eucas1p1c0fcc3046d87dc9de1d15572ba6b7caa@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 03/17] ethdev: replace library debug flag with global one Lukasz Wojciechowski
2020-04-20 9:04 ` Dumitrescu, Cristian
2020-04-20 13:37 ` Ananyev, Konstantin
2020-04-20 14:21 ` Bruce Richardson
2020-04-20 14:43 ` Lukasz Wojciechowski
2020-04-20 17:11 ` Bruce Richardson
2020-04-20 17:21 ` Thomas Monjalon
2020-04-20 17:30 ` Bruce Richardson
2020-04-20 17:34 ` Lukasz Wojciechowski
2023-06-12 16:23 ` Stephen Hemminger
2020-04-20 17:35 ` Thomas Monjalon
2020-04-20 18:57 ` Bruce Richardson
2020-04-21 0:32 ` Ananyev, Konstantin
2020-04-21 20:58 ` Lukasz Wojciechowski
2020-04-21 21:38 ` Thomas Monjalon
2020-04-22 10:41 ` Lukasz Wojciechowski
2020-04-22 10:55 ` Bruce Richardson
2020-04-22 11:02 ` Thomas Monjalon
2020-04-22 11:16 ` Bruce Richardson
2020-04-22 11:29 ` Ananyev, Konstantin
2020-04-22 12:24 ` Thomas Monjalon
2020-07-09 14:09 ` Lukasz Wojciechowski
2020-07-14 10:30 ` Ananyev, Konstantin
2020-04-22 11:52 ` Lukasz Wojciechowski
2020-04-22 12:44 ` Bruce Richardson
2020-04-20 17:24 ` Bruce Richardson
[not found] ` <CGME20200417215800eucas1p2f3a71aaf69584fc37c9c4a47c3a2d39d@eucas1p2.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 04/17] eventdev: " Lukasz Wojciechowski
2020-04-18 9:41 ` [dpdk-dev] [EXT] " Jerin Jacob Kollanukkaran
2020-04-18 9:53 ` Thomas Monjalon
2020-04-18 10:05 ` Jerin Jacob
2020-04-18 13:22 ` Thomas Monjalon
[not found] ` <CGME20200417215801eucas1p28aefc04e119aa5de16a7f0771bb0e268@eucas1p2.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 05/17] fib: " Lukasz Wojciechowski
[not found] ` <CGME20200417215801eucas1p25e56a60eda9b741ba26e686b90ed8e28@eucas1p2.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 06/17] cmdline: " Lukasz Wojciechowski
[not found] ` <CGME20200417215802eucas1p27d4041768b717226b7161d0b896c3261@eucas1p2.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 07/17] hash: " Lukasz Wojciechowski
[not found] ` <CGME20200417215803eucas1p16013610674ce6ac58189259f2632f562@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 08/17] ip_frag: " Lukasz Wojciechowski
[not found] ` <CGME20200417215804eucas1p2c04d6f2141be07b25f0d346c73d4f965@eucas1p2.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 09/17] lpm: " Lukasz Wojciechowski
[not found] ` <CGME20200417215805eucas1p114b3286afa16d6f12916048234f3a159@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 10/17] mbuf: " Lukasz Wojciechowski
[not found] ` <CGME20200417215805eucas1p2530efed5c5a73df8cc5fb613b11dfdde@eucas1p2.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 11/17] mempool: " Lukasz Wojciechowski
[not found] ` <CGME20200417215806eucas1p1df0cf8a6cfe65dd687dde9056854bbad@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 12/17] power: " Lukasz Wojciechowski
[not found] ` <CGME20200417215807eucas1p14de926321e5a683224f7550ae902af5b@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 13/17] rcu: " Lukasz Wojciechowski
[not found] ` <CGME20200417215808eucas1p26bb784466131275eeccff018ecac83ca@eucas1p2.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 14/17] timer: " Lukasz Wojciechowski
[not found] ` <CGME20200417215808eucas1p1aa9a24a464a4470d27b6c770d2e8c297@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 15/17] vhost: " Lukasz Wojciechowski
[not found] ` <CGME20200417215809eucas1p1d826c921a9880007af4ee4282dda5d32@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 16/17] eal: " Lukasz Wojciechowski
[not found] ` <CGME20200417215810eucas1p17a63d33a4d49c8866733a33ce717484b@eucas1p1.samsung.com>
2020-04-17 21:57 ` [dpdk-dev] [PATCH v1 17/17] sched: " Lukasz Wojciechowski
2020-04-20 9:04 ` Dumitrescu, Cristian
[not found] ` <CGME20200422214613eucas1p153ed981de395ef1b800364a003da85e5@eucas1p1.samsung.com>
2020-04-22 21:45 ` [dpdk-dev] [PATCH v2 0/3] introduce global debug flag Lukasz Wojciechowski
[not found] ` <CGME20200422214614eucas1p1044184e60bcb04469783ef0dd95091c1@eucas1p1.samsung.com>
2020-04-22 21:45 ` [dpdk-dev] [PATCH v2 1/3] config: introduce global rte " Lukasz Wojciechowski
2020-06-26 16:56 ` Bruce Richardson
2020-06-28 8:40 ` Andrew Rybchenko
2020-07-09 13:51 ` Lukasz Wojciechowski
2020-07-09 14:09 ` Bruce Richardson
2020-07-09 14:13 ` Lukasz Wojciechowski
[not found] ` <CGME20200422214614eucas1p2ad5c7a54972cf47f182f51ba3346027b@eucas1p2.samsung.com>
2020-04-22 21:45 ` [dpdk-dev] [PATCH v2 2/3] config: remove unused config flags Lukasz Wojciechowski
2020-06-26 16:56 ` Bruce Richardson
[not found] ` <CGME20200422214615eucas1p2a50ce20695a77b5b2888fd4521296094@eucas1p2.samsung.com>
2020-04-22 21:45 ` [dpdk-dev] [PATCH v2 3/3] mbuf: standardize library debug flag Lukasz Wojciechowski
2020-06-26 17:00 ` Bruce Richardson
2020-07-09 13:50 ` Lukasz Wojciechowski
2020-04-24 9:09 ` [dpdk-dev] [PATCH v2 0/3] introduce global " Bruce Richardson
2020-04-24 10:14 ` Lukasz Wojciechowski
[not found] ` <CGME20200709134846eucas1p193d963c3f21f0d5c4985024b6d015042@eucas1p1.samsung.com>
2020-07-09 13:48 ` [dpdk-dev] [PATCH v3 0/4] " Lukasz Wojciechowski
[not found] ` <CGME20200709134847eucas1p2698cc0b2de3751aba984d306beb9d8f1@eucas1p2.samsung.com>
2020-07-09 13:48 ` [dpdk-dev] [PATCH v3 1/4] config: introduce global rte " Lukasz Wojciechowski
[not found] ` <CGME20200709134847eucas1p2c772544e09360a0b05e95e20c36fb0b8@eucas1p2.samsung.com>
2020-07-09 13:48 ` [dpdk-dev] [PATCH v3 2/4] config: remove unused config flags Lukasz Wojciechowski
2020-07-16 7:43 ` David Marchand
2020-07-16 8:41 ` Ruifeng Wang
[not found] ` <CGME20200709134848eucas1p1b78c9b2d4556ae3047d52e9d6e41b11c@eucas1p1.samsung.com>
2020-07-09 13:48 ` [dpdk-dev] [PATCH v3 3/4] mbuf: standardize library debug flag Lukasz Wojciechowski
[not found] ` <CGME20200709134848eucas1p27b4f137a91aa805e84f981802da2a226@eucas1p2.samsung.com>
2020-07-09 13:48 ` Lukasz Wojciechowski [this message]
2020-07-11 15:11 ` [dpdk-dev] [PATCH v3 0/4] introduce global " Thomas Monjalon
2020-07-13 9:04 ` Bruce Richardson
2020-07-13 22:44 ` Lukasz Wojciechowski
2020-07-13 22:39 ` Lukasz Wojciechowski
2020-07-14 1:23 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200709134823.9176-5-l.wojciechow@partner.samsung.com \
--to=l.wojciechow@partner.samsung.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).