[19.02,1/2] memalloc: allow setting up segment list fd's
Checks
Commit Message
Currently, only segment fd's for multi-file segments are supported,
while for memfd-backed no-huge memory we need single-file segments
mode. Add support for single-file segments in the internal API.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/bsdapp/eal/eal_memalloc.c | 6 ++++++
lib/librte_eal/common/eal_memalloc.h | 4 ++++
lib/librte_eal/linuxapp/eal/eal_memalloc.c | 16 ++++++++++++++++
3 files changed, 26 insertions(+)
@@ -61,6 +61,12 @@ eal_memalloc_set_seg_fd(int list_idx __rte_unused, int seg_idx __rte_unused,
return -ENOTSUP;
}
+int
+eal_memalloc_set_seg_list_fd(int list_idx __rte_unused, int fd __rte_unused)
+{
+ return -ENOTSUP;
+}
+
int
eal_memalloc_get_seg_fd_offset(int list_idx __rte_unused,
int seg_idx __rte_unused, size_t *offset __rte_unused)
@@ -84,6 +84,10 @@ eal_memalloc_get_seg_fd(int list_idx, int seg_idx);
int
eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd);
+/* returns 0 or -errno */
+int
+eal_memalloc_set_seg_list_fd(int list_idx, int fd);
+
int
eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset);
@@ -1529,6 +1529,10 @@ eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd)
{
struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+ /* single file segments mode doesn't support individual segment fd's */
+ if (internal_config.single_file_segments)
+ return -ENOTSUP;
+
/* if list is not allocated, allocate it */
if (fd_list[list_idx].len == 0) {
int len = mcfg->memsegs[list_idx].memseg_arr.len;
@@ -1541,6 +1545,18 @@ eal_memalloc_set_seg_fd(int list_idx, int seg_idx, int fd)
return 0;
}
+int
+eal_memalloc_set_seg_list_fd(int list_idx, int fd)
+{
+ /* non-single file segment mode doesn't support segment list fd's */
+ if (!internal_config.single_file_segments)
+ return -ENOTSUP;
+
+ fd_list[list_idx].memseg_list_fd = fd;
+
+ return 0;
+}
+
int
eal_memalloc_get_seg_fd(int list_idx, int seg_idx)
{