DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dmitry Kozlyuk <dkozlyuk@oss.nvidia.com>
To: <dev@dpdk.org>
Cc: Olivier Matz <olivier.matz@6wind.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH v3 3/3] app/test: fix mempool test in no-huge mode
Date: Tue, 2 Nov 2021 12:08:17 +0200	[thread overview]
Message-ID: <20211102100817.916303-4-dkozlyuk@nvidia.com> (raw)
In-Reply-To: <20211102100817.916303-1-dkozlyuk@nvidia.com>

Amount of locked memory for regular users is limited,
it is usually 64 KB by default.
Hitting this limit in rte_mempool_populate_anon()
resulted in not populating the mempool, and a test case failure:

    EAL: Test assert test_mempool_events line 585 failed: Failed to populate mempool empty1: Success
    test failed at test_mempool():1019
    Test Failed

Decrease the amount of mapped anonymous memory to fit the limit.
While there, make all function-local constants lowercase.

Fixes: 11541c5c81dd ("mempool: add non-IO flag")

Reported-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
 app/test/test_mempool.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index ced20dcdc3..a451608558 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -515,17 +515,19 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp))
 #undef RTE_TEST_TRACE_FAILURE
 #define RTE_TEST_TRACE_FAILURE(...) do { goto fail; } while (0)
 
-	static const size_t CB_NUM = 3;
-	static const size_t MP_NUM = 2;
+	static const size_t callback_num = 3;
+	static const size_t mempool_num = 2;
+	static const unsigned int mempool_elt_size = 64;
+	static const unsigned int mempool_size = 64;
 
-	struct test_mempool_events_data data[CB_NUM];
-	struct rte_mempool *mp[MP_NUM], *freed;
+	struct test_mempool_events_data data[callback_num];
+	struct rte_mempool *mp[mempool_num], *freed;
 	char name[RTE_MEMPOOL_NAMESIZE];
 	size_t i, j;
 	int ret;
 
 	memset(mp, 0, sizeof(mp));
-	for (i = 0; i < CB_NUM; i++) {
+	for (i = 0; i < callback_num; i++) {
 		ret = rte_mempool_event_callback_register
 				(test_mempool_events_cb, &data[i]);
 		RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to register the callback %zu: %s",
@@ -541,12 +543,12 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp))
 	/* Create mempool 0 that will be observed by all callbacks. */
 	memset(&data, 0, sizeof(data));
 	strcpy(name, "empty0");
-	mp[0] = rte_mempool_create_empty(name, MEMPOOL_SIZE,
-					 MEMPOOL_ELT_SIZE, 0, 0,
+	mp[0] = rte_mempool_create_empty(name, mempool_size,
+					 mempool_elt_size, 0, 0,
 					 SOCKET_ID_ANY, 0);
 	RTE_TEST_ASSERT_NOT_NULL(mp[0], "Cannot create mempool %s: %s",
 				 name, rte_strerror(rte_errno));
-	for (j = 0; j < CB_NUM; j++)
+	for (j = 0; j < callback_num; j++)
 		RTE_TEST_ASSERT_EQUAL(data[j].invoked, false,
 				      "Callback %zu invoked on %s mempool creation",
 				      j, name);
@@ -555,7 +557,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp))
 	ret = populate(mp[0]);
 	RTE_TEST_ASSERT_EQUAL(ret, (int)mp[0]->size, "Failed to populate mempool %s: %s",
 			      name, rte_strerror(-ret));
-	for (j = 0; j < CB_NUM; j++) {
+	for (j = 0; j < callback_num; j++) {
 		RTE_TEST_ASSERT_EQUAL(data[j].invoked, true,
 					"Callback %zu not invoked on mempool %s population",
 					j, name);
@@ -574,8 +576,8 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp))
 			      rte_strerror(rte_errno));
 	memset(&data, 0, sizeof(data));
 	strcpy(name, "empty1");
