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 5C5C8455D9; Thu, 11 Jul 2024 01:38:30 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 45DA84065B; Thu, 11 Jul 2024 01:38:30 +0200 (CEST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by mails.dpdk.org (Postfix) with ESMTP id 8F2A6402C0 for ; Thu, 11 Jul 2024 01:38:28 +0200 (CEST) Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46ANTI04007496; Wed, 10 Jul 2024 23:38:25 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=LRM+udjqMjvO/ WQ3Cd3QPST1s1ccd7z+76j5eGthjfQ=; b=KdX+LsGBUvtiHOjaSyODAlW2HolT9 XFUM5gd9FRXFPCe7aupsKS6PVzbflWno7Sp+BgHQSAtcke7FsMTBxF24Z5ob+4RJ JpV8ADlNm0pCbhpT2ehUuDb4wGWr6EqPrkIaupAHdmXgLJyT4rjbMkIEeXvJqGq7 42FA8ZpuruSjwxzq3r/WpwW8mzFePHL+BLy0BwT1fma59Eu5w2/douF4pnrftYqP xbgP5t8NsJLOT+bMjMacCWB6ut+rXTthXROItJ4BZ2ZItd7j13AiItCbXxoWceoK lb6zhlBJ5mY7+zpwwQnWOSdA/ilge0nNmpoGt7kq5de4i9ke/D1Wa9YgQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40a40qr0hp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2024 23:38:24 +0000 (GMT) Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 46ANcObw020925; Wed, 10 Jul 2024 23:38:24 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40a40qr0hj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2024 23:38:24 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46ALfFFr013988; Wed, 10 Jul 2024 23:38:23 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 407jy3dges-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jul 2024 23:38:23 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 46ANcKvS25166582 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jul 2024 23:38:22 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 77A0D58054; Wed, 10 Jul 2024 23:38:20 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B606C5805C; Wed, 10 Jul 2024 23:38:19 +0000 (GMT) Received: from ltcwspoon18.bm.com (unknown [9.40.194.38]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 10 Jul 2024 23:38:19 +0000 (GMT) From: David Christensen To: thomas@monjalon.net, Ruifeng Wang , Tyler Retzlaff , Bruce Richardson , Min Zhou , David Christensen , Stanislaw Kardach , Dmitry Kozlyuk , Pallavi Kadam , Konstantin Ananyev Cc: dev@dpdk.org, David Marchand Subject: [PATCH v7] eal: verify mmu type for DPDK support (ppc64le) Date: Wed, 10 Jul 2024 19:38:16 -0400 Message-ID: <20240710233817.3638231-1-drc@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240710232122.3581128-1-drc@linux.ibm.com> References: <20240710232122.3581128-1-drc@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: JBRX2GYmuEQlImpNvBIWXV8VrnrCFpg- X-Proofpoint-GUID: lucyFNku11Oqs9Oj1WTSKrKsyy1Bj-8Q X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-10_18,2024-07-10_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 suspectscore=0 impostorscore=0 mlxlogscore=881 priorityscore=1501 mlxscore=0 spamscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407100167 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 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 Suggested-by: Thomas Monjalon Signed-off-by: David Christensen Reviewed-by: David Marchand --- 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 diff --git a/lib/eal/arm/meson.build b/lib/eal/arm/meson.build index dca1106aae..6fba3d6ba7 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 0000000000..ebca3306dc --- /dev/null +++ b/lib/eal/arm/rte_mmu.c @@ -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; +} diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index e63ecd74f8..af09620426 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -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 * diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index bab77118e9..1229230063 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 fd422f1f62..d742cc98e2 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 4dcc27babb..3acfe6c3bd 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 0000000000..ebca3306dc --- /dev/null +++ b/lib/eal/loongarch/rte_mmu.c @@ -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; +} diff --git a/lib/eal/ppc/meson.build b/lib/eal/ppc/meson.build index 71c7ac870d..eeeaeee240 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 0000000000..276d934dcf --- /dev/null +++ b/lib/eal/ppc/rte_mmu.c @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (C) IBM Corporation 2024 + */ + +#include +#include +#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"; + char buf[512]; + char *ret = NULL; + FILE *f = fopen(proc_cpuinfo, "r"); + + if (f == NULL) { + EAL_LOG(ERR, "Cannot open %s", 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) + EAL_LOG(ERR, "DPDK on PPC64 requires radix-mmu"); + + 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 dca1106aae..6fba3d6ba7 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 0000000000..ebca3306dc --- /dev/null +++ b/lib/eal/riscv/rte_mmu.c @@ -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; +} diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index 52f0e7462d..28b78a95a6 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -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; diff --git a/lib/eal/x86/meson.build b/lib/eal/x86/meson.build index d33a240e1a..e08dffa13d 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 0000000000..ebca3306dc --- /dev/null +++ b/lib/eal/x86/rte_mmu.c @@ -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