From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E33AE43414; Thu, 30 Nov 2023 20:19:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E34C42EFD; Thu, 30 Nov 2023 20:19:09 +0100 (CET) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mails.dpdk.org (Postfix) with ESMTP id 5519942EF9 for ; Thu, 30 Nov 2023 20:19:08 +0100 (CET) Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AUIqWjX023712; Thu, 30 Nov 2023 19:19:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=aM5POwScd+RFZ1Fu40k536/va/qVPuodpF8kFUgzc84=; b=crZ/T/0+5lNWEEEjuzBHwwqRyd1u8ZQlX/PAdGafqQo6KevhC0XUyXaHqqNmxWSH6nqC ofYeb0gpR5wKyqcLwClie0E9G/K3aZWVFzyilJuM7z2NvdNGxpn4nFgfCYG9+xVvguP6 mAWlzP63eVS5ljvBdYi2EJ+jMaYnrif/ugY1etuaVsoGxvkV8wSY/7RQ8RT3+pVvaa6B iJ/pzjRZz3p/ugJSPIFHHpxlflYJFMqbX4ej16itMRH7/5k5uLVOxUwvVZExJOo6G3ON reLaf+lA8m26ff5EviYZ2U1RGSoXGL3GauAisGdp/hw8YlNHe5iGxmBLWRwRbI4gmsxK nA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uq022rsj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Nov 2023 19:19:03 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AUIrkX8027480; Thu, 30 Nov 2023 19:19:01 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uq022rsft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Nov 2023 19:19:01 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AUHJB7m029890; Thu, 30 Nov 2023 19:18:55 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ukvrm05h8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Nov 2023 19:18:55 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AUJIsiv44106390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Nov 2023 19:18:54 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9525C58072; Thu, 30 Nov 2023 19:18:54 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2157858063; Thu, 30 Nov 2023 19:18:54 +0000 (GMT) Received: from ltc19u30.ibm.com (unknown [9.114.224.51]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 30 Nov 2023 19:18:54 +0000 (GMT) From: David Christensen To: thomas@monjalon.net, Ruifeng Wang , Bruce Richardson , Min Zhou , David Christensen , Stanislaw Kardach , Konstantin Ananyev Cc: dev@dpdk.org Subject: [PATCH v4] eal: verify mmu type for DPDK support (ppc64le) Date: Thu, 30 Nov 2023 14:18:44 -0500 Message-Id: <20231130191844.612699-1-drc@linux.vnet.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231024174315.318408-1-drc@linux.vnet.ibm.com> References: <20231024174315.318408-1-drc@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: FQyZ3olMDQH7w_HJaaiogc3PsU0GH_5s X-Proofpoint-ORIG-GUID: AhbUuT379fiZTL_m4vl0Cx_dE1wMkDsP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-30_19,2023-11-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 clxscore=1011 spamscore=0 malwarescore=0 adultscore=0 mlxlogscore=908 mlxscore=0 phishscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311300142 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Suggested-by: Thomas Monjalon Signed-off-by: David Christensen --- 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 diff --git a/lib/eal/arm/meson.build b/lib/eal/arm/meson.build index dca1106aaeec..6fba3d6ba7b8 100644 --- a/lib/eal/arm/meson.build +++ b/lib/eal/arm/meson.build @@ -7,5 +7,6 @@ sources += files( 'rte_cpuflags.c', 'rte_cycles.c', 'rte_hypervisor.c', + 'rte_mmu.c', 'rte_power_intrinsics.c', ) diff --git a/lib/eal/arm/rte_mmu.c b/lib/eal/arm/rte_mmu.c new file mode 100644 index 000000000000..3d40bfde386a --- /dev/null +++ b/lib/eal/arm/rte_mmu.c @@ -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; +} diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 4d2e80661023..c001c917de1d 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -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 * diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 568e06e9ed91..0a6a9edc7213 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -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."); diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 57da058cec60..b22c19ff0492 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -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."); diff --git a/lib/eal/loongarch/meson.build b/lib/eal/loongarch/meson.build index 4dcc27babb9b..3acfe6c3bd77 100644 --- a/lib/eal/loongarch/meson.build +++ b/lib/eal/loongarch/meson.build @@ -7,5 +7,6 @@ sources += files( 'rte_cpuflags.c', 'rte_cycles.c', 'rte_hypervisor.c', + 'rte_mmu.c', 'rte_power_intrinsics.c', ) diff --git a/lib/eal/loongarch/rte_mmu.c b/lib/eal/loongarch/rte_mmu.c new file mode 100644 index 000000000000..3d40bfde386a --- /dev/null +++ b/lib/eal/loongarch/rte_mmu.c @@ -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; +} diff --git a/lib/eal/ppc/meson.build b/lib/eal/ppc/meson.build index 71c7ac870da6..eeeaeee240b7 100644 --- a/lib/eal/ppc/meson.build +++ b/lib/eal/ppc/meson.build @@ -7,5 +7,6 @@ sources += files( 'rte_cpuflags.c', 'rte_cycles.c', 'rte_hypervisor.c', + 'rte_mmu.c', 'rte_power_intrinsics.c', ) diff --git a/lib/eal/ppc/rte_mmu.c b/lib/eal/ppc/rte_mmu.c new file mode 100644 index 000000000000..2d090362e530 --- /dev/null +++ b/lib/eal/ppc/rte_mmu.c @@ -0,0 +1,68 @@ +/* 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 + 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(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) { + fprintf(stderr, "EAL: FATAL: %s\n", err_msg); + RTE_LOG(ERR, EAL, "%s\n", err_msg); + } + return (ret != NULL); +#elif RTE_EXEC_ENV_FREEBSD + /* + * 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 +} diff --git a/lib/eal/riscv/meson.build b/lib/eal/riscv/meson.build index dca1106aaeec..6fba3d6ba7b8 100644 --- a/lib/eal/riscv/meson.build +++ b/lib/eal/riscv/meson.build @@ -7,5 +7,6 @@ sources += files( 'rte_cpuflags.c', 'rte_cycles.c', 'rte_hypervisor.c', + 'rte_mmu.c', 'rte_power_intrinsics.c', ) diff --git a/lib/eal/riscv/rte_mmu.c b/lib/eal/riscv/rte_mmu.c new file mode 100644 index 000000000000..3d40bfde386a --- /dev/null +++ b/lib/eal/riscv/rte_mmu.c @@ -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; +} diff --git a/lib/eal/x86/meson.build b/lib/eal/x86/meson.build index d33a240e1a98..e08dffa13dcc 100644 --- a/lib/eal/x86/meson.build +++ b/lib/eal/x86/meson.build @@ -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', ) diff --git a/lib/eal/x86/rte_mmu.c b/lib/eal/x86/rte_mmu.c new file mode 100644 index 000000000000..3d40bfde386a --- /dev/null +++ b/lib/eal/x86/rte_mmu.c @@ -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.39.3