| 1648 | } |
| 1649 | |
| 1650 | static int |
| 1651 | test_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 | |
| 1681 | int |
| 1682 | eal_memalloc_get_seg_fd_offset(int list_idx, int seg_idx, size_t *offset) |
no test coverage detected