<div dir="ltr">yes, It reduces the opened files from 450 to 2.<div>Is there any down side of using --single-file-segments flag. Because if this is better why not make it the default behaviour.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 6, 2022 at 3:42 PM Dmitry Kozlyuk <<a href="mailto:dmitry.kozliuk@gmail.com">dmitry.kozliuk@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">2022-10-06 10:04 (UTC+0000), huzaifa.rahman:<br>
> Bugzilla ID: 560<br>
> <br>
> The memory subsystem is leaving open a file descriptor for each<br>
> rtemap file. This can lead to hundreds of extra open file descriptors<br>
> which has negative side effects. For example, the application may go<br>
> over its maximum file descriptor limit, or the application may be using<br>
> limited API's like select that only allow 1024 file descriptors.<br>
> <br>
> The EAL memory subsystem does not need to hold the file open.<br>
> Probably the original intention was to keep the file locked, but that is<br>
> not necessary. The Linux kernel keeps a reference count on the file,<br>
> and the mmap counts is a reference and therefore maintains the file<br>
> as locked.<br>
> <br>
> The fix is just to close the file after it is setup.<br>
> <br>
> Signed-off-by: huzaifa.rahman <<a href="mailto:huzaifa.rahman@emumba.com" target="_blank">huzaifa.rahman@emumba.com</a>><br>
> ---<br>
> lib/eal/linux/eal_memalloc.c | 3 +++<br>
> 1 file changed, 3 insertions(+)<br>
> <br>
> diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c<br>
> index f8b1588cae..955c4e4f95 100644<br>
> --- a/lib/eal/linux/eal_memalloc.c<br>
> +++ b/lib/eal/linux/eal_memalloc.c<br>
> @@ -679,6 +679,9 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,<br>
> <br>
> huge_recover_sigbus();<br>
> <br>
> + close(fd);<br>
> + fd_list[list_idx].fds[seg_idx] = -1;<br>
> +<br>
> ms->addr = addr;<br>
> ms->hugepage_sz = alloc_sz;<br>
> ms->len = alloc_sz;<br>
<br>
This breaks rte_memseg_get_fd().<br>
If memfd_create() was used to open the file descriptor,<br>
there seems no way to reopen it once closed.<br>
<br>
--single-file-segments may be used to save FD count,<br>
does using it solve your issue?<br>
</blockquote></div>