[v4] mem: warn user when running without NUMA support

Message ID b2e4acda1bb373cf241f47bc577cc887212a796a.1553868063.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v4] mem: warn user when running without NUMA support |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/intel-Performance-Testing success Performance Testing PASS
ci/mellanox-Performance-Testing fail Performance Testing issues
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly March 29, 2019, 2:01 p.m. UTC
  Running in non-legacy mode on a NUMA-enabled system without libnuma
is unsupported, so explicitly print out a warning when trying to
do so.

Running in legacy mode without libnuma is still supported whether or
not we are running with libnuma support enabled, so also fix init to
allow that scenario.

Cc: stable@dpdk.org

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

Notes:
    v4:
    - Fix missing __func__ in the print
    v3:
    - Fix compile issues

 lib/librte_eal/common/eal_options.h     |  2 ++
 lib/librte_eal/linux/eal/eal_memalloc.c |  4 ++++
 lib/librte_eal/linux/eal/eal_memory.c   | 14 ++++++++++++--
 3 files changed, 18 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon March 29, 2019, 11:27 p.m. UTC | #1
29/03/2019 15:01, Anatoly Burakov:
> Running in non-legacy mode on a NUMA-enabled system without libnuma
> is unsupported, so explicitly print out a warning when trying to
> do so.
> 
> Running in legacy mode without libnuma is still supported whether or
> not we are running with libnuma support enabled, so also fix init to
> allow that scenario.
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index 58ee9ae33..9855429e5 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -5,6 +5,8 @@ 
 #ifndef EAL_OPTIONS_H
 #define EAL_OPTIONS_H
 
+#include "getopt.h"
+
 enum {
 	/* long options mapped to a short option */
 #define OPT_HELP              "help"
diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c
index b6fb183db..36962d0b6 100644
--- a/lib/librte_eal/linux/eal/eal_memalloc.c
+++ b/lib/librte_eal/linux/eal/eal_memalloc.c
@@ -725,6 +725,10 @@  alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 			__func__, socket_id, cur_socket_id);
 		goto mapped;
 	}
+#else
+	if (rte_socket_count() > 1)
+		RTE_LOG(DEBUG, EAL, "%s(): not checking hugepage NUMA node.\n",
+				__func__);
 #endif
 
 	ms->addr = addr;
diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux/eal/eal_memory.c
index 1b96b576e..e5a0e57ff 100644
--- a/lib/librte_eal/linux/eal/eal_memory.c
+++ b/lib/librte_eal/linux/eal/eal_memory.c
@@ -50,6 +50,7 @@ 
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
+#include "eal_options.h"
 
 #define PFN_MASK_SIZE	8
 
@@ -2088,7 +2089,8 @@  memseg_primary_init_32(void)
 		socket_id = rte_socket_id_by_idx(i);
 
 #ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES
-		if (socket_id > 0)
+		/* we can still sort pages by socket in legacy mode */
+		if (!internal_config.legacy_mem && socket_id > 0)
 			break;
 #endif
 
@@ -2269,7 +2271,8 @@  memseg_primary_init(void)
 			int socket_id = rte_socket_id_by_idx(i);
 
 #ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES
-			if (socket_id > 0)
+			/* we can still sort pages by socket in legacy mode */
+			if (!internal_config.legacy_mem && socket_id > 0)
 				break;
 #endif
 			memtypes[cur_type].page_sz = hugepage_sz;
@@ -2428,6 +2431,13 @@  rte_eal_memseg_init(void)
 	} else {
 		RTE_LOG(ERR, EAL, "Cannot get current resource limits\n");
 	}
+#ifndef RTE_EAL_NUMA_AWARE_HUGEPAGES
+	if (!internal_config.legacy_mem && rte_socket_count() > 1) {
+		RTE_LOG(WARNING, EAL, "DPDK is running on a NUMA system, but is compiled without NUMA support.\n");
+		RTE_LOG(WARNING, EAL, "This will have adverse consequences for performance and usability.\n");
+		RTE_LOG(WARNING, EAL, "Please use --"OPT_LEGACY_MEM" option, or recompile with NUMA support.\n");
+	}
+#endif
 
 	return rte_eal_process_type() == RTE_PROC_PRIMARY ?
 #ifndef RTE_ARCH_64