DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: przemyslawx.lal@intel.com, kuralamudhan.ramakrishnan@intel.com,
	ivan.coughlan@intel.com, tiwei.bie@intel.com,
	ray.kinsella@intel.com, maxime.coquelin@redhat.com
Subject: [dpdk-dev] [PATCH v2 5/5] test: add segment fd API test
Date: Tue, 11 Dec 2018 16:43:32 +0000	[thread overview]
Message-ID: <e31a2cde4f69ad12c1d1ec04d3aa47ca225b74d1.1544546363.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1544546363.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1544546363.git.anatoly.burakov@intel.com>

Use memory autotest to also test segment fd API. This will not do
any checks - just see if the relevant API's return success or
indicate that the API is not supported.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_memory.c | 43 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/test/test/test_memory.c b/test/test/test_memory.c
index b96bca771..3da803e4e 100644
--- a/test/test/test_memory.c
+++ b/test/test/test_memory.c
@@ -37,10 +37,44 @@ check_mem(const struct rte_memseg_list *msl __rte_unused,
 	return 0;
 }
 
+static int
+check_seg_fds(const struct rte_memseg_list *msl, const struct rte_memseg *ms,
+		void *arg __rte_unused)
+{
+	size_t offset;
+	int ret;
+
+	/* skip external segments */
+	if (msl->external)
+		return 0;
+
+	/* try segment fd first. we're in a callback, so thread-unsafe */
+	ret = rte_memseg_get_fd_thread_unsafe(ms);
+	if (ret < 0) {
+		/* ENOTSUP means segment is valid, but there is not support for
+		 * segment fd API (e.g. on FreeBSD).
+		 */
+		if (errno == ENOTSUP)
+			return 1;
+		/* all other errors are treated as failures */
+		return -1;
+	}
+
+	/* we're able to get memseg fd - try getting its offset */
+	ret = rte_memseg_get_fd_offset_thread_unsafe(ms, &offset);
+	if (ret < 0) {
+		if (errno == ENOTSUP)
+			return 1;
+		return -1;
+	}
+	return 0;
+}
+
 static int
 test_memory(void)
 {
 	uint64_t s;
+	int ret;
 
 	/*
 	 * dump the mapped memory: the python-expect script checks
@@ -59,6 +93,15 @@ test_memory(void)
 	/* try to read memory (should not segfault) */
 	rte_memseg_walk(check_mem, NULL);
 
+	/* check segment fd support */
+	ret = rte_memseg_walk(check_seg_fds, NULL);
+	if (ret == 1) {
+		printf("Segment fd API is unsupported\n");
+	} else if (ret == -1) {
+		printf("Error getting segment fd's\n");
+		return -1;
+	}
+
 	return 0;
 }
 
-- 
2.17.1

      parent reply	other threads:[~2018-12-11 16:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-13 17:54 [dpdk-dev] [PATCH 19.02 0/2] Allow using virtio without hugepages Anatoly Burakov
2018-11-13 17:54 ` [dpdk-dev] [PATCH 19.02 1/2] memalloc: allow setting up segment list fd's Anatoly Burakov
2018-11-13 17:54 ` [dpdk-dev] [PATCH 19.02 2/2] mem: use memfd for no-huge mode Anatoly Burakov
2018-11-28  4:57   ` Tiwei Bie
2018-11-28  9:11     ` Burakov, Anatoly
2018-12-11 16:43 ` [dpdk-dev] [PATCH v2 0/5] Allow using virtio without hugepages Anatoly Burakov
2018-12-13  4:53   ` Tiwei Bie
2018-12-13 11:43   ` [dpdk-dev] [PATCH v3 0/5] Allow using virtio-user " Anatoly Burakov
2018-12-20 22:01     ` Thomas Monjalon
2018-12-13 11:43   ` [dpdk-dev] [PATCH v3 1/5] mem: fix error code for segment fd API for external segs Anatoly Burakov
2018-12-14  9:15     ` Maxime Coquelin
2018-12-13 11:43   ` [dpdk-dev] [PATCH v3 2/5] memalloc: check for memfd support in segment fd API Anatoly Burakov
2018-12-14  9:19     ` Maxime Coquelin
2018-12-13 11:43   ` [dpdk-dev] [PATCH v3 3/5] memalloc: allow setting up segment list fd's Anatoly Burakov
2018-12-14 10:03     ` Maxime Coquelin
2018-12-13 11:43   ` [dpdk-dev] [PATCH v3 4/5] mem: use memfd for no-huge mode Anatoly Burakov
2018-12-13 11:59     ` Burakov, Anatoly
2018-12-14 10:06     ` Maxime Coquelin
2018-12-13 11:43   ` [dpdk-dev] [PATCH v3 5/5] test: add segment fd API test Anatoly Burakov
2018-12-14 10:09     ` Maxime Coquelin
2018-12-11 16:43 ` [dpdk-dev] [PATCH v2 1/5] mem: fix error code for segment fd API for external segs Anatoly Burakov
2018-12-11 16:43 ` [dpdk-dev] [PATCH v2 2/5] memalloc: check for memfd support in segment fd API Anatoly Burakov
2018-12-11 16:43 ` [dpdk-dev] [PATCH v2 3/5] memalloc: allow setting up segment list fd's Anatoly Burakov
2018-12-11 16:43 ` [dpdk-dev] [PATCH v2 4/5] mem: use memfd for no-huge mode Anatoly Burakov
2018-12-13  4:59   ` Tiwei Bie
2018-12-13 11:36     ` Burakov, Anatoly
2018-12-11 16:43 ` Anatoly Burakov [this message]

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=e31a2cde4f69ad12c1d1ec04d3aa47ca225b74d1.1544546363.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=ivan.coughlan@intel.com \
    --cc=kuralamudhan.ramakrishnan@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=przemyslawx.lal@intel.com \
    --cc=ray.kinsella@intel.com \
    --cc=tiwei.bie@intel.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).