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,
	thomas@monjalon.net
Subject: [dpdk-dev] [PATCH v2 6/9] mem: add support for hugepage-unlink mode
Date: Fri, 13 Jul 2018 11:27:12 +0100	[thread overview]
Message-ID: <f44cfb9a672b4d1e1106cd0ec1695bd73f7e7037.1531477505.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1531477505.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1531477505.git.anatoly.burakov@intel.com>

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

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v1->v2:
    - Move check for hugepage unlink into this patch, to be
      consistent with commit message
    
    RFC->v1:
    - Use --huge-unlink only
    
    RFC->v1:
    - Use --huge-unlink only

 lib/librte_eal/common/eal_common_options.c |  6 ++++++
 lib/librte_eal/linuxapp/eal/eal_memalloc.c | 16 +++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 45ea01a8b..df5d53648 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -1332,6 +1332,12 @@ eal_check_common_options(struct internal_config *internal_cfg)
 			" is only supported in non-legacy memory mode\n");
 		return -1;
 	}
+	if (internal_cfg->single_file_segments &&
+			internal_cfg->hugepage_unlink) {
+		RTE_LOG(ERR, EAL, "Option --"OPT_SINGLE_FILE_SEGMENTS" is "
+			"not compatible with --"OPT_HUGE_UNLINK"\n");
+		return -1;
+	}
 
 	return 0;
 }
diff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
index 69604f823..d610923b8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c
@@ -489,6 +489,13 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 				__func__, strerror(errno));
 			goto resized;
 		}
+		if (internal_config.hugepage_unlink) {
+			if (unlink(path)) {
+				RTE_LOG(DEBUG, EAL, "%s(): unlink() failed: %s\n",
+					__func__, strerror(errno));
+				goto resized;
+			}
+		}
 	}
 
 	/*
@@ -587,7 +594,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.hugepage_unlink == 0 &&
+				lock(fd, LOCK_EX) == 1)
 			unlink(path);
 		close(fd);
 	}
@@ -612,6 +620,12 @@ free_seg(struct rte_memseg *ms, struct hugepage_info *hi,
 		return -1;
 	}
 
+	/* if we've already unlinked the page, nothing needs to be done */
+	if (internal_config.hugepage_unlink) {
+		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.1

  parent reply	other threads:[~2018-07-13 10:27 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01 17:15 [dpdk-dev] [PATCH 0/9] Support running DPDK without hugetlbfs mountpoint Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 1/9] fbarray: support no-shconf mode Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 2/9] ipc: add support for " Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 3/9] eal: add support for no-shconf for hugepage info Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 4/9] eal: add support for no-shconf in hugepage data file Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 5/9] eal: do not create runtime dir in no-shconf mode Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 6/9] mem: add support for hugepage-unlink mode Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 7/9] eal: add --in-memory option Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 8/9] doc: add deprecation notice for EAL command line options Anatoly Burakov
2018-06-01 17:15 ` [dpdk-dev] [PATCH 9/9] mem: support in-memory mode Anatoly Burakov
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 0/9] Support running DPDK without hugetlbfs mountpoint Anatoly Burakov
2018-07-13 12:47   ` [dpdk-dev] [PATCH v3 0/8] " Anatoly Burakov
2018-07-13 13:41     ` Thomas Monjalon
2018-07-13 12:47   ` [dpdk-dev] [PATCH v3 1/8] fbarray: support no-shconf mode Anatoly Burakov
2018-07-13 12:47   ` [dpdk-dev] [PATCH v3 2/8] ipc: add support for " Anatoly Burakov
2018-07-13 12:47   ` [dpdk-dev] [PATCH v3 3/8] eal: add support for no-shconf for hugepage info Anatoly Burakov
2018-07-13 12:48   ` [dpdk-dev] [PATCH v3 4/8] eal: add support for no-shconf in hugepage data file Anatoly Burakov
2018-07-13 12:48   ` [dpdk-dev] [PATCH v3 5/8] eal: do not create runtime dir in no-shconf mode Anatoly Burakov
2018-07-13 12:48   ` [dpdk-dev] [PATCH v3 6/8] mem: add support for hugepage-unlink mode Anatoly Burakov
2018-07-13 12:48   ` [dpdk-dev] [PATCH v3 7/8] eal: add --in-memory option Anatoly Burakov
2018-07-13 12:48   ` [dpdk-dev] [PATCH v3 8/8] mem: support in-memory mode Anatoly Burakov
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 1/9] fbarray: support no-shconf mode Anatoly Burakov
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 2/9] ipc: add support for " Anatoly Burakov
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 3/9] eal: add support for no-shconf for hugepage info Anatoly Burakov
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 4/9] eal: add support for no-shconf in hugepage data file Anatoly Burakov
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 5/9] eal: do not create runtime dir in no-shconf mode Anatoly Burakov
2018-07-13 10:27 ` Anatoly Burakov [this message]
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 7/9] eal: add --in-memory option Anatoly Burakov
2018-07-13 12:13   ` Thomas Monjalon
2018-07-13 12:27     ` Burakov, Anatoly
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 8/9] doc: add deprecation notice for EAL command line options Anatoly Burakov
2018-07-13 12:13   ` Thomas Monjalon
2018-07-13 12:29     ` Burakov, Anatoly
2018-07-13 10:27 ` [dpdk-dev] [PATCH v2 9/9] mem: support in-memory mode Anatoly Burakov
2018-07-13 12:15   ` Thomas Monjalon

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=f44cfb9a672b4d1e1106cd0ec1695bd73f7e7037.1531477505.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 \
    --cc=thomas@monjalon.net \
    /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).