From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, stephen@networkplumber.org
Subject: [dpdk-dev] [PATCH v2 2/4] test/extmem: extend autotest to test without IOVA table
Date: Fri, 21 Dec 2018 11:29:01 +0000 [thread overview]
Message-ID: <d585585708545763d1fc27839ce1936153e88995.1545391716.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <c822e5e21620d0fa4b2930d9e89bce44e80eac73.1545391716.git.anatoly.burakov@intel.com>
In-Reply-To: <c822e5e21620d0fa4b2930d9e89bce44e80eac73.1545390524.git.anatoly.burakov@intel.com>
Currently, only scenario with valid IOVA table is tested. Fix this
by also testing without IOVA table - in these cases, EAL should
always return RTE_BAD_IOVA for all memsegs, and contiguous memzone
allocation should fail.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
Notes:
v2:
- Improve condition checking on contiguous memzone test
- Clarify commit message
test/test/test_external_mem.c | 66 +++++++++++++++++++++++------------
1 file changed, 43 insertions(+), 23 deletions(-)
diff --git a/test/test/test_external_mem.c b/test/test/test_external_mem.c
index 6df42e3ae..06e6ccc1d 100644
--- a/test/test/test_external_mem.c
+++ b/test/test/test_external_mem.c
@@ -31,6 +31,7 @@ check_mem(void *addr, rte_iova_t *iova, size_t pgsz, int n_pages)
for (i = 0; i < n_pages; i++) {
const struct rte_memseg *ms;
void *cur = RTE_PTR_ADD(addr, pgsz * i);
+ rte_iova_t expected_iova;
ms = rte_mem_virt2memseg(cur, NULL);
if (ms == NULL) {
@@ -42,7 +43,8 @@ check_mem(void *addr, rte_iova_t *iova, size_t pgsz, int n_pages)
printf("%s():%i: VA mismatch\n", __func__, __LINE__);
return -1;
}
- if (ms->iova != iova[i]) {
+ expected_iova = (iova == NULL) ? RTE_BAD_IOVA : iova[i];
+ if (ms->iova != expected_iova) {
printf("%s():%i: IOVA mismatch\n", __func__, __LINE__);
return -1;
}
@@ -218,24 +220,29 @@ test_malloc_invalid_param(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
goto fail;
}
- /* wrong page count */
- if (rte_malloc_heap_memory_add(valid_name, addr, len,
- iova, 0, pgsz) >= 0 || rte_errno != EINVAL) {
- printf("%s():%i: Added memory with invalid parameters\n",
- __func__, __LINE__);
- goto fail;
- }
- if (rte_malloc_heap_memory_add(valid_name, addr, len,
- iova, n_pages - 1, pgsz) >= 0 || rte_errno != EINVAL) {
- printf("%s():%i: Added memory with invalid parameters\n",
- __func__, __LINE__);
- goto fail;
- }
- if (rte_malloc_heap_memory_add(valid_name, addr, len,
- iova, n_pages + 1, pgsz) >= 0 || rte_errno != EINVAL) {
- printf("%s():%i: Added memory with invalid parameters\n",
- __func__, __LINE__);
- goto fail;
+ /* the following tests are only valid if IOVA table is not NULL */
+ if (iova != NULL) {
+ /* wrong page count */
+ if (rte_malloc_heap_memory_add(valid_name, addr, len,
+ iova, 0, pgsz) >= 0 || rte_errno != EINVAL) {
+ printf("%s():%i: Added memory with invalid parameters\n",
+ __func__, __LINE__);
+ goto fail;
+ }
+ if (rte_malloc_heap_memory_add(valid_name, addr, len,
+ iova, n_pages - 1, pgsz) >= 0 ||
+ rte_errno != EINVAL) {
+ printf("%s():%i: Added memory with invalid parameters\n",
+ __func__, __LINE__);
+ goto fail;
+ }
+ if (rte_malloc_heap_memory_add(valid_name, addr, len,
+ iova, n_pages + 1, pgsz) >= 0 ||
+ rte_errno != EINVAL) {
+ printf("%s():%i: Added memory with invalid parameters\n",
+ __func__, __LINE__);
+ goto fail;
+ }
}
/* tests passed, destroy heap */
@@ -257,7 +264,7 @@ test_malloc_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
const char *heap_name = "heap";
void *ptr = NULL;
int socket_id;
- const struct rte_memzone *mz = NULL;
+ const struct rte_memzone *mz = NULL, *contig_mz = NULL;
/* create heap */
if (rte_malloc_heap_create(heap_name) != 0) {
@@ -322,12 +329,19 @@ test_malloc_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
goto fail;
}
+ /* try allocating a memzone */
+ mz = rte_memzone_reserve("heap_test", pgsz * 2, socket_id, 0);
+ if (mz == NULL) {
+ printf("%s():%i: Failed to reserve memzone\n",
+ __func__, __LINE__);
+ goto fail;
+ }
/* try allocating an IOVA-contiguous memzone - this should succeed
- * because we've set up a contiguous IOVA table.
+ * if we've set up a contiguous IOVA table, and fail if we haven't.
*/
- mz = rte_memzone_reserve("heap_test", pgsz * 2, socket_id,
+ contig_mz = rte_memzone_reserve("heap_test_contig", pgsz * 2, socket_id,
RTE_MEMZONE_IOVA_CONTIG);
- if (mz == NULL) {
+ if ((iova == NULL) != (contig_mz == NULL)) {
printf("%s():%i: Failed to reserve memzone\n",
__func__, __LINE__);
goto fail;
@@ -342,6 +356,8 @@ test_malloc_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
rte_memzone_free(mz);
mz = NULL;
+ rte_memzone_free(contig_mz);
+ contig_mz = NULL;
if (rte_malloc_heap_memory_remove(heap_name, addr, len) != 0) {
printf("%s():%i: Removing memory from heap failed\n",
@@ -356,6 +372,7 @@ test_malloc_basic(void *addr, size_t len, size_t pgsz, rte_iova_t *iova,
return 0;
fail:
+ rte_memzone_free(contig_mz);
rte_memzone_free(mz);
rte_free(ptr);
/* even if something failed, attempt to clean up */
@@ -393,6 +410,9 @@ test_external_mem(void)
ret = test_malloc_invalid_param(addr, len, pgsz, iova, n_pages);
ret |= test_malloc_basic(addr, len, pgsz, iova, n_pages);
+ /* when iova table is NULL, everything should still work */
+ ret |= test_malloc_invalid_param(addr, len, pgsz, NULL, n_pages);
+ ret |= test_malloc_basic(addr, len, pgsz, NULL, n_pages);
munmap(addr, len);
--
2.17.1
next prev parent reply other threads:[~2018-12-21 11:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-21 11:09 [dpdk-dev] [PATCH 1/4] test/extmem: refactor and rename test functions Anatoly Burakov
2018-12-21 11:09 ` [dpdk-dev] [PATCH 2/4] test/extmem: extend autotest to test without IOVA table Anatoly Burakov
2018-12-21 11:09 ` [dpdk-dev] [PATCH 3/4] test/extmem: check if memseg list is external Anatoly Burakov
2018-12-21 11:09 ` [dpdk-dev] [PATCH 4/4] test/extmem: extend test to cover non-heap API Anatoly Burakov
2018-12-21 11:29 ` [dpdk-dev] [PATCH v2 1/4] test/extmem: refactor and rename test functions Anatoly Burakov
2018-12-21 11:29 ` Anatoly Burakov [this message]
2018-12-21 11:29 ` [dpdk-dev] [PATCH v2 3/4] test/extmem: check if memseg list is external Anatoly Burakov
2018-12-21 11:29 ` [dpdk-dev] [PATCH v2 4/4] test/extmem: extend test to cover non-heap API Anatoly Burakov
2018-12-21 15:19 ` 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=d585585708545763d1fc27839ce1936153e88995.1545391716.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/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).