DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Anatoly Burakov <anatoly.burakov@intel.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH] mem: close rtemap files
Date: Mon, 19 Oct 2020 08:42:35 -0700
Message-ID: <20201019154235.17799-1-stephen@networkplumber.org> (raw)

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 one line just close the file after it is setup.

Fixes: 582bed1e1d1d ("mem: support mapping hugepages at runtime")
Cc: anatoly.burakov@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
 lib/librte_eal/linux/eal_memalloc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_eal/linux/eal_memalloc.c b/lib/librte_eal/linux/eal_memalloc.c
index 6dc1b2baecdc..99600adda568 100644
--- a/lib/librte_eal/linux/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal_memalloc.c
@@ -651,6 +651,12 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
+	/*
+	 * reference count is held by mmap() now
+	 * don't need to hold file open to keep it locked
+	 */
+	close(fd);
 	ms->addr = addr;
 	ms->hugepage_sz = alloc_sz;
 	ms->len = alloc_sz;

             reply	other threads:[~2020-10-19 15:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 15:42 Stephen Hemminger [this message]
2020-10-19 16:23 ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201019154235.17799-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git