diff mbox series

[v2,7/9] eal: add --in-memory option

Message ID f7b13bc0e6b8cbacb273ef949a447974f1467861.1531477505.git.anatoly.burakov@intel.com (mailing list archive)
State Superseded, archived
Headers show
Series Support running DPDK without hugetlbfs mountpoint | expand

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly July 13, 2018, 10:27 a.m. UTC
This command-line option will cause DPDK to operate entirely in
memory and not create any shared files at runtime, including any
shared configuration or hugetlbfs files. This is useful for debug
purposes, as well as for certain use cases like containers or
automatic memory cleanup.

Currently, this option acts as a strict superset of --no-shconf and
--huge-unlink commands.

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

Notes:
    RFC->v1:
    - Do not deprecate old options, instead just coopt them

 lib/librte_eal/common/eal_common_options.c | 18 ++++++++++++++----
 lib/librte_eal/common/eal_internal_cfg.h   |  4 ++++
 lib/librte_eal/common/eal_options.h        |  2 ++
 3 files changed, 20 insertions(+), 4 deletions(-)

Comments

Thomas Monjalon July 13, 2018, 12:13 p.m. UTC | #1
13/07/2018 12:27, Anatoly Burakov:
> This command-line option will cause DPDK to operate entirely in
> memory and not create any shared files at runtime, including any
> shared configuration or hugetlbfs files. This is useful for debug
> purposes, as well as for certain use cases like containers or
> automatic memory cleanup.
> 
> Currently, this option acts as a strict superset of --no-shconf and
> --huge-unlink commands.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

I would like to see some support or review for this feature.
Burakov, Anatoly July 13, 2018, 12:27 p.m. UTC | #2
On 13-Jul-18 1:13 PM, Thomas Monjalon wrote:
> 13/07/2018 12:27, Anatoly Burakov:
>> This command-line option will cause DPDK to operate entirely in
>> memory and not create any shared files at runtime, including any
>> shared configuration or hugetlbfs files. This is useful for debug
>> purposes, as well as for certain use cases like containers or
>> automatic memory cleanup.
>>
>> Currently, this option acts as a strict superset of --no-shconf and
>> --huge-unlink commands.
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> I would like to see some support or review for this feature.
> 

While the justification for it can be use-cases like running a DPDK 
process without worrying about cleaning up its hugepages afterwards 
(somewhat less of a concern since 18.05 but still a concern if primary 
crashes), it is really fixing the no-shconf/huge-unlink options to not 
be half-measures.

Both of these options effectively disable secondary processes, but don't 
do it in a consistent way - huge-unlink cleans up hugepages after 
allocating them, but leaves shared config on. No-shconf disables shared 
config, but leaves hugepages in place. Since 18.05, huge-unlink didn't 
work anyway (wasn't implemented, which was my omission), and due to EAL 
now relying on fbarray's to store some data, no-shconf wasn't working 
correctly either because even though shared config wasn't created, two 
primaries still couldn't share a prefix with --no-shconf (see the first 
patch).

So, this patchset is really an acknowledgement of the fact that both 
huge-unlink and no-shconf options are really there to disable secondary 
processes and stop leaving files on the file system. I just went one 
step further, and instead of allocating-and-then-removing hugepages 
we're not creating them in the first place, and map them anonymously 
instead.
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index df5d53648..f308b57c3 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -66,6 +66,7 @@  eal_long_options[] = {
 	{OPT_NO_HUGE,           0, NULL, OPT_NO_HUGE_NUM          },
 	{OPT_NO_PCI,            0, NULL, OPT_NO_PCI_NUM           },
 	{OPT_NO_SHCONF,         0, NULL, OPT_NO_SHCONF_NUM        },
+	{OPT_IN_MEMORY,         0, NULL, OPT_IN_MEMORY_NUM        },
 	{OPT_PCI_BLACKLIST,     1, NULL, OPT_PCI_BLACKLIST_NUM    },
 	{OPT_PCI_WHITELIST,     1, NULL, OPT_PCI_WHITELIST_NUM    },
 	{OPT_PROC_TYPE,         1, NULL, OPT_PROC_TYPE_NUM        },
@@ -1170,6 +1171,13 @@  eal_parse_common_option(int opt, const char *optarg,
 		conf->no_shconf = 1;
 		break;
 
+	case OPT_IN_MEMORY_NUM:
+		conf->in_memory = 1;
+		/* in-memory is a superset of noshconf and huge-unlink */
+		conf->no_shconf = 1;
+		conf->hugepage_unlink = 1;
+		break;
+
 	case OPT_PROC_TYPE_NUM:
 		conf->process_type = eal_parse_proc_type(optarg);
 		break;
@@ -1321,8 +1329,8 @@  eal_check_common_options(struct internal_config *internal_cfg)
 			"be specified together with --"OPT_NO_HUGE"\n");
 		return -1;
 	}
-
-	if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink) {
+	if (internal_cfg->no_hugetlbfs && internal_cfg->hugepage_unlink &&
+			!internal_cfg->in_memory) {
 		RTE_LOG(ERR, EAL, "Option --"OPT_HUGE_UNLINK" cannot "
 			"be specified together with --"OPT_NO_HUGE"\n");
 		return -1;
@@ -1330,12 +1338,12 @@  eal_check_common_options(struct internal_config *internal_cfg)
 	if (internal_config.force_socket_limits && internal_config.legacy_mem) {
 		RTE_LOG(ERR, EAL, "Option --"OPT_SOCKET_LIMIT
 			" 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");
+			"not compatible with neither --"OPT_IN_MEMORY" nor "
+			"--"OPT_HUGE_UNLINK"\n");
 		return -1;
 	}
 
@@ -1386,6 +1394,8 @@  eal_common_usage(void)
 	       "                      Set specific log level\n"
 	       "  -v                  Display version information on startup\n"
 	       "  -h, --help          This help\n"
+	       "  --"OPT_IN_MEMORY"   Operate entirely in memory. This will \n"
+	       "                      disable secondary process support\n"
 	       "\nEAL options for DEBUG use only:\n"
 	       "  --"OPT_HUGE_UNLINK"       Unlink hugepage files after init\n"
 	       "  --"OPT_NO_HUGE"           Use malloc instead of hugetlbfs\n"
diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
index d66cd0313..00ee6e06e 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -41,6 +41,10 @@  struct internal_config {
 	volatile unsigned vmware_tsc_map; /**< true to use VMware TSC mapping
 										* instead of native TSC */
 	volatile unsigned no_shconf;      /**< true if there is no shared config */
+	volatile unsigned in_memory;
+	/**< true if DPDK should operate entirely in-memory and not create any
+	 * shared files or runtime data.
+	 */
 	volatile unsigned create_uio_dev; /**< true to create /dev/uioX devices */
 	volatile enum rte_proc_type_t process_type; /**< multi-process proc type */
 	/** true to try allocating memory on specific sockets */
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index 6d92f64a8..96e166787 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -45,6 +45,8 @@  enum {
 	OPT_NO_PCI_NUM,
 #define OPT_NO_SHCONF         "no-shconf"
 	OPT_NO_SHCONF_NUM,
+#define OPT_IN_MEMORY         "in-memory"
+	OPT_IN_MEMORY_NUM,
 #define OPT_SOCKET_MEM        "socket-mem"
 	OPT_SOCKET_MEM_NUM,
 #define OPT_SOCKET_LIMIT        "socket-limit"