DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/test: fix mempool test failure on FreeBSD
@ 2021-10-29  8:40 Dmitry Kozlyuk
  2021-10-29  9:34 ` Olivier Matz
  2021-11-01  7:36 ` [dpdk-dev] [PATCH v2 0/3] Mempool fixes for FreeBSD Dmitry Kozlyuk
  0 siblings, 2 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-10-29  8:40 UTC (permalink / raw)
  To: dev; +Cc: YuX Jiang, Olivier Matz, Andrew Rybchenko

FreeBSD EAL does not implement rte_mem_virt2iova()
that was used in mempool_autotest, causing it to fail:

    EAL: Test assert test_mempool_flag_non_io_unset_when_populated_with_valid_iova
    line 781 failed: Cannot get IOVA
    test failed at test_mempool():1030
    Test Failed

Change unit test to use rte_memzone_reserve() to allocate memory,
which allows to obtain IOVA directly.

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

Reported-by: YuX Jiang <yux.jiang@intel.com>
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
 app/test/test_mempool.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index 4b0f6b0e7f..bce073064a 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -740,16 +740,17 @@ test_mempool_events_safety(void)
 static int
 test_mempool_flag_non_io_set_when_no_iova_contig_set(void)
 {
-	void *virt = NULL;
+	const struct rte_memzone *mz = NULL;
+	void *virt;
 	rte_iova_t iova;
 	size_t size = MEMPOOL_ELT_SIZE * 16;
 	struct rte_mempool *mp = NULL;
 	int ret;
 
-	virt = rte_malloc("test_mempool", size, rte_mem_page_size());
-	RTE_TEST_ASSERT_NOT_NULL(virt, "Cannot allocate memory");
-	iova = rte_mem_virt2iova(virt);
-	RTE_TEST_ASSERT_NOT_EQUAL(iova,  RTE_BAD_IOVA, "Cannot get IOVA");
+	mz = rte_memzone_reserve("test_mempool", size, SOCKET_ID_ANY, 0);
+	RTE_TEST_ASSERT_NOT_NULL(mz, "Cannot allocate memory");
+	virt = mz->addr;
+	iova = mz->iova;
 	mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
 				      MEMPOOL_ELT_SIZE, 0, 0,
 				      SOCKET_ID_ANY, RTE_MEMPOOL_F_NO_IOVA_CONTIG);
@@ -772,14 +773,15 @@ test_mempool_flag_non_io_set_when_no_iova_contig_set(void)
 	ret = TEST_SUCCESS;
 exit:
 	rte_mempool_free(mp);
-	rte_free(virt);
+	rte_memzone_free(mz);
 	return ret;
 }
 
 static int
 test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 {
-	void *virt = NULL;
+	const struct rte_memzone *mz = NULL;
+	void *virt;
 	rte_iova_t iova;
 	size_t total_size = MEMPOOL_ELT_SIZE * MEMPOOL_SIZE;
 	size_t block_size = total_size / 3;
@@ -789,12 +791,12 @@ test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 	/*
 	 * Since objects from the pool are never used in the test,
 	 * we don't care for contiguous IOVA, on the other hand,
-	 * reiuring it could cause spurious test failures.
+	 * reqiuring it could cause spurious test failures.
 	 */
-	virt = rte_malloc("test_mempool", total_size, rte_mem_page_size());
-	RTE_TEST_ASSERT_NOT_NULL(virt, "Cannot allocate memory");
-	iova = rte_mem_virt2iova(virt);
-	RTE_TEST_ASSERT_NOT_EQUAL(iova,  RTE_BAD_IOVA, "Cannot get IOVA");
+	mz = rte_memzone_reserve("test_mempool", total_size, SOCKET_ID_ANY, 0);
+	RTE_TEST_ASSERT_NOT_NULL(mz, "Cannot allocate memory");
+	virt = mz->addr;
+	iova = mz->iova;
 	mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
 				      MEMPOOL_ELT_SIZE, 0, 0,
 				      SOCKET_ID_ANY, 0);
@@ -827,7 +829,7 @@ test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 
 exit:
 	rte_mempool_free(mp);
-	rte_free(virt);
+	rte_memzone_free(mz);
 	return ret;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH] app/test: fix mempool test failure on FreeBSD
  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
  1 sibling, 1 reply; 13+ messages in thread
