Skip to contentSkip to conversation

eal/linux: verify mmu type for DPDK support (ppc64le)

PATCH Superseded David Christensen 4 participants 15 messages Oct 10, 2023 – Jul 12, 2024 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal/linux: verify mmu type for DPDK support (ppc64le)

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

---
 lib/eal/linux/eal.c | 63 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
lib/eal/linux/eal.c +63 -0
index 5f4b2fb0054a..1c546564fa9c 100644
@@ -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.");
Signature · 1 line
2.39.1
#1 lore raw

11/10/2023 00:51, David Christensen:

Quoted 60 lines

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

---

lib/eal/linux/eal.c +45 -0
+/*
+ * 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);

lib/eal/linux/eal.c is_iommu_enabled(void) · line 967

Quoted 10 lines
lib/eal/linux/eal.c +10 -0
+		break;
+	}
+	fclose(f);
+	if (ret == NULL)
+		rte_eal_init_alert("DPDK on PPC64 requires radix-mmu.");
+	return (ret != NULL);
+#else
+	return true;
+#endif
+}

I feel this function should not be implemented in the common EAL. What about adding a new function in lib/eal/ppc/ ?
And add the "return true" for other architectures?

#2 lore raw
Quoted 3 lines · Thomas Monjalon

I feel this function should not be implemented in the common EAL. What about adding a new function in lib/eal/ppc/ ?
And add the "return true" for other architectures?

Would it be more appropriate in the lib/eal/common level or lib/eal/linux only? I would expect the MMU requirement should apply to FreeBSD on ppc64le as well but IBM doesn't support or test FreeBSD internally.

Dave

#3 lore raw

23/10/2023 23:59, David Christensen:

Quoted 10 lines · Thomas Monjalon
Quoted 3 lines

I feel this function should not be implemented in the common EAL. What about adding a new function in lib/eal/ppc/ ?
And add the "return true" for other architectures?

Would it be more appropriate in the lib/eal/common level or lib/eal/linux only? I would expect the MMU requirement should apply to FreeBSD on ppc64le as well but IBM doesn't support or test FreeBSD internally.

Even if you are not testing it, I don't think you should restrict the code change to Linux.

#4 lore raw

PATCH v2 1/1 eal/linux: eal/linux: verify mmu type for DPDK support (ppc64le)

In reply to 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

---
v2:
* Replace ifdef with arch specific functions

 lib/eal/arm/meson.build       |  1 +
 lib/eal/arm/rte_mmu.c         | 11 ++++++++
 lib/eal/common/eal_private.h  |  7 +++++
 lib/eal/linux/eal.c           |  7 +++++
 lib/eal/loongarch/meson.build |  1 +
 lib/eal/loongarch/rte_mmu.c   | 11 ++++++++
 lib/eal/ppc/meson.build       |  1 +
 lib/eal/ppc/rte_mmu.c         | 53 +++++++++++++++++++++++++++++++++++
 lib/eal/riscv/meson.build     |  1 +
 lib/eal/riscv/rte_mmu.c       | 11 ++++++++
 lib/eal/x86/meson.build       |  1 +
 lib/eal/x86/rte_mmu.c         | 11 ++++++++
 12 files changed, 116 insertions(+)
 create mode 100644 lib/eal/arm/rte_mmu.c
 create mode 100644 lib/eal/loongarch/rte_mmu.c
 create mode 100644 lib/eal/ppc/rte_mmu.c
 create mode 100644 lib/eal/riscv/rte_mmu.c
 create mode 100644 lib/eal/x86/rte_mmu.c
lib/eal/arm/meson.build +1 -0
index dca1106aaeec..6fba3d6ba7b8 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/arm/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..f0002d9f89b1
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported_arch(void)
+{
+	return true;
+}
lib/eal/common/eal_private.h +7 -0
index ebd496b537cf..7d84adb5b328 100644
@@ -354,6 +354,13 @@ unsigned eal_cpu_core_id(unsigned lcore_id);
  */
 int eal_cpu_detected(unsigned lcore_id);
 
