[v3,3/5] 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>
Acked-by: Tiwei Bie <tiwei.bie@intel.com>
---
Notes:
v2:
- Add missing fd list allocation on setting segment
list fd
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 | 26 ++++++++++++++++++++++
3 files changed, 36 insertions(+)
Comments
On 12/13/18 12:43 PM, Anatoly Burakov wrote:
> 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>
> Acked-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
>
> Notes:
> v2:
> - Add missing fd list allocation on setting segment
> list fd
>
> 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 | 26 ++++++++++++++++++++++
> 3 files changed, 36 insertions(+)
>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
@@ -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,28 @@ 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)
+{
+ struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
+
+ /* non-single file segment mode doesn't support segment list 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;
+
+ if (alloc_list(list_idx, len) < 0)
+ return -ENOMEM;
+ }
+
+ fd_list[list_idx].memseg_list_fd = fd;
+
+ return 0;
+}
+
int
eal_memalloc_get_seg_fd(int list_idx, int seg_idx)
{