[dpdk-dev] [PATCH] mem: allow mem size to be specified when no hugetblfs

Paul Atkins patkins at brocade.com
Fri May 29 16:23:58 CEST 2015


The config option to turn off huge table support does not work with
the existing -m option to specify the amount of memory to use.  Add
a new option --no-huge-mem-size <mem in MB> that takes a paramater
to use as the heap size instead of the value specified by
MEMSIZE_IF_NO_HUGE_PAGE.

Signed-off-by: Paul Atkins <patkins at brocade.com>
---
 lib/librte_eal/common/eal_common_options.c |    7 +++++++
 lib/librte_eal/common/eal_internal_cfg.h   |    1 +
 lib/librte_eal/common/eal_options.h        |    2 ++
 lib/librte_eal/linuxapp/eal/eal.c          |    6 +++++-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 8fcb1ab..8b1f9f0 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -79,6 +79,7 @@ eal_long_options[] = {
 	{OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
 	{OPT_NO_HPET,           0, NULL, OPT_NO_HPET_NUM          },
 	{OPT_NO_HUGE,           0, NULL, OPT_NO_HUGE_NUM          },
+	{OPT_NO_HUGE_MEM_SIZE,  1, NULL, OPT_NO_HUGE_MEM_SIZE_NUM },
 	{OPT_NO_PCI,            0, NULL, OPT_NO_PCI_NUM           },
 	{OPT_NO_SHCONF,         0, NULL, OPT_NO_SHCONF_NUM        },
 	{OPT_PCI_BLACKLIST,     1, NULL, OPT_PCI_BLACKLIST_NUM    },
@@ -722,6 +723,11 @@ eal_parse_common_option(int opt, const char *optarg,
 		conf->no_hugetlbfs = 1;
 		break;
 
+	case OPT_NO_HUGE_MEM_SIZE_NUM:
+		conf->no_hugetlbfs_mem_size = atoi(optarg);
+		conf->no_hugetlbfs_mem_size *= 1024ULL * 1024ULL;
+		break;
+
 	case OPT_NO_PCI_NUM:
 		conf->no_pci = 1;
 		break;
@@ -907,6 +913,7 @@ eal_common_usage(void)
 	       "  -h, --help          This help\n"
 	       "\nEAL options for DEBUG use only:\n"
 	       "  --"OPT_NO_HUGE"           Use malloc instead of hugetlbfs\n"
+	       "  --"OPT_NO_HUGE_MEM_SIZE"  Heap size when no hugetblfs\n"
 	       "  --"OPT_NO_PCI"            Disable PCI\n"
 	       "  --"OPT_NO_HPET"           Disable HPET\n"
 	       "  --"OPT_NO_SHCONF"         No shared config (mmap'd files)\n"
diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
index e2ecb0d..f1a2a7d 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -64,6 +64,7 @@ struct internal_config {
 	volatile unsigned force_nchannel; /**< force number of channels */
 	volatile unsigned force_nrank;    /**< force number of ranks */
 	volatile unsigned no_hugetlbfs;   /**< true to disable hugetlbfs */
+	volatile unsigned no_hugetlbfs_mem_size; /**< mem size without hugetlbfs  */
 	volatile unsigned xen_dom0_support; /**< support app running on Xen Dom0*/
 	volatile unsigned no_pci;         /**< true to disable PCI */
 	volatile unsigned no_hpet;        /**< true to disable HPET */
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index f6714d9..39a0b94 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -65,6 +65,8 @@ enum {
 	OPT_NO_HPET_NUM,
 #define OPT_NO_HUGE           "no-huge"
 	OPT_NO_HUGE_NUM,
+#define OPT_NO_HUGE_MEM_SIZE  "no-huge-mem-size"
+	OPT_NO_HUGE_MEM_SIZE_NUM,
 #define OPT_NO_PCI            "no-pci"
 	OPT_NO_PCI_NUM,
 #define OPT_NO_SHCONF         "no-shconf"
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index bd770cf..3528a0e 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -735,7 +735,11 @@ rte_eal_init(int argc, char **argv)
 
 	if (internal_config.memory == 0 && internal_config.force_sockets == 0) {
 		if (internal_config.no_hugetlbfs)
-			internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
+			if (internal_config.no_hugetlbfs_mem_size)
+				internal_config.memory =
+					internal_config.no_hugetlbfs_mem_size;
+			else
+				internal_config.memory = MEMSIZE_IF_NO_HUGE_PAGE;
 		else
 			internal_config.memory = eal_get_hugepage_mem_size();
 	}
-- 
1.7.10.4



More information about the dev mailing list