+/**
+ * Check for architecture supported MMU.
+ *
+ * This function is private to the EAL.
+ */
+bool eal_mmu_supported_arch(void);
+
 /**
  * Set TSC frequency from precise value or estimation
  *
lib/eal/linux/eal.c +7 -0
index 5f4b2fb0054a..26333934de0b 100644
@@ -983,6 +983,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported_arch()) {
+		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.");
lib/eal/loongarch/meson.build +1 -0
index 4dcc27babb9b..3acfe6c3bd77 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/loongarch/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..f0002d9f89b1
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported_arch(void)
+{
+	return true;
+}
lib/eal/ppc/meson.build +1 -0
index 71c7ac870da6..eeeaeee240b7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/ppc/rte_mmu.c new file +53 -0

53 lines not on this page · raw message

lib/eal/riscv/meson.build +1 -0
index dca1106aaeec..6fba3d6ba7b8 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/riscv/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..f0002d9f89b1
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported_arch(void)
+{
+	return true;
+}
lib/eal/x86/meson.build +1 -0
index d33a240e1a98..e08dffa13dcc 100644
@@ -7,6 +7,7 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_spinlock.c',
         'rte_power_intrinsics.c',
 )
lib/eal/x86/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..f0002d9f89b1
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported_arch(void)
+{
+	return true;
+}

--
2.39.1

#5 lore raw

Re: [PATCH v2] eal/linux: eal/linux: verify mmu type for DPDK support (ppc64le)

Quoted 15 lines · David Christensen
lib/eal/common/eal_private.h +7 -0
index ebd496b537cf..7d84adb5b328 100644
@@ -354,6 +354,13 @@ unsigned eal_cpu_core_id(unsigned lcore_id);
   */
  int eal_cpu_detected(unsigned lcore_id);
 
+/**
+ * Check for architecture supported MMU.
+ *
+ * This function is private to the EAL.
+ */
+bool eal_mmu_supported_arch(void);
+

...

Quoted 7 lines
lib/eal/ppc/rte_mmu.c new file +1 -0
new file mode 100644
index 000000000000..017a8768bce3
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: BSD-3-Clause

lib/eal/ppc/rte_mmu.c line 11

Quoted 10 lines
lib/eal/ppc/rte_mmu.c new file +10 -0
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "rte_log.h"
+#include "eal_private.h"
+
+bool
+eal_mmu_supported_arch(void)
+{
+	static const char proc_cpuinfo[] = "/proc/cpuinfo";

Belatedly recognized that I'd implemented an OS specific detection mechanism for a function in the "common" library. I'll resubmit a v3 under the "linux" subtree shortly.

Dave

#6 lore raw

PATCH v3 1/1 eal/linux: verify mmu type for DPDK support (ppc64le)

In reply to 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

---
v3:
* Move test function from "common" tree to "linux"
v2:
* Replace ifdef with arch specific functions

---
 lib/eal/arm/meson.build           |  1 +
 lib/eal/arm/rte_mmu.c             | 11 ++++++
 lib/eal/linux/eal.c               |  8 +++++
 lib/eal/linux/eal_linux_private.h | 17 ++++++++++
 lib/eal/loongarch/meson.build     |  1 +
 lib/eal/loongarch/rte_mmu.c       | 11 ++++++
 lib/eal/ppc/meson.build           |  1 +
 lib/eal/ppc/rte_mmu.c             | 56 +++++++++++++++++++++++++++++++
 lib/eal/riscv/meson.build         |  1 +
 lib/eal/riscv/rte_mmu.c           | 11 ++++++
 lib/eal/x86/meson.build           |  1 +
 lib/eal/x86/rte_mmu.c             | 11 ++++++
 12 files changed, 130 insertions(+)
 create mode 100644 lib/eal/arm/rte_mmu.c
 create mode 100644 lib/eal/linux/eal_linux_private.h
 create mode 100644 lib/eal/loongarch/rte_mmu.c
 create mode 100644 lib/eal/ppc/rte_mmu.c
 create mode 100644 lib/eal/riscv/rte_mmu.c
 create mode 100644 lib/eal/x86/rte_mmu.c
lib/eal/arm/meson.build +1 -0
index dca1106aaeec..6fba3d6ba7b8 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/arm/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..3c043be10236
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include <linux/eal_linux_private.h>
+
+bool
+eal_mmu_supported_linux_arch(void)
+{
+	return true;
+}
lib/eal/linux/eal.c +8 -0
index 5f4b2fb0054a..6f838265b15b 100644
@@ -44,6 +44,7 @@
 
 #include <telemetry_internal.h>
 #include "eal_private.h"
+#include "eal_linux_private.h"
 #include "eal_thread.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
@@ -983,6 +984,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported_linux_arch()) {
+		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.");
lib/eal/linux/eal_linux_private.h new file +17 -0
new file mode 100644
index 000000000000..b7eaac922849
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 IBM Corporation
+ */
+
+#ifndef _EAL_LINUX_PRIVATE_H_
+#define _EAL_LINUX_PRIVATE_H_
+
+#include <stdbool.h>
+
+/**
+ * Check for architecture supported MMU.
+ *
+ * This function is private to the EAL for Linux.
+ */
+bool eal_mmu_supported_linux_arch(void);
+
+#endif /* _EAL_LINUX_PRIVATE_H_ */
lib/eal/loongarch/meson.build +1 -0
index 4dcc27babb9b..3acfe6c3bd77 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/loongarch/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..3c043be10236
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include <linux/eal_linux_private.h>
+
+bool
+eal_mmu_supported_linux_arch(void)
+{
+	return true;
+}
lib/eal/ppc/meson.build +1 -0
index 71c7ac870da6..eeeaeee240b7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/ppc/rte_mmu.c new file +56 -0

56 lines not on this page · raw message

lib/eal/riscv/meson.build +1 -0
index dca1106aaeec..6fba3d6ba7b8 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/riscv/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..3c043be10236
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include <linux/eal_linux_private.h>
+
+bool
+eal_mmu_supported_linux_arch(void)
+{
+	return true;
+}
lib/eal/x86/meson.build +1 -0
index d33a240e1a98..e08dffa13dcc 100644
@@ -7,6 +7,7 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_spinlock.c',
         'rte_power_intrinsics.c',
 )