From: Olivier Matz @ 2021-10-29  9:34 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev, YuX Jiang, Andrew Rybchenko

Hi Dmitry,

On Fri, Oct 29, 2021 at 11:40:50AM +0300, Dmitry Kozlyuk wrote:
> FreeBSD EAL does not implement rte_mem_virt2iova()
> that was used in mempool_autotest, causing it to fail:
> 
>     EAL: Test assert test_mempool_flag_non_io_unset_when_populated_with_valid_iova
>     line 781 failed: Cannot get IOVA
>     test failed at test_mempool():1030
>     Test Failed
> 
> Change unit test to use rte_memzone_reserve() to allocate memory,
> which allows to obtain IOVA directly.
> 
> Bugzilla ID: 863
> Fixes: 11541c5c81dd ("mempool: add non-IO flag")
> 
> Reported-by: YuX Jiang <yux.jiang@intel.com>
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>

Reviewed-by: Olivier Matz <olivier.matz@6wind.com>

However, I launched the test like this and it failed:

$ ./build/app/test/dpdk-test --no-huge -m 512
EAL: Detected CPU lcores: 12
EAL: Detected NUMA nodes: 1
EAL: Detected shared linkage of DPDK
EAL: Multi-process socket /run/user/12489/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
APP: HPET is not enabled, using TSC as default timer
RTE>>mempool_autotest
(...)
EAL: Test assert test_mempool_events line 585 failed: Failed to populate mempool empty1: Success
test failed at test_mempool():1019
Test Failed

It appears that the failure comes from:

