Skip to contentSkip to conversation

fix mempool when --no-huge option is set

PATCH Applied Damien Millescamps 3 participants 7 messages Jul 26, 2013 5 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover fix mempool when --no-huge option is set

This set of patch permits to use the --no-huge option to create valid mempools. However, drivers necessitating a physically contiguous memory larger than a standard page won't work in this mode.
Only vmxnet3-usermap will work in this mode among the available open source PMD.

This can be useful for old kernels (< 2.6.33) and VM with limited amount of mempory.

Damien Millescamps (2):
mem: get hugepages config
mem: fix mempool for --no-huge

 lib/librte_eal/common/include/rte_eal.h  |   13 +++++++-
 lib/librte_eal/linuxapp/eal/eal.c        |    4 ++
 lib/librte_eal/linuxapp/eal/eal_memory.c |    2 +-
 lib/librte_mempool/rte_mempool.c         |   54 +++++++++++++++++++++++++++++-
 lib/librte_mempool/rte_mempool.h         |   20 +++++++----
 5 files changed, 83 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.2.5

A message that is not in the archive (sent off-list or not yet received): cover.1374849076.git.damien.millescamps-pdR9zngts4EAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/2 mem: get hugepages config

Allow external libraries and applications to know if hugepages are enabled.

---
 lib/librte_eal/common/include/rte_eal.h |   13 ++++++++++++-
 lib/librte_eal/linuxapp/eal/eal.c       |    4 ++++
 2 files changed, 16 insertions(+), 1 deletions(-)
lib/librte_eal/common/include/rte_eal.h +12 -1
index 240530d..58a6f90 100644
@@ -214,7 +214,18 @@ int rte_eal_init(int argc, char **argv);
 	}								\
 } while(0)
 
- 
+/**
+ * Whether EAL is using huge pages (disabled by --no-huge option).
+ * The no-huge mode cannot be used with UIO poll-mode drivers like igb/ixgbe.
+ * It is useful for NIC drivers (e.g. librte_pmd_mlx4, librte_pmd_vmxnet3) or
+ * crypto drivers (e.g. librte_crypto_nitrox) provided by third-parties such
+ * as 6WIND.
+ *
+ * @return
+ *   Nonzero if hugepages are enabled.
+ */
+int rte_eal_has_hugepages(void);
+
 #ifdef __cplusplus
 }
 #endif
lib/librte_eal/linuxapp/eal/eal.c +4 -0
index ed0e9b1..52de2b6 100644
@@ -945,3 +945,7 @@ rte_eal_process_type(void)
 	return (rte_config.process_type);
 }
 
+int rte_eal_has_hugepages(void)
+{
+	return ! internal_config.no_hugetlbfs;
+}
Signature · 1 line
1.7.2.5

A message that is not in the archive (sent off-list or not yet received): 0e095118447ebbd42f2762edbda8218b13b58a1a.1374849076.git.damien.millescamps-pdR9zngts4EAvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [PATCH 1/2] mem: get hugepages config

Quoted 9 lines · Damien Millescamps

Allow external libraries and applications to know if hugepages are enabled.

---
 lib/librte_eal/common/include/rte_eal.h |   13 ++++++++++++-
 lib/librte_eal/linuxapp/eal/eal.c       |    4 ++++
 2 files changed, 16 insertions(+), 1 deletions(-)
Signature · 2 lines
Adrien Mazarguil
6WIND

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Re: [PATCH 1/2] mem: get hugepages config

26/07/2013 16:59, Adrien Mazarguil :

Quoted 8 lines · Damien Millescamps
Quoted 7 lines

Allow external libraries and applications to know if hugepages are enabled.

---

Quoted 5 lines
Quoted 3 lines
 lib/librte_eal/common/include/rte_eal.h |   13 ++++++++++++-
 lib/librte_eal/linuxapp/eal/eal.c       |    4 ++++
 2 files changed, 16 insertions(+), 1 deletions(-)

applied

Signature · 1 line
Thomas
#7 lore raw

PATCH 2/2 mem: fix mempool for --no-huge

In reply to a message not in the archive

In --no-huge mode, mempool provides objects with their associated header/trailer fitting in a standard page (usually 4KB). This means all non-UIO driver should work correctly in this mode, since UIO drivers allocate ring sizes that cannot fit in a page.

Extend rte_mempool_virt2phy to obtain the correct physical address when elements of the pool are not on the same physically contiguous memory region. This is a first step for enhancement PR #29696.

Reason for this patch is to be able to run on a kernel < 2.6.37 without the need to patch it, since all kernel below are either bugged or don't have huge page support at all (< 2.6.28).

