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 485B442357; Wed, 11 Oct 2023 00:51:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6204402BA; Wed, 11 Oct 2023 00:51:14 +0200 (CEST) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by mails.dpdk.org (Postfix) with ESMTP id 3DC3F400EF for ; Wed, 11 Oct 2023 00:51:13 +0200 (CEST) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39AMKFaZ003914; Tue, 10 Oct 2023 22:51:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=HedxpKANcE4O8bgHsovsUXR8fDczQhTji3PAnChliyw=; b=CZRmI/2VD9L9hT7ppoY9545cAnw8UJouZZciwhVlZ/nV/Y8PuPjI3PK51XitcF6uaaDD M50TjcOJiLigOZt/nd2df6q4ZB8sFGrFb1dy4h1RQ+LxAKChu3/SK941isR2ZRrKtKtB Ia9Z/tAi/09NCEGRK+x5nY+vSYWySm6Xed+6fxjuQ5xXDIm1+/co5a9uO31G+1rRuu5i X1AUKaT6kxZkBt6vaR1cAIBV+BDYyZDa5f74AIGuSuoItxN2QgEXIjQXC9VYkT2tzs/S AJ8sEgxz0YH7Q0Xb+rSZXd9QeQB7TAz38LVCYc4XNVAV5u8ZCWNutw0XNCYMO5xtj68E ww== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3tnfah8sa8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Oct 2023 22:51:12 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 39AMiExq024487; Tue, 10 Oct 2023 22:51:11 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3tkhnsm4ue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Oct 2023 22:51:11 +0000 Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 39AMpAr815401676 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Oct 2023 22:51:10 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3EDA5805E; Tue, 10 Oct 2023 22:51:10 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8594058051; Tue, 10 Oct 2023 22:51:10 +0000 (GMT) Received: from ltc19u30.ibm.com (unknown [9.114.224.51]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 10 Oct 2023 22:51:10 +0000 (GMT) From: David Christensen To: thomas@monjalon.net Cc: dev@dpdk.org, David Christensen Subject: [PATCH] eal/linux: verify mmu type for DPDK support (ppc64le) Date: Tue, 10 Oct 2023 18:51:00 -0400 Message-Id: <20231010225100.335049-1-drc@linux.vnet.ibm.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: eVif5QapLsikgskGUceQ5Aj187OClvtu X-Proofpoint-ORIG-GUID: eVif5QapLsikgskGUceQ5Aj187OClvtu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-10_19,2023-10-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 malwarescore=0 clxscore=1011 spamscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=812 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310100176 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. Bugzilla ID: 1221 Suggested-by: Thomas Monjalon Signed-off-by: David Christensen --- 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