lib/eal/x86/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..3c043be10236
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include <linux/eal_linux_private.h>
+
+bool
+eal_mmu_supported_linux_arch(void)
+{
+	return true;
+}

--
2.39.1

#7 lore raw

24/10/2023 19:43, David Christensen:

Quoted 16 lines

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

---

lib/eal/linux/eal.c rte_eal_init(int argc, char **argv) · line 992

Quoted 6 lines
lib/eal/linux/eal.c +6 -0
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported_linux_arch()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}

I don't think we should restrict the MMU check to Linux.

#8 lore raw

PATCH v4 1/1 eal: verify mmu type for DPDK support (ppc64le)

In reply to 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.

All architectures other than ppc64le unconditionally report that the MMU is supported. When running with ppc64le on Linux, the MMU is tested and the actual result is returned, while running with ppc64le on FreeBSD unconditionally reports that the MMU is supported to avoid unnecessary breakage until an actual test can be implemented for that environment.

Bugzilla ID: 1221

---
 lib/eal/arm/meson.build       |  1 +
 lib/eal/arm/rte_mmu.c         | 11 ++++++
 lib/eal/common/eal_private.h  |  7 ++++
 lib/eal/freebsd/eal.c         |  7 ++++
 lib/eal/linux/eal.c           |  7 ++++
 lib/eal/loongarch/meson.build |  1 +
 lib/eal/loongarch/rte_mmu.c   | 11 ++++++
 lib/eal/ppc/meson.build       |  1 +
 lib/eal/ppc/rte_mmu.c         | 68 +++++++++++++++++++++++++++++++++++
 lib/eal/riscv/meson.build     |  1 +
 lib/eal/riscv/rte_mmu.c       | 11 ++++++
 lib/eal/x86/meson.build       |  1 +
 lib/eal/x86/rte_mmu.c         | 11 ++++++
 13 files changed, 138 insertions(+)
 create mode 100644 lib/eal/arm/rte_mmu.c
 create mode 100644 lib/eal/loongarch/rte_mmu.c
 create mode 100644 lib/eal/ppc/rte_mmu.c
 create mode 100644 lib/eal/riscv/rte_mmu.c
 create mode 100644 lib/eal/x86/rte_mmu.c
