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

Function get_seg_memfd

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

Source from the content-addressed store, hash-verified

232}
233
234static int
235get_seg_memfd(struct hugepage_info *hi __rte_unused,
236 unsigned int list_idx __rte_unused,
237 unsigned int seg_idx __rte_unused)
238{
239#ifdef MEMFD_SUPPORTED
240 int fd;
241 char segname[250]; /* as per manpage, limit is 249 bytes plus null */
242
243 int flags = RTE_MFD_HUGETLB | pagesz_flags(hi->hugepage_sz);
244 const struct internal_config *internal_conf =
245 eal_get_internal_configuration();
246
247 if (internal_conf->single_file_segments) {
248 fd = fd_list[list_idx].memseg_list_fd;
249
250 if (fd < 0) {
251 snprintf(segname, sizeof(segname), "seg_%i", list_idx);
252 fd = memfd_create(segname, flags);
253 if (fd < 0) {
254 RTE_LOG(DEBUG, EAL, "%s(): memfd create failed: %s\n",
255 __func__, strerror(errno));
256 return -1;
257 }
258 fd_list[list_idx].memseg_list_fd = fd;
259 }
260 } else {
261 fd = fd_list[list_idx].fds[seg_idx];
262
263 if (fd < 0) {
264 snprintf(segname, sizeof(segname), "seg_%i-%i",
265 list_idx, seg_idx);
266 fd = memfd_create(segname, flags);
267 if (fd < 0) {
268 RTE_LOG(DEBUG, EAL, "%s(): memfd create failed: %s\n",
269 __func__, strerror(errno));
270 return -1;
271 }
272 fd_list[list_idx].fds[seg_idx] = fd;
273 }
274 }
275 return fd;
276#endif
277 return -1;
278}
279
280static int
281get_seg_fd(char *path, int buflen, struct hugepage_info *hi,

Callers 1

get_seg_fdFunction · 0.85

Calls 4

snprintfFunction · 0.85
memfd_createFunction · 0.85
pagesz_flagsFunction · 0.70

Tested by

no test coverage detected