DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] eal/linux: verify mmu type for DPDK support (ppc64le)
@ 2023-10-10 22:51 David Christensen
  2023-10-17 12:39 ` Thomas Monjalon
  2023-10-23 23:19 ` [PATCH v2] eal/linux: " David Christensen
  0 siblings, 2 replies; 15+ messages in thread
From: David Christensen @ 2023-10-10 22:51 UTC (permalink / raw)
  To: thomas; +Cc: dev, David Christensen

IBM POWER systems support more than one type of memory management unit
(MMU).  The Power ISA 3.0 specification, which applies to P9 and later
CPUs, defined a new Radix MMU which, among other things, allows an
anonymous memory page mapping to be converted into a hugepage mapping
at a specific address. This is a required feature in DPDK so we need
to test the MMU type when POWER systems are used and provide a more
useful error message for the user when running on an unsupported
system.

Bugzilla ID: 1221
Suggested-by: Thomas Monjalon <thomas@monjalon.net>
Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
---
 lib/eal/linux/eal.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 5f4b2fb0054a..1c546564fa9c 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -910,6 +910,62 @@ is_iommu_enabled(void)
 	return n > 2;
 }
 
+/*
+ * IBM POWER systems support more than one type of memory management unit (MMU).
+ * The Power ISA 3.0 specification, which applies to P9 and later CPUs, defined
+ * a new Radix MMU which, among other things, allows an anonymous memory page
+ * mapping to be converted into a hugepage mapping at a specific address. This
+ * is a required feature in DPDK so we need to test the MMU type when POWER
+ * systems are used.
+ */
+static bool
+is_mmu_supported(void)
+{
+#ifdef RTE_ARCH_PPC_64
+	static const char proc_cpuinfo[] = "/proc/cpuinfo";
+	static const char str_mmu[] = "MMU";
+	static const char str_radix[] = "Radix";
+	char buf[512];
+	char *ret = NULL;
+	FILE *f = fopen(proc_cpuinfo, "r");
+
+	if (f == NULL) {
+		RTE_LOG(ERR, EAL, "Cannot open %s\n", proc_cpuinfo);
+		return false;
+	}
+
+	/*
+	 * Example "MMU" in /proc/cpuinfo:
+	 * ...
+	 * model	: 8335-GTW
+	 * machine	: PowerNV 8335-GTW
+	 * firmware	: OPAL
+	 * MMU		: Radix
+	 * ... or ...
+	 * model        : IBM,9009-22A
+	 * machine      : CHRP IBM,9009-22A
+	 * MMU          : Hash
+	 */
+	while (fgets(buf, sizeof(buf), f) != NULL) {
+		ret = strstr(buf, str_mmu);
+		if (ret == NULL)
+			continue;
+		ret += sizeof(str_mmu) - 1;
+		ret = strchr(ret, ':');
+		if (ret == NULL)
+			continue;
+		ret = strstr(ret, str_radix);
+		break;
+	}
+	fclose(f);
+	if (ret == NULL)
+		rte_eal_init_alert("DPDK on PPC64 requires radix-mmu.");
+	return (ret != NULL);
+#else
+	return true;
+#endif
+}
+
 static __rte_noreturn void *
 eal_worker_thread_loop(void *arg)
 {
@@ -983,6 +1039,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if mmu is supported */
+	if (!is_mmu_supported()) {
+		rte_eal_init_alert("unsupported mmu type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!__atomic_compare_exchange_n(&run_once, &has_run, 1, 0,
 					__ATOMIC_RELAXED, __ATOMIC_RELAXED)) {
 		rte_eal_init_alert("already called initialization.");
-- 
2.39.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-07-12  9:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-10 22:51 [PATCH] eal/linux: verify mmu type for DPDK support (ppc64le) David Christensen
2023-10-17 12:39 ` Thomas Monjalon
2023-10-23 21:59   ` David Christensen
2023-11-06 13:54     ` Thomas Monjalon
2023-10-23 23:19 ` [PATCH v2] eal/linux: " David Christensen
2023-10-24  2:02   ` David Christensen
2023-10-24 17:43   ` [PATCH v3] " David Christensen
2023-11-06 13:55     ` Thomas Monjalon
2023-11-30 19:18     ` [PATCH v4] eal: " David Christensen
2024-05-30 16:44       ` [PATCH v5] " David Christensen
2024-06-28 12:10         ` David Marchand
2024-07-10 23:21         ` [PATCH v6] " David Christensen
2024-07-10 23:38           ` [PATCH v7] " David Christensen
2024-07-12  9:03             ` David Marchand
     [not found]       ` <20240529183222.105731-1-drc@linux.vnet.ibm.com>
2024-06-27 21:11         ` [PATCH v5] " David Christensen

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).