lib/eal/arm/meson.build +1 -0
index dca1106aaeec..6fba3d6ba7b8 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/arm/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..3d40bfde386a
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/common/eal_private.h +7 -0
index 4d2e80661023..c001c917de1d 100644
@@ -93,6 +93,13 @@ int rte_eal_memzone_init(void);
  */
 int rte_eal_cpu_init(void);
 
+/**
+ * Check for architecture supported MMU.
+ *
+ * This function is private to EAL.
+ */
+bool eal_mmu_supported(void);
+
 /**
  * Create memseg lists
  *
lib/eal/freebsd/eal.c +7 -0
index 568e06e9ed91..0a6a9edc7213 100644
@@ -597,6 +597,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
 					rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		rte_eal_init_alert("already called initialization.");
lib/eal/linux/eal.c +7 -0
index 57da058cec60..b22c19ff0492 100644
@@ -983,6 +983,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
 					rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		rte_eal_init_alert("already called initialization.");
lib/eal/loongarch/meson.build +1 -0
index 4dcc27babb9b..3acfe6c3bd77 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/loongarch/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..3d40bfde386a
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/ppc/meson.build +1 -0
index 71c7ac870da6..eeeaeee240b7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/ppc/rte_mmu.c new file +68 -0

68 lines not on this page · raw message

lib/eal/riscv/meson.build +1 -0
index dca1106aaeec..6fba3d6ba7b8 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/riscv/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..3d40bfde386a
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/x86/meson.build +1 -0
index d33a240e1a98..e08dffa13dcc 100644
@@ -7,6 +7,7 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_spinlock.c',
         'rte_power_intrinsics.c',
 )
lib/eal/x86/rte_mmu.c new file +11 -0
new file mode 100644
index 000000000000..3d40bfde386a
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
Signature · 1 line
2.39.3
#9 lore raw

PATCH v5 1/1 eal: verify mmu type for DPDK support (ppc64le)

From: David Christensen <[email protected]>

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 such as P8/P9 on PowerVM.

All architectures other than ppc64le unconditionally report that the MMU is supported. When running with ppc64le on Linux, the MMU is tested and the actual result is returned, while running with ppc64le on FreeBSD unconditionally reports that the MMU is supported to avoid unnecessary breakage until an actual test can be implemented for that environment (i.e. keeps existing behavior without the patch).

Bugzilla ID: 1221

---
v5:
* Rebase patch to current release, fix new checkpatch warnings
v4:
* Added test function to "freebsd"
v3:
* Move test function from "common" tree to "linux"
v2:
* Replace ifdef with arch specific functions

---
 lib/eal/arm/meson.build       |  1 +
 lib/eal/arm/rte_mmu.c         | 11 ++++++
 lib/eal/common/eal_private.h  |  7 ++++
 lib/eal/freebsd/eal.c         |  7 ++++
 lib/eal/linux/eal.c           |  7 ++++
 lib/eal/loongarch/meson.build |  1 +
 lib/eal/loongarch/rte_mmu.c   | 11 ++++++
 lib/eal/ppc/meson.build       |  1 +
 lib/eal/ppc/rte_mmu.c         | 67 +++++++++++++++++++++++++++++++++++
 lib/eal/riscv/meson.build     |  1 +
 lib/eal/riscv/rte_mmu.c       | 11 ++++++
 lib/eal/x86/meson.build       |  1 +
 lib/eal/x86/rte_mmu.c         | 11 ++++++
 13 files changed, 137 insertions(+)
 create mode 100644 lib/eal/arm/rte_mmu.c
 create mode 100644 lib/eal/loongarch/rte_mmu.c
 create mode 100644 lib/eal/ppc/rte_mmu.c
 create mode 100644 lib/eal/riscv/rte_mmu.c
 create mode 100644 lib/eal/x86/rte_mmu.c
lib/eal/arm/meson.build +1 -0
index dca1106aae..6fba3d6ba7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/arm/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..3d40bfde38
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/common/eal_private.h +7 -0
index 71523cfdb8..7c1eddcb3b 100644
@@ -94,6 +94,13 @@ int rte_eal_memzone_init(void);
  */
 int rte_eal_cpu_init(void);
 