int
rte_mempool_populate_anon(struct rte_mempool *mp)
{
(...)
        /* can't use MMAP_LOCKED, it does not exist on BSD */
        if (rte_mem_lock(addr, size) < 0) {
=>              rte_mem_unmap(addr, size);
                return 0;
        }

The errno here is 12 (ENOMEM). This is because of the default ulimit for
max locked memory: (kbytes, -l) 65536

If I increase it to 128000, it works.

Would it make sense to decrease the size of the pools so that we don't
reach this limit?

(...)
> @@ -789,12 +791,12 @@ test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
>  	/*
>  	 * Since objects from the pool are never used in the test,
>  	 * we don't care for contiguous IOVA, on the other hand,
> -	 * reiuring it could cause spurious test failures.
> +	 * reqiuring it could cause spurious test failures.

nice try :D

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH] app/test: fix mempool test failure on FreeBSD
  2021-10-29  9:34 ` Olivier Matz
@ 2021-10-29  9:37   ` Dmitry Kozlyuk
  0 siblings, 0 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-10-29  9:37 UTC (permalink / raw)
  To: Olivier Matz; +Cc: dev, YuX Jiang, Andrew Rybchenko



> -----Original Message-----
> From: Olivier Matz <olivier.matz@6wind.com>
> Sent: 29 октября 2021 г. 12:35
> To: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> Cc: dev@dpdk.org; YuX Jiang <yux.jiang@intel.com>; Andrew Rybchenko
> <andrew.rybchenko@oktetlabs.ru>
> Subject: Re: [PATCH] app/test: fix mempool test failure on FreeBSD
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi Dmitry,
> 
> On Fri, Oct 29, 2021 at 11:40:50AM +0300, Dmitry Kozlyuk wrote:
> > FreeBSD EAL does not implement rte_mem_virt2iova()
> > that was used in mempool_autotest, causing it to fail:
> >
> >     EAL: Test assert
> test_mempool_flag_non_io_unset_when_populated_with_valid_iova
> >     line 781 failed: Cannot get IOVA
> >     test failed at test_mempool():1030
> >     Test Failed
> >
> > Change unit test to use rte_memzone_reserve() to allocate memory,
> > which allows to obtain IOVA directly.
> >
> > Bugzilla ID: 863
> > Fixes: 11541c5c81dd ("mempool: add non-IO flag")
> >
> > Reported-by: YuX Jiang <yux.jiang@intel.com>
> > Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> 
> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
> 
> However, I launched the test like this and it failed:
> 
> $ ./build/app/test/dpdk-test --no-huge -m 512
> EAL: Detected CPU lcores: 12
> EAL: Detected NUMA nodes: 1
> EAL: Detected shared linkage of DPDK
> EAL: Multi-process socket /run/user/12489/dpdk/rte/mp_socket
> EAL: Selected IOVA mode 'VA'
> APP: HPET is not enabled, using TSC as default timer
> RTE>>mempool_autotest
> (...)
> EAL: Test assert test_mempool_events line 585 failed: Failed to populate
> mempool empty1: Success
> test failed at test_mempool():1019
> Test Failed
> 
> It appears that the failure comes from:
> 
> int
> rte_mempool_populate_anon(struct rte_mempool *mp)
> {
> (...)
>         /* can't use MMAP_LOCKED, it does not exist on BSD */
>         if (rte_mem_lock(addr, size) < 0) {
> =>              rte_mem_unmap(addr, size);
>                 return 0;
>         }
> 
> The errno here is 12 (ENOMEM). This is because of the default ulimit for
> max locked memory: (kbytes, -l) 65536
> 
> If I increase it to 128000, it works.
> 
> Would it make sense to decrease the size of the pools so that we don't
> reach this limit?

Good catch, will send a v2.

> (...)
> > @@ -789,12 +791,12 @@
> test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
> >       /*
> >        * Since objects from the pool are never used in the test,
> >        * we don't care for contiguous IOVA, on the other hand,
> > -      * reiuring it could cause spurious test failures.
> > +      * reqiuring it could cause spurious test failures.
> 
> nice try :D

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v2 0/3] Mempool fixes for FreeBSD
  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-11-01  7:36 ` Dmitry Kozlyuk
  2021-11-01  7:36   ` [dpdk-dev] [PATCH v2 1/3] eal/freebsd: fix IOVA mode selection Dmitry Kozlyuk
                     ` (3 more replies)
  1 sibling, 4 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-01  7:36 UTC (permalink / raw)
  To: dev; +Cc: Anatoly Burakov, Olivier Matz, Yu Jiang

mempool_autotest was failing on FreeBSD,
because rte_virt2iova() is not implemented.
After the test started using memzones,
it appeared that in --no-huge memzones have iova=RTE_BAD_IOVA,
which is unexpected and contradicts with selected IOVA-as-PA.
Intead of working around this in the unit test,
fix FreeBSD EAL to select IOVA-as-VA in --no-huge mode.

v2:
  * Add the EAL changes.
  * Fix a failure with --no-huge (Olivier).

Dmitry Kozlyuk (3):
  eal/freebsd: fix IOVA mode selection
  app/test: fix mempool test on FreeBSD
  app/test: fix mempool test in no-huge mode

 app/test/test_mempool.c | 62 ++++++++++++++++++++++-------------------
 lib/eal/freebsd/eal.c   | 37 ++++++++++++++++--------
 2 files changed, 58 insertions(+), 41 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v2 1/3] eal/freebsd: fix IOVA mode selection
  2021-11-01  7:36 ` [dpdk-dev] [PATCH v2 0/3] Mempool fixes for FreeBSD Dmitry Kozlyuk
@ 2021-11-01  7:36   ` 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
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-01  7:36 UTC (permalink / raw)
  To: dev; +Cc: Anatoly Burakov, benjamin.walker, stable, Bruce Richardson

FreeBSD EAL selected IOVA mode PA even in --no-huge mode
where PA are not available. Memory zones were created with IOVA
equal to RTE_BAD_IOVA with no indication this field is not usable.

Change IOVA mode detection:
1. Always allow to force --iova-mode=va.
2. In --no-huge mode, disallow forcing --iova-mode=pa, and select VA.
3. Otherwise select IOVA mode according to bus requests, default to PA.
In case contigmem is inaccessible, memory initialization will fail
with a message indicating the cause.

Fixes: c2361bab70c5 ("eal: compute IOVA mode based on PA availability")
Cc: benjamin.walker@intel.com
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
 lib/eal/freebsd/eal.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 9935356ed4..519a645344 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -677,6 +677,8 @@ rte_eal_init(int argc, char **argv)
 	const struct rte_config *config = rte_eal_get_configuration();
 	struct internal_config *internal_conf =
 		eal_get_internal_configuration();
+	bool has_phys_addr;
+	enum rte_iova_mode iova_mode;
 
 	/* checks if the machine is adequate */
 	if (!rte_cpu_is_supported()) {
@@ -777,21 +779,32 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	/* if no EAL option "--iova-mode=<pa|va>", use bus IOVA scheme */
-	if (internal_conf->iova_mode == RTE_IOVA_DC) {
-		/* autodetect the IOVA mapping mode (default is RTE_IOVA_PA) */
-		enum rte_iova_mode iova_mode = rte_bus_get_iommu_class();
-
-		if (iova_mode == RTE_IOVA_DC)
-			iova_mode = RTE_IOVA_PA;
-		rte_eal_get_configuration()->iova_mode = iova_mode;
-	} else {
-		rte_eal_get_configuration()->iova_mode =
-			internal_conf->iova_mode;
+	/*
+	 * PA are only available for hugepages via contigmem.
+	 * If contigmem is inaccessible, rte_eal_hugepage_init() will fail
+	 * with a message describing the cause.
+	 */
+	has_phys_addr = internal_conf->no_hugetlbfs == 0;
+	iova_mode = internal_conf->iova_mode;
+	if (iova_mode == RTE_IOVA_PA && !has_phys_addr) {
+		rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available");
+		rte_errno = EINVAL;
+		return -1;
+	}
+	if (iova_mode == RTE_IOVA_DC) {
+		RTE_LOG(DEBUG, EAL, "Specific IOVA mode is not requested, autodetecting\n");
+		if (has_phys_addr) {
+			RTE_LOG(DEBUG, EAL, "Selecting IOVA mode according to bus requests\n");
+			iova_mode = rte_bus_get_iommu_class();
+			if (iova_mode == RTE_IOVA_DC)
+				iova_mode = RTE_IOVA_PA;
+		} else {
+			iova_mode = RTE_IOVA_VA;
+		}
 	}
-
 	RTE_LOG(INFO, EAL, "Selected IOVA mode '%s'\n",
 		rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA");
+	rte_eal_get_configuration()->iova_mode = iova_mode;
 
 	if (internal_conf->no_hugetlbfs == 0) {
 		/* rte_config isn't initialized yet */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v2 2/3] app/test: fix mempool test on FreeBSD
  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  7:37   ` 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
  3 siblings, 0 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-01  7:37 UTC (permalink / raw)
  To: dev; +Cc: Yu Jiang, Olivier Matz, Andrew Rybchenko

FreeBSD EAL does not implement rte_mem_virt2iova() causing an error:

    EAL: Test assert test_mempool_flag_non_io_unset_when_populated_with_valid_iova
    line 781 failed: Cannot get IOVA
    test failed at test_mempool():1030
    Test Failed

Change unit test to use rte_memzone_reserve() to allocate memory,
which allows to obtain IOVA directly.

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

Reported-by: Yu Jiang <yux.jiang@intel.com>
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
 app/test/test_mempool.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index 4b0f6b0e7f..ced20dcdc3 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -740,16 +740,17 @@ test_mempool_events_safety(void)
 static int
 test_mempool_flag_non_io_set_when_no_iova_contig_set(void)
 {
-	void *virt = NULL;
+	const struct rte_memzone *mz = NULL;
+	void *virt;
 	rte_iova_t iova;
 	size_t size = MEMPOOL_ELT_SIZE * 16;
 	struct rte_mempool *mp = NULL;
 	int ret;
 
-	virt = rte_malloc("test_mempool", size, rte_mem_page_size());
-	RTE_TEST_ASSERT_NOT_NULL(virt, "Cannot allocate memory");
-	iova = rte_mem_virt2iova(virt);
-	RTE_TEST_ASSERT_NOT_EQUAL(iova,  RTE_BAD_IOVA, "Cannot get IOVA");
+	mz = rte_memzone_reserve("test_mempool", size, SOCKET_ID_ANY, 0);
+	RTE_TEST_ASSERT_NOT_NULL(mz, "Cannot allocate memory");
+	virt = mz->addr;
+	iova = mz->iova;
 	mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
 				      MEMPOOL_ELT_SIZE, 0, 0,
 				      SOCKET_ID_ANY, RTE_MEMPOOL_F_NO_IOVA_CONTIG);
@@ -772,14 +773,15 @@ test_mempool_flag_non_io_set_when_no_iova_contig_set(void)
 	ret = TEST_SUCCESS;
 exit:
 	rte_mempool_free(mp);
-	rte_free(virt);
+	rte_memzone_free(mz);
 	return ret;
 }
 
 static int
 test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 {
-	void *virt = NULL;
+	const struct rte_memzone *mz = NULL;
+	void *virt;
 	rte_iova_t iova;
 	size_t total_size = MEMPOOL_ELT_SIZE * MEMPOOL_SIZE;
 	size_t block_size = total_size / 3;
@@ -789,12 +791,12 @@ test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 	/*
 	 * Since objects from the pool are never used in the test,
 	 * we don't care for contiguous IOVA, on the other hand,
-	 * reiuring it could cause spurious test failures.
+	 * requiring it could cause spurious test failures.
 	 */
-	virt = rte_malloc("test_mempool", total_size, rte_mem_page_size());
-	RTE_TEST_ASSERT_NOT_NULL(virt, "Cannot allocate memory");
-	iova = rte_mem_virt2iova(virt);
-	RTE_TEST_ASSERT_NOT_EQUAL(iova,  RTE_BAD_IOVA, "Cannot get IOVA");
+	mz = rte_memzone_reserve("test_mempool", total_size, SOCKET_ID_ANY, 0);
+	RTE_TEST_ASSERT_NOT_NULL(mz, "Cannot allocate memory");
+	virt = mz->addr;
+	iova = mz->iova;
 	mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
 				      MEMPOOL_ELT_SIZE, 0, 0,
 				      SOCKET_ID_ANY, 0);
@@ -827,7 +829,7 @@ test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 
 exit:
 	rte_mempool_free(mp);
-	rte_free(virt);
+	rte_memzone_free(mz);
 	return ret;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v2 3/3] app/test: fix mempool test in no-huge mode
  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  7:37   ` [dpdk-dev] [PATCH v2 2/3] app/test: fix mempool test on FreeBSD Dmitry Kozlyuk
@ 2021-11-01  7:37   ` Dmitry Kozlyuk
  2021-11-02 10:08   ` [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD Dmitry Kozlyuk
  3 siblings, 0 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-01  7:37 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH v2 1/3] eal/freebsd: fix IOVA mode selection
  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
  0 siblings, 0 replies; 13+ messages in thread
From: Bruce Richardson @ 2021-11-01 16:21 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev, Anatoly Burakov, benjamin.walker, stable

On Mon, Nov 01, 2021 at 09:36:59AM +0200, Dmitry Kozlyuk wrote:
> FreeBSD EAL selected IOVA mode PA even in --no-huge mode
> where PA are not available. Memory zones were created with IOVA
> equal to RTE_BAD_IOVA with no indication this field is not usable.
> 
> Change IOVA mode detection:
> 1. Always allow to force --iova-mode=va.
> 2. In --no-huge mode, disallow forcing --iova-mode=pa, and select VA.
> 3. Otherwise select IOVA mode according to bus requests, default to PA.
> In case contigmem is inaccessible, memory initialization will fail
> with a message indicating the cause.
> 
> Fixes: c2361bab70c5 ("eal: compute IOVA mode based on PA availability")
> Cc: benjamin.walker@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
> ---
>  lib/eal/freebsd/eal.c | 37 +++++++++++++++++++++++++------------
>  1 file changed, 25 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
> index 9935356ed4..519a645344 100644
> --- a/lib/eal/freebsd/eal.c
> +++ b/lib/eal/freebsd/eal.c
> @@ -677,6 +677,8 @@ rte_eal_init(int argc, char **argv)
>  	const struct rte_config *config = rte_eal_get_configuration();
>  	struct internal_config *internal_conf =
>  		eal_get_internal_configuration();
> +	bool has_phys_addr;
> +	enum rte_iova_mode iova_mode;
>  
>  	/* checks if the machine is adequate */
>  	if (!rte_cpu_is_supported()) {
> @@ -777,21 +779,32 @@ rte_eal_init(int argc, char **argv)
>  		return -1;
>  	}
>  
> -	/* if no EAL option "--iova-mode=<pa|va>", use bus IOVA scheme */
> -	if (internal_conf->iova_mode == RTE_IOVA_DC) {
> -		/* autodetect the IOVA mapping mode (default is RTE_IOVA_PA) */
> -		enum rte_iova_mode iova_mode = rte_bus_get_iommu_class();
> -
> -		if (iova_mode == RTE_IOVA_DC)
> -			iova_mode = RTE_IOVA_PA;
> -		rte_eal_get_configuration()->iova_mode = iova_mode;
> -	} else {
> -		rte_eal_get_configuration()->iova_mode =
> -			internal_conf->iova_mode;
> +	/*
> +	 * PA are only available for hugepages via contigmem.
> +	 * If contigmem is inaccessible, rte_eal_hugepage_init() will fail
> +	 * with a message describing the cause.
> +	 */
> +	has_phys_addr = internal_conf->no_hugetlbfs == 0;
> +	iova_mode = internal_conf->iova_mode;
> +	if (iova_mode == RTE_IOVA_PA && !has_phys_addr) {
> +		rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available");
> +		rte_errno = EINVAL;
> +		return -1;
> +	}
> +	if (iova_mode == RTE_IOVA_DC) {
> +		RTE_LOG(DEBUG, EAL, "Specific IOVA mode is not requested, autodetecting\n");
> +		if (has_phys_addr) {
> +			RTE_LOG(DEBUG, EAL, "Selecting IOVA mode according to bus requests\n");
> +			iova_mode = rte_bus_get_iommu_class();
> +			if (iova_mode == RTE_IOVA_DC)
> +				iova_mode = RTE_IOVA_PA;
> +		} else {
> +			iova_mode = RTE_IOVA_VA;
> +		}
>  	}
> -
>  	RTE_LOG(INFO, EAL, "Selected IOVA mode '%s'\n",
>  		rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA");
> +	rte_eal_get_configuration()->iova_mode = iova_mode;
>  

This line needs to come before the log, or else the log statement needs to
be changed to use iova_mode rather than rte_eal_iova_mode(). I'd suggest
the former option.

With that change, you can add my ack to v2:

Acked-by: Bruce Richardson <bruce.richardson@intel.com>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD
  2021-11-01  7:36 ` [dpdk-dev] [PATCH v2 0/3] Mempool fixes for FreeBSD Dmitry Kozlyuk
                     ` (2 preceding siblings ...)
  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   ` Dmitry Kozlyuk
  2021-11-02 10:08     ` [dpdk-dev] [PATCH v3 1/3] eal/freebsd: fix IOVA mode selection Dmitry Kozlyuk
                       ` (3 more replies)
  3 siblings, 4 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-02 10:08 UTC (permalink / raw)
  To: dev; +Cc: Anatoly Burakov, Olivier Matz, Yu Jiang

mempool_autotest was failing on FreeBSD,
because rte_virt2iova() is not implemented.
After the test started using memzones,
it appeared that in --no-huge memzones have iova=RTE_BAD_IOVA,
which is unexpected and contradicts with selected IOVA-as-PA.
Intead of working around this in the unit test,
fix FreeBSD EAL to select IOVA-as-VA in --no-huge mode.

v3:
  * Fix IOVA mode logging (Bruce).
v2:
  * Add the EAL changes.
  * Fix a failure with --no-huge (Olivier).

Dmitry Kozlyuk (3):
  eal/freebsd: fix IOVA mode selection
  app/test: fix mempool test on FreeBSD
  app/test: fix mempool test in no-huge mode

 app/test/test_mempool.c | 62 ++++++++++++++++++++++-------------------
 lib/eal/freebsd/eal.c   | 37 ++++++++++++++++--------
 2 files changed, 58 insertions(+), 41 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v3 1/3] eal/freebsd: fix IOVA mode selection
  2021-11-02 10:08   ` [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD Dmitry Kozlyuk
@ 2021-11-02 10:08     ` Dmitry Kozlyuk
  2021-11-02 10:08     ` [dpdk-dev] [PATCH v3 2/3] app/test: fix mempool test on FreeBSD Dmitry Kozlyuk
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-02 10:08 UTC (permalink / raw)
  To: dev; +Cc: benjamin.walker, stable, Bruce Richardson

FreeBSD EAL selected IOVA mode PA even in --no-huge mode
where PA are not available. Memory zones were created with IOVA
equal to RTE_BAD_IOVA with no indication this field is not usable.

Change IOVA mode detection:
1. Always allow to force --iova-mode=va.
2. In --no-huge mode, disallow forcing --iova-mode=pa, and select VA.
3. Otherwise select IOVA mode according to bus requests, default to PA.
In case contigmem is inaccessible, memory initialization will fail
with a message indicating the cause.

Fixes: c2361bab70c5 ("eal: compute IOVA mode based on PA availability")
Cc: benjamin.walker@intel.com
Cc: stable@dpdk.org

Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/eal/freebsd/eal.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 9935356ed4..2c2baaa691 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -677,6 +677,8 @@ rte_eal_init(int argc, char **argv)
 	const struct rte_config *config = rte_eal_get_configuration();
 	struct internal_config *internal_conf =
 		eal_get_internal_configuration();
+	bool has_phys_addr;
+	enum rte_iova_mode iova_mode;
 
 	/* checks if the machine is adequate */
 	if (!rte_cpu_is_supported()) {
@@ -777,19 +779,30 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
-	/* if no EAL option "--iova-mode=<pa|va>", use bus IOVA scheme */
-	if (internal_conf->iova_mode == RTE_IOVA_DC) {
-		/* autodetect the IOVA mapping mode (default is RTE_IOVA_PA) */
-		enum rte_iova_mode iova_mode = rte_bus_get_iommu_class();
-
-		if (iova_mode == RTE_IOVA_DC)
-			iova_mode = RTE_IOVA_PA;
-		rte_eal_get_configuration()->iova_mode = iova_mode;
-	} else {
-		rte_eal_get_configuration()->iova_mode =
-			internal_conf->iova_mode;
+	/*
+	 * PA are only available for hugepages via contigmem.
+	 * If contigmem is inaccessible, rte_eal_hugepage_init() will fail
+	 * with a message describing the cause.
+	 */
+	has_phys_addr = internal_conf->no_hugetlbfs == 0;
+	iova_mode = internal_conf->iova_mode;
+	if (iova_mode == RTE_IOVA_PA && !has_phys_addr) {
+		rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available");
+		rte_errno = EINVAL;
+		return -1;
 	}
-
+	if (iova_mode == RTE_IOVA_DC) {
+		RTE_LOG(DEBUG, EAL, "Specific IOVA mode is not requested, autodetecting\n");
+		if (has_phys_addr) {
+			RTE_LOG(DEBUG, EAL, "Selecting IOVA mode according to bus requests\n");
+			iova_mode = rte_bus_get_iommu_class();
+			if (iova_mode == RTE_IOVA_DC)
+				iova_mode = RTE_IOVA_PA;
+		} else {
+			iova_mode = RTE_IOVA_VA;
+		}
+	}
+	rte_eal_get_configuration()->iova_mode = iova_mode;
 	RTE_LOG(INFO, EAL, "Selected IOVA mode '%s'\n",
 		rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA");
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v3 2/3] app/test: fix mempool test on FreeBSD
  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     ` Dmitry Kozlyuk
  2021-11-02 10:08     ` [dpdk-dev] [PATCH v3 3/3] app/test: fix mempool test in no-huge mode Dmitry Kozlyuk
  2021-11-03 17:39     ` [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD Thomas Monjalon
  3 siblings, 0 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-02 10:08 UTC (permalink / raw)
  To: dev; +Cc: Yu Jiang, Olivier Matz, Andrew Rybchenko

FreeBSD EAL does not implement rte_mem_virt2iova() causing an error:

    EAL: Test assert test_mempool_flag_non_io_unset_when_populated_with_valid_iova
    line 781 failed: Cannot get IOVA
    test failed at test_mempool():1030
    Test Failed

Change unit test to use rte_memzone_reserve() to allocate memory,
which allows to obtain IOVA directly.

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

Reported-by: Yu Jiang <yux.jiang@intel.com>
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
---
 app/test/test_mempool.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index 4b0f6b0e7f..ced20dcdc3 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -740,16 +740,17 @@ test_mempool_events_safety(void)
 static int
 test_mempool_flag_non_io_set_when_no_iova_contig_set(void)
 {
-	void *virt = NULL;
+	const struct rte_memzone *mz = NULL;
+	void *virt;
 	rte_iova_t iova;
 	size_t size = MEMPOOL_ELT_SIZE * 16;
 	struct rte_mempool *mp = NULL;
 	int ret;
 
-	virt = rte_malloc("test_mempool", size, rte_mem_page_size());
-	RTE_TEST_ASSERT_NOT_NULL(virt, "Cannot allocate memory");
-	iova = rte_mem_virt2iova(virt);
-	RTE_TEST_ASSERT_NOT_EQUAL(iova,  RTE_BAD_IOVA, "Cannot get IOVA");
+	mz = rte_memzone_reserve("test_mempool", size, SOCKET_ID_ANY, 0);
+	RTE_TEST_ASSERT_NOT_NULL(mz, "Cannot allocate memory");
+	virt = mz->addr;
+	iova = mz->iova;
 	mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
 				      MEMPOOL_ELT_SIZE, 0, 0,
 				      SOCKET_ID_ANY, RTE_MEMPOOL_F_NO_IOVA_CONTIG);
@@ -772,14 +773,15 @@ test_mempool_flag_non_io_set_when_no_iova_contig_set(void)
 	ret = TEST_SUCCESS;
 exit:
 	rte_mempool_free(mp);
-	rte_free(virt);
+	rte_memzone_free(mz);
 	return ret;
 }
 
 static int
 test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 {
-	void *virt = NULL;
+	const struct rte_memzone *mz = NULL;
+	void *virt;
 	rte_iova_t iova;
 	size_t total_size = MEMPOOL_ELT_SIZE * MEMPOOL_SIZE;
 	size_t block_size = total_size / 3;
@@ -789,12 +791,12 @@ test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 	/*
 	 * Since objects from the pool are never used in the test,
 	 * we don't care for contiguous IOVA, on the other hand,
-	 * reiuring it could cause spurious test failures.
+	 * requiring it could cause spurious test failures.
 	 */
-	virt = rte_malloc("test_mempool", total_size, rte_mem_page_size());
-	RTE_TEST_ASSERT_NOT_NULL(virt, "Cannot allocate memory");
-	iova = rte_mem_virt2iova(virt);
-	RTE_TEST_ASSERT_NOT_EQUAL(iova,  RTE_BAD_IOVA, "Cannot get IOVA");
+	mz = rte_memzone_reserve("test_mempool", total_size, SOCKET_ID_ANY, 0);
+	RTE_TEST_ASSERT_NOT_NULL(mz, "Cannot allocate memory");
+	virt = mz->addr;
+	iova = mz->iova;
 	mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
 				      MEMPOOL_ELT_SIZE, 0, 0,
 				      SOCKET_ID_ANY, 0);
@@ -827,7 +829,7 @@ test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
 
 exit:
 	rte_mempool_free(mp);
-	rte_free(virt);
+	rte_memzone_free(mz);
 	return ret;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [dpdk-dev] [PATCH v3 3/3] app/test: fix mempool test in no-huge mode
  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
  2021-11-03 17:39     ` [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD Thomas Monjalon
  3 siblings, 0 replies; 13+ messages in thread
From: Dmitry Kozlyuk @ 2021-11-02 10:08 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Andrew Rybchenko

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD
  2021-11-02 10:08   ` [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD Dmitry Kozlyuk
                       ` (2 preceding siblings ...)
  2021-11-02 10:08     ` [dpdk-dev] [PATCH v3 3/3] app/test: fix mempool test in no-huge mode Dmitry Kozlyuk
@ 2021-11-03 17:39     ` Thomas Monjalon
  3 siblings, 0 replies; 13+ messages in thread
From: Thomas Monjalon @ 2021-11-03 17:39 UTC (permalink / raw)
  To: Dmitry Kozlyuk; +Cc: dev, Anatoly Burakov, Olivier Matz, Yu Jiang

02/11/2021 11:08, Dmitry Kozlyuk:
> mempool_autotest was failing on FreeBSD,
> because rte_virt2iova() is not implemented.
> After the test started using memzones,
> it appeared that in --no-huge memzones have iova=RTE_BAD_IOVA,
> which is unexpected and contradicts with selected IOVA-as-PA.
> Intead of working around this in the unit test,
> fix FreeBSD EAL to select IOVA-as-VA in --no-huge mode.
> 
> v3:
>   * Fix IOVA mode logging (Bruce).
> v2:
>   * Add the EAL changes.
>   * Fix a failure with --no-huge (Olivier).
> 
> Dmitry Kozlyuk (3):
>   eal/freebsd: fix IOVA mode selection
>   app/test: fix mempool test on FreeBSD
>   app/test: fix mempool test in no-huge mode

Series applied, thanks.




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-11-03 17:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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     ` [dpdk-dev] [PATCH v3 3/3] app/test: fix mempool test in no-huge mode Dmitry Kozlyuk
2021-11-03 17:39     ` [dpdk-dev] [PATCH v3 0/3] Mempool fixes for FreeBSD Thomas Monjalon

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).