DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: ray.kinsella@intel.com, kuralamudhan.ramakrishnan@intel.com,
	louise.m.daly@intel.com, bruce.richardson@intel.com,
	ferruh.yigit@intel.com, konstantin.ananyev@intel.com
Subject: [dpdk-dev] [RFC 05/10] mem: add support for no-shared-files mode
Date: Thu, 31 May 2018 15:32:28 +0100	[thread overview]
Message-ID: <968c1d9580b90d4fd7e606cd9e5d838748abdda3.1527776837.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1527776837.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1527776837.git.anatoly.burakov@intel.com>

Unlink hugepages after creating them, to honor the no shared files mode.
We cannot resize non-existing files, so make single file segments
explicitly unsupported.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal.c          |  9 +++++++++
 lib/librte_eal/linuxapp/eal/eal_memalloc.c | 23 +++++++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 32ca25dc2..7904f813e 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -690,6 +690,15 @@ eal_parse_args(int argc, char **argv)
 		goto out;
 	}
 
+	if (internal_config.single_file_segments &&
+			internal_config.no_shared_files) {
+		RTE_LOG(ERR, EAL, "Option --"OPT_SINGLE_FILE_SEGMENTS" is "
+			"incompatible with --"OPT_NO_SHARED_FILES"\n");
+		eal_usage(prgname);
+		ret = -1;
+		goto out;
+	}
+
 	if (optind >= 0)
 		argv[optind-1] = prgname;
 	ret = optind-1;
diff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
index 8c11f98c9..f57d307dd 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
@@ -512,6 +512,13 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 				__func__, strerror(errno));
 			goto resized;
 		}
+		if (internal_config.no_shared_files) {
+			if (unlink(path)) {
+				RTE_LOG(DEBUG, EAL, "%s(): unlink() failed: %s\n",
+					__func__, strerror(errno));
+				goto resized;
+			}
+		}
 	}
 
 	/*
@@ -562,8 +569,11 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 			(unsigned int)(alloc_sz >> 20));
 		goto mapped;
 	}
-	/* for non-single file segments, we can close fd here */
-	if (!internal_config.single_file_segments)
+	/* for non-single file segments or no shared files mode, we can close fd
+	 * here
+	 */
+	if (!internal_config.single_file_segments ||
+			internal_config.no_shared_files)
 		close(fd);
 
 	/* we need to trigger a write to the page to enforce page fault and
@@ -592,7 +602,8 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 		/* ignore failure, can't make it any worse */
 	} else {
 		/* only remove file if we can take out a write lock */
-		if (lock(fd, LOCK_EX) == 1)
+		if (internal_config.no_shared_files == 0 &&
+				lock(fd, LOCK_EX) == 1)
 			unlink(path);
 		close(fd);
 	}
@@ -617,6 +628,12 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi,
 		return -1;
 	}
 
+	/* if we're no in shared files mode, nothing needs to be done */
+	if (internal_config.no_shared_files) {
+		memset(ms, 0, sizeof(*ms));
+		return 0;
+	}
+
 	/* if we are not in single file segments mode, we're going to unmap the
 	 * segment and thus drop the lock on original fd, but hugepage dir is
 	 * now locked so we can take out another one without races.
-- 
2.17.0

  parent reply	other threads:[~2018-05-31 14:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 14:32 [dpdk-dev] [RFC 00/10] Support running DPDK without hugetlbfs mountpoint Anatoly Burakov
2018-05-31 14:32 ` [dpdk-dev] [RFC 01/10] eal: add --no-shared-files option Anatoly Burakov
2018-05-31 14:32 ` [dpdk-dev] [RFC 02/10] eal: make --no-shconf an alias for --no-shared-files Anatoly Burakov
2018-05-31 14:32 ` [dpdk-dev] [RFC 03/10] eal: make --huge-unlink " Anatoly Burakov
2018-05-31 14:32 ` [dpdk-dev] [RFC 04/10] fbarray: support no-shared-files mode Anatoly Burakov
2018-05-31 14:32 ` Anatoly Burakov [this message]
2018-05-31 14:32 ` [dpdk-dev] [RFC 06/10] ipc: add support for " Anatoly Burakov
2018-05-31 14:32 ` [dpdk-dev] [RFC 07/10] eal: add support for no-shared-files for hugepage info Anatoly Burakov
2018-05-31 14:32 ` [dpdk-dev] [RFC 08/10] eal: add support for no-shared-files in hugepage data file Anatoly Burakov
2018-05-31 14:32 ` [dpdk-dev] [RFC 09/10] eal: do not create runtime dir in no-shared-files mode Anatoly Burakov
2018-05-31 14:32 ` [dpdk-dev] [RFC 10/10] mem: enable memfd-based hugepage allocation Anatoly Burakov

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=968c1d9580b90d4fd7e606cd9e5d838748abdda3.1527776837.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=kuralamudhan.ramakrishnan@intel.com \
    --cc=louise.m.daly@intel.com \
    --cc=ray.kinsella@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).