[v3,1/5] mem: fix error code for segment fd API for external segs

Message ID 633b56ce7ee5551bfc456bd2f7968fd2f61b7529.1544701282.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series Allow using virtio-user without hugepages |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Anatoly Burakov Dec. 13, 2018, 11:43 a.m. UTC
  Segment fd API does not support getting segment fd's from
externally allocated memory, so return proper error code
on any attempts to do so. This changes API behavior, so
document the change as well.

Fixes: 5282bb1c3695 ("mem: allow memseg lists to be marked as external")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Tiwei Bie <tiwei.bie@intel.com>
---

Notes:
    The API is experimental, no deprecation notice needed.

 doc/guides/rel_notes/release_19_02.rst    |  6 ++++++
 lib/librte_eal/common/eal_common_memory.c | 12 ++++++++++++
 2 files changed, 18 insertions(+)
  

Comments

Maxime Coquelin Dec. 14, 2018, 9:15 a.m. UTC | #1
On 12/13/18 12:43 PM, Anatoly Burakov wrote:
> Segment fd API does not support getting segment fd's from
> externally allocated memory, so return proper error code
> on any attempts to do so. This changes API behavior, so
> document the change as well.
> 
> Fixes: 5282bb1c3695 ("mem: allow memseg lists to be marked as external")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> Acked-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
> 
> Notes:
>      The API is experimental, no deprecation notice needed.
> 
>   doc/guides/rel_notes/release_19_02.rst    |  6 ++++++
>   lib/librte_eal/common/eal_common_memory.c | 12 ++++++++++++
>   2 files changed, 18 insertions(+)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/doc/guides/rel_notes/release_19_02.rst b/doc/guides/rel_notes/release_19_02.rst
index a94fa86a7..ade41b9c8 100644
--- a/doc/guides/rel_notes/release_19_02.rst
+++ b/doc/guides/rel_notes/release_19_02.rst
@@ -84,6 +84,12 @@  API Changes
    =========================================================
 
 
+* eal: segment fd API on Linux now sets error code to ``ENOTSUP`` in more cases
+  where segment fd API is not expected to be supported:
+
+  - On attempt to get segment fd for an externally allocated memory segment
+
+
 ABI Changes
 -----------
 
diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index d47ea4938..999ba24b4 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -704,6 +704,12 @@  rte_memseg_get_fd_thread_unsafe(const struct rte_memseg *ms)
 		return -1;
 	}
 
+	/* segment fd API is not supported for external segments */
+	if (msl->external) {
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	ret = eal_memalloc_get_seg_fd(msl_idx, seg_idx);
 	if (ret < 0) {
 		rte_errno = -ret;
@@ -754,6 +760,12 @@  rte_memseg_get_fd_offset_thread_unsafe(const struct rte_memseg *ms,
 		return -1;
 	}
 
+	/* segment fd API is not supported for external segments */
+	if (msl->external) {
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	ret = eal_memalloc_get_seg_fd_offset(msl_idx, seg_idx, offset);
 	if (ret < 0) {
 		rte_errno = -ret;