-	mp[1] = rte_mempool_create_empty(name, MEMPOOL_SIZE,
-					 MEMPOOL_ELT_SIZE, 0, 0,
+	mp[1] = rte_mempool_create_empty(name, mempool_size,
+					 mempool_elt_size, 0, 0,
 					 SOCKET_ID_ANY, 0);
 	RTE_TEST_ASSERT_NOT_NULL(mp[1], "Cannot create mempool %s: %s",
 				 name, rte_strerror(rte_errno));
@@ -587,7 +589,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp))
 			      "Unregistered callback 0 invoked on %s mempool populaton",
 			      name);
 
-	for (i = 0; i < MP_NUM; i++) {
+	for (i = 0; i < mempool_num; i++) {
 		memset(&data, 0, sizeof(data));
 		sprintf(name, "empty%zu", i);
 		rte_mempool_free(mp[i]);
@@ -597,7 +599,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp))
 		 */
 		freed = mp[i];
 		mp[i] = NULL;
-		for (j = 1; j < CB_NUM; j++) {
+		for (j = 1; j < callback_num; j++) {
 			RTE_TEST_ASSERT_EQUAL(data[j].invoked, true,
 					      "Callback %zu not invoked on mempool %s destruction",
 					      j, name);
@@ -613,7 +615,7 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp))
 				      name);
 	}
 
-	for (j = 1; j < CB_NUM; j++) {
+	for (j = 1; j < callback_num; j++) {
 		ret = rte_mempool_event_callback_unregister
 					(test_mempool_events_cb, &data[j]);
 		RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister the callback %zu: %s",
@@ -622,10 +624,10 @@ test_mempool_events(int (*populate)(struct rte_mempool *mp))
 	return TEST_SUCCESS;
 
 fail:
-	for (j = 0; j < CB_NUM; j++)
+	for (j = 0; j < callback_num; j++)
 		rte_mempool_event_callback_unregister
 					(test_mempool_events_cb, &data[j]);
-	for (i = 0; i < MP_NUM; i++)
+	for (i = 0; i < mempool_num; i++)
 		rte_mempool_free(mp[i]);
 	return TEST_FAILED;
 
-- 
2.25.1


  parent reply	other threads:[~2021-11-02 10:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29  8:40 [dpdk-dev] [PATCH] app/test: fix mempool test failure on FreeBSD Dmitry Kozlyuk
2021-10-29  9:34 ` Olivier Matz
2021-10-29  9:37   ` Dmitry Kozlyuk
2021-11-01  7:36 ` [dpdk-dev] [PATCH v2 0/3] Mempool fixes for FreeBSD Dmitry Kozlyuk
2021-11-01  7:36   ` [dpdk-dev] [PATCH v2 1/3] eal/freebsd: fix IOVA mode selection Dmitry Kozlyuk
2021-11-01 16:21     ` Bruce Richardson
2021-11-01  7:37   ` [dpdk-dev] [PATCH v2 2/3] app/test: fix mempool test on FreeBSD Dmitry Kozlyuk
2021-11-01  7:37   ` [dpdk-dev] [PATCH v2 3/3] app/test: fix mempool test in no-huge mode Dmitry Kozlyuk
2021-11-02 10:08   ` [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD Dmitry Kozlyuk
2021-11-02 10:08     ` [dpdk-dev] [PATCH v3 1/3] eal/freebsd: fix IOVA mode selection Dmitry Kozlyuk
2021-11-02 10:08     ` [dpdk-dev] [PATCH v3 2/3] app/test: fix mempool test on FreeBSD Dmitry Kozlyuk
2021-11-02 10:08     ` Dmitry Kozlyuk [this message]
2021-11-03 17:39     ` [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD Thomas Monjalon

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=20211102100817.916303-4-dkozlyuk@nvidia.com \
    --to=dkozlyuk@oss.nvidia.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    /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).