---
 lib/librte_eal/linuxapp/eal/eal_memory.c |    2 +-
 lib/librte_mempool/rte_mempool.c         |   54 +++++++++++++++++++++++++++++-
 lib/librte_mempool/rte_mempool.h         |   20 +++++++----
 3 files changed, 67 insertions(+), 9 deletions(-)
lib/librte_eal/linuxapp/eal/eal_memory.c +1 -1
index ce0c2d8..00b5952 100644
@@ -780,7 +780,7 @@ rte_eal_hugepage_init(void)
 	/* get pointer to global configuration */
 	mcfg = rte_eal_get_configuration()->mem_config;
 
-	/* for debug purposes, hugetlbfs can be disabled */
+	/* hugetlbfs can be disabled */
 	if (internal_config.no_hugetlbfs) {
 		addr = malloc(internal_config.memory);
 		mcfg->memseg[0].phys_addr = (phys_addr_t)(uintptr_t)addr;
lib/librte_mempool/rte_mempool.c +53 -1

87 lines not on this page · raw message

lib/librte_mempool/rte_mempool.h +13 -7
index 67d7f09..33ce35c 100644
@@ -950,16 +950,22 @@ rte_mempool_empty(const struct rte_mempool *mp)
  * @return
  *   The physical address of the elt element.
  */
-static inline phys_addr_t rte_mempool_virt2phy(const struct rte_mempool *mp,
-	const void *elt)
+static inline phys_addr_t
+rte_mempool_virt2phy(const struct rte_mempool *mp, const void *elt)
 {
-	uintptr_t off;
-
-	off = (const char *)elt - (const char *)mp;
-	return mp->phys_addr + off;
+	if (rte_eal_has_hugepages()) {
+		uintptr_t offset = (const char *)elt - (const char *)mp;
+		return mp->phys_addr + offset;
+	} else {
+		/*
+		 * If huge pages are disabled, we cannot assume the
+		 * memory region to be physically contiguous.
+		 * Lookup for each element.
+		 */
+		return rte_mem_virt2phy(elt);
+	}
 }
 
-
 /**
  * Check the consistency of mempool objects.
  *
Signature · 1 line
1.7.2.5

A message that is not in the archive (sent off-list or not yet received): be4886be27e09d0f0fa1a81be866b99bbab4f081.1374849076.git.damien.millescamps-pdR9zngts4EAvxtiuMwx3w@public.gmane.org

#9 lore raw

Re: [PATCH 2/2] mem: fix mempool for --no-huge

Quoted 13 lines · Damien Millescamps

In --no-huge mode, mempool provides objects with their associated header/trailer fitting in a standard page (usually 4KB). This means all non-UIO driver should work correctly in this mode, since UIO drivers allocate ring sizes that cannot fit in a page.

Extend rte_mempool_virt2phy to obtain the correct physical address when elements of the pool are not on the same physically contiguous memory region. This is a first step for enhancement PR #29696.

Reason for this patch is to be able to run on a kernel < 2.6.37 without the need to patch it, since all kernel below are either bugged or don't have huge page support at all (< 2.6.28).

Quoted 6 lines
---
 lib/librte_eal/linuxapp/eal/eal_memory.c |    2 +-
 lib/librte_mempool/rte_mempool.c         |   54 +++++++++++++++++++++++++++++-
 lib/librte_mempool/rte_mempool.h         |   20 +++++++----
 3 files changed, 67 insertions(+), 9 deletions(-)
Signature · 2 lines
Adrien Mazarguil
6WIND

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw

Re: [PATCH 2/2] mem: fix mempool for --no-huge

26/07/2013 16:59, Adrien Mazarguil :

Quoted 17 lines · Damien Millescamps
Quoted 16 lines

In --no-huge mode, mempool provides objects with their associated header/trailer fitting in a standard page (usually 4KB). This means all non-UIO driver should work correctly in this mode, since UIO drivers allocate ring sizes that cannot fit in a page.

Extend rte_mempool_virt2phy to obtain the correct physical address when elements of the pool are not on the same physically contiguous memory region. This is a first step for enhancement PR #29696.

Reason for this patch is to be able to run on a kernel < 2.6.37 without the need to patch it, since all kernel below are either bugged or don't have huge page support at all (< 2.6.28).

---

Quoted 7 lines
Quoted 5 lines
 lib/librte_eal/linuxapp/eal/eal_memory.c |    2 +-
 lib/librte_mempool/rte_mempool.c         |   54
 +++++++++++++++++++++++++++++- lib/librte_mempool/rte_mempool.h        
 |   20 +++++++----
 3 files changed, 67 insertions(+), 9 deletions(-)

applied

Signature · 1 line
Thomas