+/**
+ * Check for architecture supported MMU.
+ *
+ * This function is private to EAL.
+ */
+bool eal_mmu_supported(void);
+
 /**
  * Create memseg lists
  *
lib/eal/freebsd/eal.c +7 -0
index bab77118e9..1229230063 100644
@@ -597,6 +597,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
 					rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		rte_eal_init_alert("already called initialization.");
lib/eal/linux/eal.c +7 -0
index fd422f1f62..d742cc98e2 100644
@@ -983,6 +983,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
 					rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		rte_eal_init_alert("already called initialization.");
lib/eal/loongarch/meson.build +1 -0
index 4dcc27babb..3acfe6c3bd 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/loongarch/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..3d40bfde38
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/ppc/meson.build +1 -0
index 71c7ac870d..eeeaeee240 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/ppc/rte_mmu.c new file +67 -0

67 lines not on this page · raw message

lib/eal/riscv/meson.build +1 -0
index dca1106aae..6fba3d6ba7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/riscv/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..3d40bfde38
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/x86/meson.build +1 -0
index d33a240e1a..e08dffa13d 100644
@@ -7,6 +7,7 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_spinlock.c',
         'rte_power_intrinsics.c',
 )
lib/eal/x86/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..3d40bfde38
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}

--
2.43.0

#10 lore raw

Re: [PATCH v5] eal: verify mmu type for DPDK support (ppc64le)

Quoted 19 lines · David Christensen

From: David Christensen <[email protected]>

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 such as P8/P9 on PowerVM.

All architectures other than ppc64le unconditionally report that the MMU is supported. When running with ppc64le on Linux, the MMU is tested and the actual result is returned, while running with ppc64le on FreeBSD unconditionally reports that the MMU is supported to avoid unnecessary breakage until an actual test can be implemented for that environment (i.e. keeps existing behavior without the patch).

Quoted 4 lines

Bugzilla ID: 1221

Sorry, this patch fell through the cracks..

Could you please check that author == sob ?

WARNING:FROM_SIGN_OFF_MISMATCH: From:/Signed-off-by: email address
mismatch: 'From: David Christensen <[email protected]>' != 'Signed-off-by: David Christensen <[email protected]>'

[snip]

lib/eal/arm/rte_mmu.c line 2

Quoted 8 lines
lib/eal/arm/rte_mmu.c new file +2 -0
new file mode 100644
index 0000000000..3d40bfde38
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023

2024* (and idem in other new files in this patch)

[snip]

Quoted 26 lines
lib/eal/freebsd/eal.c +7 -0
index bab77118e9..1229230063 100644
@@ -597,6 +597,13 @@ rte_eal_init(int argc, char **argv)
                return -1;
        }
 
+       /* verify if DPDK supported on architecture MMU */
+       if (!eal_mmu_supported()) {
+               rte_eal_init_alert("unsupported MMU type.");
+               rte_errno = ENOTSUP;
+               return -1;
+       }
+
        if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
                                        rte_memory_order_relaxed, rte_memory_order_relaxed)) {
                rte_eal_init_alert("already called initialization.");
lib/eal/linux/eal.c +0 -0
index fd422f1f62..d742cc98e2 100644
@@ -983,6 +983,13 @@ rte_eal_init(int argc, char **argv)
                return -1;
        }
 

lib/eal/linux/eal.c rte_eal_init(int argc, char **argv) · line 995

