DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] mem: close rtemap files
@ 2022-10-06 10:04 huzaifa.rahman
  2022-10-06 10:42 ` Dmitry Kozlyuk
  0 siblings, 1 reply; 4+ messages in thread
From: huzaifa.rahman @ 2022-10-06 10:04 UTC (permalink / raw)
  To: anatoly.burakov; +Cc: dev, stephen, huzaifa.rahman

Bugzilla ID: 560

The memory subsystem is leaving open a file descriptor for each
rtemap file. This can lead to hundreds of extra open file descriptors
which has negative side effects. For example, the application may go
over its maximum file descriptor limit, or the application may be using
limited API's like select that only allow 1024 file descriptors.

The EAL memory subsystem does not need to hold the file open.
Probably the original intention was to keep the file locked, but that is
not necessary. The Linux kernel keeps a reference count on the file,
and the mmap counts is a reference and therefore maintains the file
as locked.

The fix is just to close the file after it is setup.

Signed-off-by: huzaifa.rahman <huzaifa.rahman@emumba.com>
---
 lib/eal/linux/eal_memalloc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c
index f8b1588cae..955c4e4f95 100644
--- a/lib/eal/linux/eal_memalloc.c
+++ b/lib/eal/linux/eal_memalloc.c
@@ -679,6 +679,9 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 
 	huge_recover_sigbus();
 
+	close(fd);
+	fd_list[list_idx].fds[seg_idx] = -1;
+
 	ms->addr = addr;
 	ms->hugepage_sz = alloc_sz;
 	ms->len = alloc_sz;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-20 10:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06 10:04 [PATCH] mem: close rtemap files huzaifa.rahman
2022-10-06 10:42 ` Dmitry Kozlyuk
2022-10-20 10:12   ` Huzaifa Rahman
2022-10-20 10:46     ` Dmitry Kozlyuk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).