app/test: fix mempool test failure on FreeBSD
Checks
Commit Message
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(-)
Comments
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
> -----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
@@ -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;
}