Quoted 10 lines
lib/eal/linux/eal.c +7 -0
+       /* verify if DPDK supported on architecture MMU */
+       if (!eal_mmu_supported()) {
+               rte_eal_init_alert("unsupported MMU type.");
+               rte_errno = ENOTSUP;
+               return -1;
+       }
+
        if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
                                        rte_memory_order_relaxed, rte_memory_order_relaxed)) {
                rte_eal_init_alert("already called initialization.");

We are missing an update of windows/eal.c.

[snip]

Quoted 19 lines
lib/eal/ppc/rte_mmu.c new file +13 -0
new file mode 100644
index 0000000000..72d28c5985
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "stdio.h"
+#include "string.h"
+#include "rte_log.h"
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+#ifdef RTE_EXEC_ENV_LINUX

lib/eal/ppc/rte_mmu.c line 23

Quoted 10 lines
lib/eal/ppc/rte_mmu.c new file +10 -0
+       static const char proc_cpuinfo[] = "/proc/cpuinfo";
+       static const char str_mmu[] = "MMU";
+       static const char str_radix[] = "Radix";
+       static const char err_msg[] = "DPDK on PPC64 requires radix-mmu";
+       char buf[512];
+       char *ret = NULL;
+       FILE *f = fopen(proc_cpuinfo, "r");
+
+       if (f == NULL) {
+               RTE_LOG_LINE(ERR, EAL, "Cannot open %s", proc_cpuinfo);

EAL_LOG().

Quoted 20 lines
lib/eal/ppc/rte_mmu.c new file +20 -0
+               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;

lib/eal/ppc/rte_mmu.c line 53

Quoted 10 lines
lib/eal/ppc/rte_mmu.c new file +10 -0
+               ret = strchr(ret, ':');
+               if (ret == NULL)
+                       continue;
+               ret = strstr(ret, str_radix);
+               break;
+       }
+       fclose(f);
+
+       if (ret == NULL)
+               RTE_LOG_LINE(ERR, EAL, "%s", err_msg);

err_msg is a fixed string (and only used once).

EAL_LOG(ERR, DPDK on PPC64 requires radix-mmu");

Quoted 4 lines
lib/eal/ppc/rte_mmu.c new file +4 -0
+
+       return (ret != NULL);
+#elif RTE_EXEC_ENV_FREEBSD
+       /*

lib/eal/ppc/rte_mmu.c line 67

Quoted 10 lines
lib/eal/ppc/rte_mmu.c new file +10 -0
+        * Method to detect MMU type in FreeBSD not known
+        * by this author.  Return true for now to emulate
+        * previous behavior and avoid unnecessary failures.
+        */
+       return true;
+#else
+       /* Force false for other execution environments */
+       return false;
+#endif
+}

The rest lgtm, can you send a n+1 for -rc2?

Thanks.

Signature · 1 line
David Marchand
#11 lore raw

PATCH v6 1/1 eal: verify mmu type for DPDK support (ppc64le)

In reply to 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 such as P8/P9 on PowerVM.

All architectures other than ppc64le unconditionally report that the MMU is supported. When running with ppc64le on Linux, the MMU is tested and the actual result is returned, while running with ppc64le on FreeBSD unconditionally reports that the MMU is supported to avoid unnecessary breakage until an actual test can be implemented for that environment (i.e. keeps existing behavior without the patch).

Bugzilla ID: 1221

---
v6:
* Add Windows OS, fix copyright date, use EAL_LOG(), fix "stdio.h" include
v5:
* Rebase patch to current release, fix new checkpatch warnings
v4:
* Added test function to "freebsd"
v3:
* Move test function from "common" tree to "linux"
v2:
* Replace ifdef with arch specific functions

---
 lib/eal/arm/meson.build       |  1 +
 lib/eal/arm/rte_mmu.c         | 11 ++++++
 lib/eal/common/eal_private.h  |  7 ++++
 lib/eal/freebsd/eal.c         |  7 ++++
 lib/eal/linux/eal.c           |  7 ++++
 lib/eal/loongarch/meson.build |  1 +
 lib/eal/loongarch/rte_mmu.c   | 11 ++++++
 lib/eal/ppc/meson.build       |  1 +
 lib/eal/ppc/rte_mmu.c         | 66 +++++++++++++++++++++++++++++++++++
 lib/eal/riscv/meson.build     |  1 +
 lib/eal/riscv/rte_mmu.c       | 11 ++++++
 lib/eal/windows/eal.c         |  7 ++++
 lib/eal/x86/meson.build       |  1 +
 lib/eal/x86/rte_mmu.c         | 11 ++++++
 14 files changed, 143 insertions(+)
 create mode 100644 lib/eal/arm/rte_mmu.c
 create mode 100644 lib/eal/loongarch/rte_mmu.c
 create mode 100644 lib/eal/ppc/rte_mmu.c
 create mode 100644 lib/eal/riscv/rte_mmu.c
 create mode 100644 lib/eal/x86/rte_mmu.c
lib/eal/arm/meson.build +1 -0
index dca1106aae..6fba3d6ba7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/arm/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..ebca3306dc
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2024
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/common/eal_private.h +7 -0
index e63ecd74f8..af09620426 100644
@@ -94,6 +94,13 @@ int rte_eal_memzone_init(void);
  */
 int rte_eal_cpu_init(void);
 
+/**
+ * Check for architecture supported MMU.
+ *
+ * This function is private to EAL.
+ */
+bool eal_mmu_supported(void);
+
 /**
  * Create memseg lists
  *
lib/eal/freebsd/eal.c +7 -0
index bab77118e9..1229230063 100644
@@ -597,6 +597,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
 					rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		rte_eal_init_alert("already called initialization.");
lib/eal/linux/eal.c +7 -0
index fd422f1f62..d742cc98e2 100644
@@ -983,6 +983,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
 					rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		rte_eal_init_alert("already called initialization.");
lib/eal/loongarch/meson.build +1 -0
index 4dcc27babb..3acfe6c3bd 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/loongarch/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..ebca3306dc
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2024
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/ppc/meson.build +1 -0
index 71c7ac870d..eeeaeee240 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/ppc/rte_mmu.c new file +66 -0

66 lines not on this page · raw message

lib/eal/riscv/meson.build +1 -0
index dca1106aae..6fba3d6ba7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/riscv/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..ebca3306dc
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2024
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/windows/eal.c +7 -0
index 52f0e7462d..a75395d6cf 100644
@@ -295,6 +295,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+        if (!eal_mmu_supported()) {
+                rte_eal_init_alert("Unsupported MMU type.");
+                rte_errno = ENOTSUP;
+                return -1;
+        }
+
 	if (rte_eal_cpu_init() < 0) {
 		rte_eal_init_alert("Cannot detect lcores.");
 		rte_errno = ENOTSUP;
lib/eal/x86/meson.build +1 -0
index d33a240e1a..e08dffa13d 100644
@@ -7,6 +7,7 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_spinlock.c',
         'rte_power_intrinsics.c',
 )
lib/eal/x86/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..ebca3306dc
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2024
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}

--
2.43.0

#12 lore raw

PATCH v7 1/1 eal: verify mmu type for DPDK support (ppc64le)

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 such as P8/P9 on PowerVM.

All architectures other than ppc64le unconditionally report that the MMU is supported. When running with ppc64le on Linux, the MMU is tested and the actual result is returned, while running with ppc64le on FreeBSD unconditionally reports that the MMU is supported to avoid unnecessary breakage until an actual test can be implemented for that environment (i.e. keeps existing behavior without the patch).

Bugzilla ID: 1221

---
v7:
* Fix space/indent errors
v6:
* Add Windows OS, fix copyright date, use EAL_LOG(), fix "stdio.h" include
v5:
* Rebase patch to current release, fix new checkpatch warnings
v4:
* Added test function to "freebsd"
v3:
* Move test function from "common" tree to "linux"
v2:
* Replace ifdef with arch specific functions

---
 lib/eal/arm/meson.build       |  1 +
 lib/eal/arm/rte_mmu.c         | 11 ++++++
 lib/eal/common/eal_private.h  |  7 ++++
 lib/eal/freebsd/eal.c         |  7 ++++
 lib/eal/linux/eal.c           |  7 ++++
 lib/eal/loongarch/meson.build |  1 +
 lib/eal/loongarch/rte_mmu.c   | 11 ++++++
 lib/eal/ppc/meson.build       |  1 +
 lib/eal/ppc/rte_mmu.c         | 66 +++++++++++++++++++++++++++++++++++
 lib/eal/riscv/meson.build     |  1 +
 lib/eal/riscv/rte_mmu.c       | 11 ++++++
 lib/eal/windows/eal.c         |  7 ++++
 lib/eal/x86/meson.build       |  1 +
 lib/eal/x86/rte_mmu.c         | 11 ++++++
 14 files changed, 143 insertions(+)
 create mode 100644 lib/eal/arm/rte_mmu.c
 create mode 100644 lib/eal/loongarch/rte_mmu.c
 create mode 100644 lib/eal/ppc/rte_mmu.c
 create mode 100644 lib/eal/riscv/rte_mmu.c
 create mode 100644 lib/eal/x86/rte_mmu.c
lib/eal/arm/meson.build +1 -0
index dca1106aae..6fba3d6ba7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/arm/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..ebca3306dc
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2024
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/common/eal_private.h +7 -0
index e63ecd74f8..af09620426 100644
@@ -94,6 +94,13 @@ int rte_eal_memzone_init(void);
  */
 int rte_eal_cpu_init(void);
 
+/**
+ * Check for architecture supported MMU.
+ *
+ * This function is private to EAL.
+ */
+bool eal_mmu_supported(void);
+
 /**
  * Create memseg lists
  *
lib/eal/freebsd/eal.c +7 -0
index bab77118e9..1229230063 100644
@@ -597,6 +597,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
 					rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		rte_eal_init_alert("already called initialization.");
lib/eal/linux/eal.c +7 -0
index fd422f1f62..d742cc98e2 100644
@@ -983,6 +983,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
 					rte_memory_order_relaxed, rte_memory_order_relaxed)) {
 		rte_eal_init_alert("already called initialization.");
lib/eal/loongarch/meson.build +1 -0
index 4dcc27babb..3acfe6c3bd 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/loongarch/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..ebca3306dc
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2024
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/ppc/meson.build +1 -0
index 71c7ac870d..eeeaeee240 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/ppc/rte_mmu.c new file +66 -0

66 lines not on this page · raw message

lib/eal/riscv/meson.build +1 -0
index dca1106aae..6fba3d6ba7 100644
@@ -7,5 +7,6 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_power_intrinsics.c',
 )
lib/eal/riscv/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..ebca3306dc
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2024
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}
lib/eal/windows/eal.c +7 -0
index 52f0e7462d..28b78a95a6 100644
@@ -295,6 +295,13 @@ rte_eal_init(int argc, char **argv)
 		return -1;
 	}
 
+	/* verify if DPDK supported on architecture MMU */
+	if (!eal_mmu_supported()) {
+		rte_eal_init_alert("Unsupported MMU type.");
+		rte_errno = ENOTSUP;
+		return -1;
+	}
+
 	if (rte_eal_cpu_init() < 0) {
 		rte_eal_init_alert("Cannot detect lcores.");
 		rte_errno = ENOTSUP;
lib/eal/x86/meson.build +1 -0
index d33a240e1a..e08dffa13d 100644
@@ -7,6 +7,7 @@ sources += files(
         'rte_cpuflags.c',
         'rte_cycles.c',
         'rte_hypervisor.c',
+        'rte_mmu.c',
         'rte_spinlock.c',
         'rte_power_intrinsics.c',
 )
lib/eal/x86/rte_mmu.c new file +11 -0
new file mode 100644
index 0000000000..ebca3306dc
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2024
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+	return true;
+}

--
2.43.0

#13 lore raw

Re: [PATCH v7] eal: verify mmu type for DPDK support (ppc64le)

Quoted 17 lines · 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 such as P8/P9 on PowerVM.

All architectures other than ppc64le unconditionally report that the MMU is supported. When running with ppc64le on Linux, the MMU is tested and the actual result is returned, while running with ppc64le on FreeBSD unconditionally reports that the MMU is supported to avoid unnecessary breakage until an actual test can be implemented for that environment (i.e. keeps existing behavior without the patch).

Quoted 5 lines

Bugzilla ID: 1221

Applied, thanks.

Signature · 1 line
David Marchand

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

#15 lore raw

Re: [PATCH v5] eal: verify mmu type for DPDK support (ppc64le)

Quoted 9 lines · 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 such as P8/P9 on PowerVM.

Quoted 8 lines

All architectures other than ppc64le unconditionally report that the MMU is supported. When running with ppc64le on Linux, the MMU is tested and the actual result is returned, while running with ppc64le on FreeBSD unconditionally reports that the MMU is supported to avoid unnecessary breakage until an actual test can be implemented for that environment (i.e. keeps existing behavior without the patch).

Bugzilla ID: 1221

Any chance I'll receive a review for this patch in this release cycle or should I go ahead and mark the Bugzilla as will not address?

Dave