MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_memfd_create

Function test_memfd_create

dpdk/lib/eal/linux/eal_memalloc.c:1650–1679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1648}
1649
1650static int
1651test_memfd_create(void)
1652{
1653#ifdef MEMFD_SUPPORTED
1654 const struct internal_config *internal_conf =
1655 eal_get_internal_configuration();
1656 unsigned int i;
1657 for (i = 0; i < internal_conf->num_hugepage_sizes; i++) {
1658 uint64_t pagesz = internal_conf->hugepage_info[i].hugepage_sz;
1659 int pagesz_flag = pagesz_flags(pagesz);
1660 int flags;
1661
1662 flags = pagesz_flag | RTE_MFD_HUGETLB;
1663 int fd = memfd_create("test", flags);
1664 if (fd < 0) {
1665 /* we failed - let memalloc know this isn't working */
1666 if (errno == EINVAL) {
1667 memfd_create_supported = 0;
1668 return 0; /* not supported */
1669 }
1670
1671 /* we got other error - something's wrong */
1672 return -1; /* error */
1673 }
1674 close(fd);
1675 return 1; /* supported */
1676 }
1677#endif
1678 return 0; /* not supported */
1679}
1680
1681int
1682eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset)

Callers 1

eal_memalloc_initFunction · 0.85

Calls 4

memfd_createFunction · 0.85
pagesz_flagsFunction · 0.70
closeFunction · 0.50

Tested by

no test coverage detected