From nobody Wed Feb 11 04:00:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8565C76188 for ; Tue, 4 Apr 2023 21:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234583AbjDDVPk (ORCPT ); Tue, 4 Apr 2023 17:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236437AbjDDVPN (ORCPT ); Tue, 4 Apr 2023 17:15:13 -0400 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3440149DE for ; Tue, 4 Apr 2023 14:15:07 -0700 (PDT) Received: from pps.filterd (m0150241.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334L2OUm011267; Tue, 4 Apr 2023 21:14:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=BJHA943ji6p+WFfL+5qIIveTVtDXjl/o6BKXr5YMnh8=; b=lKq6xQu16UYYqXESCBJV25i/8da8rgn1uGOt82uqvZBbDyrtOR5y8MVwYNcM/UeVRaQL /vhH1eUHJAGIpGibB9zMzb5IrixINx1MgRs85Slb2Jv2rm2dSLApbkcz2QNK5TegNkTb edHcjbgH/c3uOHit2hgumlFAoU1aORKkQoME1BEOLNmASZNWR2i6ruMFhd8JLXpbd/gt NrlbfNCQxU3+97q3b29/ztvxHRuR6U/xu7txYJSior1IoAA1GBf4DAlTYzSoK2Y5iheS EDepxISSS1JK7ng48Fp/HRzdmXR1c0c2A0ToNGVuSZOrxgkwXqYXhyhc+V1KKZVP78EI QQ== Received: from p1lg14880.it.hpe.com (p1lg14880.it.hpe.com [16.230.97.201]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3prnwpb2tm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 21:14:34 +0000 Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14880.it.hpe.com (Postfix) with ESMTPS id 1292A80025F; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id A35BE80AB06; Tue, 4 Apr 2023 21:14:33 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id F24AC30062B11; Tue, 4 Apr 2023 16:14:31 -0500 (CDT) From: Steve Wahl To: Steve Wahl , Dimitri Sivanich , Russ Anderson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v5 1/8] x86/platform/uv: Add platform resolving #defines for misc GAM_MMIOH_REDIRECT* Date: Tue, 4 Apr 2023 16:14:24 -0500 Message-Id: <20230404211431.776248-2-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404211431.776248-1-steve.wahl@hpe.com> References: <20230404211431.776248-1-steve.wahl@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 6eiDwa7ZVqrg9ZozHHgntQGk6-WYErCy X-Proofpoint-GUID: 6eiDwa7ZVqrg9ZozHHgntQGk6-WYErCy X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_12,2023-04-04_05,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=977 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Upcoming changes will require use of new #defines UVH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK and UVH_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK, which provide the appropriate values on different uv platforms. Also, fix typo that defined a couple of "*_CONFIG0_*" values twice where "*_CONFIG1_*" was intended. Signed-off-by: Steve Wahl --- arch/x86/include/asm/uv/uv_mmrs.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/uv/uv_mmrs.h b/arch/x86/include/asm/uv/uv= _mmrs.h index 57fa67373262..bb45812889dd 100644 --- a/arch/x86/include/asm/uv/uv_mmrs.h +++ b/arch/x86/include/asm/uv/uv_mmrs.h @@ -4199,6 +4199,13 @@ union uvh_rh_gam_mmioh_overlay_config1_u { #define UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_SHFT 0 #define UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK 0x0000000000007fffUL =20 +/* UVH common defines */ +#define UVH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK ( \ + is_uv(UV4A) ? UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : \ + is_uv(UV4) ? UV4H_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : \ + is_uv(UV3) ? UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK : \ + 0) + =20 union uvh_rh_gam_mmioh_redirect_config0_u { unsigned long v; @@ -4247,8 +4254,8 @@ union uvh_rh_gam_mmioh_redirect_config0_u { 0) =20 /* UV4A unique defines */ -#define UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_SHFT 0 -#define UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK 0x0000000000000fffUL +#define UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_SHFT 0 +#define UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK 0x0000000000000fffUL =20 /* UV4 unique defines */ #define UV4H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_SHFT 0 @@ -4258,6 +4265,13 @@ union uvh_rh_gam_mmioh_redirect_config0_u { #define UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_SHFT 0 #define UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK 0x0000000000007fffUL =20 +/* UVH common defines */ +#define UVH_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK ( \ + is_uv(UV4A) ? UV4AH_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK : \ + is_uv(UV4) ? UV4H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK : \ + is_uv(UV3) ? UV3H_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK : \ + 0) + =20 union uvh_rh_gam_mmioh_redirect_config1_u { unsigned long v; --=20 2.26.2 From nobody Wed Feb 11 04:00:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56445C6FD1D for ; Tue, 4 Apr 2023 21:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236492AbjDDVPU (ORCPT ); Tue, 4 Apr 2023 17:15:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236048AbjDDVPJ (ORCPT ); Tue, 4 Apr 2023 17:15:09 -0400 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A53D49D6 for ; Tue, 4 Apr 2023 14:15:05 -0700 (PDT) Received: from pps.filterd (m0150245.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334Kek2K004693; Tue, 4 Apr 2023 21:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=rw11ZEDdVmZVNnDftNTm7kbEAWM1cLoAsbf4DeGCg54=; b=YAA/aOx6hq9qQgZr3EeT/CMedwyQg3vKqgVomNYxqgDDN7TCHNXfbagVwyY8+k3AMdcL Tlg6Xwsq+/BHdCS+OeFke2lW4bufuObyqDUMAzujk/uKwndzBRqNFo1upLXA6HvVDCPa 7fuESsjvSbJAFkyxtd2js0dMKsNSvQ4sq+tJraJrBaCc3ouFng5zQLsy6cuqviyAsR9g 9cO2hk7OEbcKuJpQD61kG/iHTW7THF2VaZBqrc3sDbd4lkP1+4RnJkVMYcKacfWLbKC4 p4CjF8Pha9UC4f/9MH+9KQMapht6FPgtFyYJCDNcVF7Brlc5CqkEJgm9+4CdKP3zmO6O 3Q== Received: from p1lg14878.it.hpe.com (p1lg14878.it.hpe.com [16.230.97.204]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3prtvegbcn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 21:14:34 +0000 Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14878.it.hpe.com (Postfix) with ESMTPS id E121C13060; Tue, 4 Apr 2023 21:14:33 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 2F4D780D6A3; Tue, 4 Apr 2023 21:14:32 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id F2E3730313040; Tue, 4 Apr 2023 16:14:31 -0500 (CDT) From: Steve Wahl To: Steve Wahl , Dimitri Sivanich , Russ Anderson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v5 2/8] x86/platform/uv: Introduce helper function uv_pnode_to_socket. Date: Tue, 4 Apr 2023 16:14:25 -0500 Message-Id: <20230404211431.776248-3-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404211431.776248-1-steve.wahl@hpe.com> References: <20230404211431.776248-1-steve.wahl@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: _riF_xFxE9MV_VdrSf_Rp_drw8qYdC0n X-Proofpoint-ORIG-GUID: _riF_xFxE9MV_VdrSf_Rp_drw8qYdC0n X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_12,2023-04-04_05,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 phishscore=0 mlxlogscore=749 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add and use uv_pnode_to_socket() function, which parallels other helper functions in here, and will enable avoiding duplicate code in an upcoming patch. Signed-off-by: Steve Wahl --- arch/x86/include/asm/uv/uv_hub.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_= hub.h index d3e3197917be..0acfd1734c8b 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h @@ -519,18 +519,24 @@ static inline int uv_socket_to_node(int socket) return _uv_socket_to_node(socket, uv_hub_info->socket_to_node); } =20 +static inline int uv_pnode_to_socket(int pnode) +{ + unsigned short *p2s =3D uv_hub_info->pnode_to_socket; + + return p2s ? p2s[pnode - uv_hub_info->min_pnode] : pnode; +} + /* pnode, offset --> socket virtual */ static inline void *uv_pnode_offset_to_vaddr(int pnode, unsigned long offs= et) { unsigned int m_val =3D uv_hub_info->m_val; unsigned long base; - unsigned short sockid, node, *p2s; + unsigned short sockid, node; =20 if (m_val) return __va(((unsigned long)pnode << m_val) | offset); =20 - p2s =3D uv_hub_info->pnode_to_socket; - sockid =3D p2s ? p2s[pnode - uv_hub_info->min_pnode] : pnode; + sockid =3D uv_pnode_to_socket(pnode); node =3D uv_socket_to_node(sockid); =20 /* limit address of previous socket is our base, except node 0 is 0 */ --=20 2.26.2 From nobody Wed Feb 11 04:00:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59CDBC6FD1D for ; Tue, 4 Apr 2023 21:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236075AbjDDVPd (ORCPT ); Tue, 4 Apr 2023 17:15:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236404AbjDDVPM (ORCPT ); Tue, 4 Apr 2023 17:15:12 -0400 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06A724C13 for ; Tue, 4 Apr 2023 14:15:05 -0700 (PDT) Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334L23OG009526; Tue, 4 Apr 2023 21:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=i3YXDfMP+UH9NTSWYzAJ6EiweJ7Xf7At9N6j69CwHqw=; b=dplI7skgEzgkhnfgLsdinda4Femu206V+sCvwOKFlPyyvaqkAiW40yhaGlhfaFku2NX9 FnBjRj7HyaHwTO5n5JRxGfS7m03XLDqVZKIDE5QcF4hWcG0xKhTaZt2A6VUxdAnaLAdl CQ02UfCNBCOCn2iU+DcSGYVyWlzk4vCPmyD0NXwMtm4ImkFqecf6LRqDTsPLCO9xuNVK EOS2LaN6f/wdmPlqnqdUWghbq9ercpD5FAiKAL1FxOrnROuj/vEk2DpBEurmtBl10e5a MiYAq/nZVSpVpbQY7ieCb2vm2hYDPPQ3eJqPn52qcrjEsCDGcsKzp0oWK0P8jF/cE+1G Gw== Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 3prttu8bud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 21:14:35 +0000 Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id B67F41304B; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id 3647C816652; Tue, 4 Apr 2023 21:14:33 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id 00A6830313045; Tue, 4 Apr 2023 16:14:31 -0500 (CDT) From: Steve Wahl To: Steve Wahl , Dimitri Sivanich , Russ Anderson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v5 3/8] x86/platform/uv: Fix printed information in calc_mmioh_map Date: Tue, 4 Apr 2023 16:14:26 -0500 Message-Id: <20230404211431.776248-4-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404211431.776248-1-steve.wahl@hpe.com> References: <20230404211431.776248-1-steve.wahl@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: blqDZEJEb3-GVFOom763VjjORKZqTu5i X-Proofpoint-ORIG-GUID: blqDZEJEb3-GVFOom763VjjORKZqTu5i X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_12,2023-04-04_05,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 impostorscore=0 phishscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Fix incorrect mask names and values in calc_mmioh_map() that caused it to print wrong NASID information. And an unused blade position is not an error condition, but will yield an invalid NASID value, so change the invalid NASID message from an error to a debug message. Signed-off-by: Steve Wahl --- arch/x86/kernel/apic/x2apic_uv_x.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2ap= ic_uv_x.c index 482855227964..6d2739eadb71 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -1022,7 +1022,7 @@ static void __init calc_mmioh_map(enum mmioh_arch ind= ex, switch (index) { case UVY_MMIOH0: mmr =3D UVH_RH10_GAM_MMIOH_REDIRECT_CONFIG0; - nasid_mask =3D UVH_RH10_GAM_MMIOH_OVERLAY_CONFIG0_BASE_MASK; + nasid_mask =3D UVYH_RH10_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK; n =3D UVH_RH10_GAM_MMIOH_REDIRECT_CONFIG0_DEPTH; min_nasid =3D min_pnode; max_nasid =3D max_pnode; @@ -1030,7 +1030,7 @@ static void __init calc_mmioh_map(enum mmioh_arch ind= ex, break; case UVY_MMIOH1: mmr =3D UVH_RH10_GAM_MMIOH_REDIRECT_CONFIG1; - nasid_mask =3D UVH_RH10_GAM_MMIOH_OVERLAY_CONFIG1_BASE_MASK; + nasid_mask =3D UVYH_RH10_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK; n =3D UVH_RH10_GAM_MMIOH_REDIRECT_CONFIG1_DEPTH; min_nasid =3D min_pnode; max_nasid =3D max_pnode; @@ -1038,7 +1038,7 @@ static void __init calc_mmioh_map(enum mmioh_arch ind= ex, break; case UVX_MMIOH0: mmr =3D UVH_RH_GAM_MMIOH_REDIRECT_CONFIG0; - nasid_mask =3D UVH_RH_GAM_MMIOH_OVERLAY_CONFIG0_BASE_MASK; + nasid_mask =3D UVH_RH_GAM_MMIOH_REDIRECT_CONFIG0_NASID_MASK; n =3D UVH_RH_GAM_MMIOH_REDIRECT_CONFIG0_DEPTH; min_nasid =3D min_pnode * 2; max_nasid =3D max_pnode * 2; @@ -1046,7 +1046,7 @@ static void __init calc_mmioh_map(enum mmioh_arch ind= ex, break; case UVX_MMIOH1: mmr =3D UVH_RH_GAM_MMIOH_REDIRECT_CONFIG1; - nasid_mask =3D UVH_RH_GAM_MMIOH_OVERLAY_CONFIG1_BASE_MASK; + nasid_mask =3D UVH_RH_GAM_MMIOH_REDIRECT_CONFIG1_NASID_MASK; n =3D UVH_RH_GAM_MMIOH_REDIRECT_CONFIG1_DEPTH; min_nasid =3D min_pnode * 2; max_nasid =3D max_pnode * 2; @@ -1072,8 +1072,9 @@ static void __init calc_mmioh_map(enum mmioh_arch ind= ex, =20 /* Invalid NASID check */ if (nasid < min_nasid || max_nasid < nasid) { - pr_err("UV:%s:Invalid NASID:%x (range:%x..%x)\n", - __func__, index, min_nasid, max_nasid); + /* Not an error: unused table entries get "poison" values */ + pr_debug("UV:%s:Invalid NASID(%x):%x (range:%x..%x)\n", + __func__, index, nasid, min_nasid, max_nasid); nasid =3D -1; } =20 --=20 2.26.2 From nobody Wed Feb 11 04:00:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B14DC761A6 for ; Tue, 4 Apr 2023 21:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236048AbjDDVPY (ORCPT ); Tue, 4 Apr 2023 17:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236328AbjDDVPK (ORCPT ); Tue, 4 Apr 2023 17:15:10 -0400 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA9414691 for ; Tue, 4 Apr 2023 14:15:06 -0700 (PDT) Received: from pps.filterd (m0150245.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334KMqXn020217; Tue, 4 Apr 2023 21:14:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=TT0BrqDjVdA3VHsClN80ASSbX1qXRCx5MBlvmm5IOtE=; b=Nue+P2ehAssGsPSjhiJEd3czq2hBvuvjgZ04zDerwTDoPVs+UdC8RmgAR9c179NyKz16 oDoOx1xDiLIfcDN08GV9/195BEg0IPBzFfPDTt5DrXhArIyGgeI4gOGR/AUucR9IU6sw FUbZsPKAv2sZp5xSDKzoK2wQVRPGj9jFNIIoWfWWrUfJrkEeNd9VHC07W4dSZFgRprPC wHeMD4svZYusILyCD8vd1NUP+4bfv9/dX8E3CNvpO3/5ZdpKNgJ6EL/3RhWE6bN1xOWW Q2hmisHtL+bNYJ107BmehYEV43E22FOAH3qfun14iD4GkCyujguMs3dZURFD1ZrjjKPF Fw== Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3prtvegbck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 21:14:34 +0000 Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id BA94E130AB; Tue, 4 Apr 2023 21:14:33 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id 1CD08815C22; Tue, 4 Apr 2023 21:14:32 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id 0468B30313048; Tue, 4 Apr 2023 16:14:32 -0500 (CDT) From: Steve Wahl To: Steve Wahl , Dimitri Sivanich , Russ Anderson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v5 4/8] x86/platform/uv: When searching for minimums, start at INT_MAX not 99999 Date: Tue, 4 Apr 2023 16:14:27 -0500 Message-Id: <20230404211431.776248-5-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404211431.776248-1-steve.wahl@hpe.com> References: <20230404211431.776248-1-steve.wahl@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: zU0F16GCrc-VISM4wMmX2iBHjGSjINCP X-Proofpoint-ORIG-GUID: zU0F16GCrc-VISM4wMmX2iBHjGSjINCP X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_12,2023-04-04_05,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 malwarescore=0 adultscore=0 impostorscore=0 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 phishscore=0 mlxlogscore=971 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Using a starting value of INT_MAX rather than 999999 or 99999 means this algorithm won't fail should the numbers being compared ever exceed this value. Signed-off-by: Steve Wahl --- arch/x86/kernel/apic/x2apic_uv_x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2ap= ic_uv_x.c index 6d2739eadb71..2da84befabf0 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -1349,7 +1349,7 @@ static void __init decode_gam_rng_tbl(unsigned long p= tr) struct uv_gam_range_entry *gre =3D (struct uv_gam_range_entry *)ptr; unsigned long lgre =3D 0, gend =3D 0; int index =3D 0; - int sock_min =3D 999999, pnode_min =3D 99999; + int sock_min =3D INT_MAX, pnode_min =3D INT_MAX; int sock_max =3D -1, pnode_max =3D -1; =20 uv_gre_table =3D gre; @@ -1694,7 +1694,7 @@ static void __init uv_system_init_hub(void) { struct uv_hub_info_s hub_info =3D {0}; int bytes, cpu, nodeid; - unsigned short min_pnode =3D 9999, max_pnode =3D 0; + unsigned short min_pnode =3D USHRT_MAX, max_pnode =3D 0; char *hub =3D is_uv5_hub() ? "UV500" : is_uv4_hub() ? "UV400" : is_uv3_hub() ? "UV300" : --=20 2.26.2 From nobody Wed Feb 11 04:00:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B5DCC6FD1D for ; Tue, 4 Apr 2023 21:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236437AbjDDVPm (ORCPT ); Tue, 4 Apr 2023 17:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236442AbjDDVPO (ORCPT ); Tue, 4 Apr 2023 17:15:14 -0400 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFEE49E6 for ; Tue, 4 Apr 2023 14:15:13 -0700 (PDT) Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334KcCM4023130; Tue, 4 Apr 2023 21:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=rMtFGeLTLqs2vfIhLT9M8T7JC+BTSDdRFHdnK5EA330=; b=ophDhxUq7fiDXJ5V9aI7ax0Bi5etE6yFaEMxG5iN+KFVgIbOXyq2dClAha5tcxymqWHt CK8ESAm3f0ybUKk4lRHIl0iVL0sbwWdV49nY0mXHVZorHhSXjFgvW12s+mgdiRiKYzIf w7w9pI58PjsJ0Ca3sc0PussZwNzInHXSmWeyM29HPABbjCbd4BNYj2nRu9hUzgC9UUzv MnchCpy9IBjR4yT6z7RMyYna4386WJ+LSEGuURymbtxffzMW+dT0dIyYnrcRP7Sv6T9X QiKHDAc/onu46r3XE1lu+y1gRS+PAYHL2rrtj984WQcWgfGeTqs0ZUXRZaJF7Iy9youk Pw== Received: from p1lg14878.it.hpe.com (p1lg14878.it.hpe.com [16.230.97.204]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3pru3k07rj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 21:14:35 +0000 Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14878.it.hpe.com (Postfix) with ESMTPS id BB36E12E93; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id 87BC1815C39; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id 0770130313049; Tue, 4 Apr 2023 16:14:32 -0500 (CDT) From: Steve Wahl To: Steve Wahl , Dimitri Sivanich , Russ Anderson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v5 5/8] x86/platform/uv: helper functions for allocating and freeing conversion tables Date: Tue, 4 Apr 2023 16:14:28 -0500 Message-Id: <20230404211431.776248-6-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404211431.776248-1-steve.wahl@hpe.com> References: <20230404211431.776248-1-steve.wahl@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 5Kolm2u87La83tcygUjL7_6bDjefXogU X-Proofpoint-GUID: 5Kolm2u87La83tcygUjL7_6bDjefXogU X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_12,2023-04-04_05,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 malwarescore=0 spamscore=0 priorityscore=1501 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add alloc_conv_table() and FREE_1_TO_1_TABLE() to reduce duplicated code among the conversion tables we use. Signed-off-by: Steve Wahl --- arch/x86/kernel/apic/x2apic_uv_x.c | 97 ++++++++++++++++-------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2ap= ic_uv_x.c index 2da84befabf0..1bd15b1f7712 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -1491,16 +1491,50 @@ static __init void boot_init_possible_blades(struct= uv_hub_info_s *hub_info) pr_info("UV: number nodes/possible blades %d\n", uv_pb); } =20 +static int __init alloc_conv_table(int num_elem, unsigned short **table) +{ + int i; + size_t bytes; + + bytes =3D num_elem * sizeof(*table[0]); + *table =3D kmalloc(bytes, GFP_KERNEL); + if (WARN_ON_ONCE(!*table)) + return -ENOMEM; + for (i =3D 0; i < num_elem; i++) + ((unsigned short *)*table)[i] =3D SOCK_EMPTY; + return 0; +} + +/* Remove conversion table if it's 1:1 */ +#define FREE_1_TO_1_TABLE(tbl, min, max, max2) free_1_to_1_table(&tbl, #tb= l, min, max, max2) + +static void __init free_1_to_1_table(unsigned short **tp, char *tname, int= min, int max, int max2) +{ + int i; + unsigned short *table =3D *tp; + + if (table =3D=3D NULL) + return; + if (max !=3D max2) + return; + for (i =3D 0; i < max; i++) { + if (i !=3D table[i]) + return; + } + kfree(table); + *tp =3D NULL; + pr_info("UV: %s is 1:1, conversion table removed\n", tname); +} + static void __init build_socket_tables(void) { struct uv_gam_range_entry *gre =3D uv_gre_table; - int num, nump; + int nums, numn, nump; int cpu, i, lnid; int minsock =3D _min_socket; int maxsock =3D _max_socket; int minpnode =3D _min_pnode; int maxpnode =3D _max_pnode; - size_t bytes; =20 if (!gre) { if (is_uv2_hub() || is_uv3_hub()) { @@ -1511,22 +1545,20 @@ static void __init build_socket_tables(void) BUG(); } =20 - /* Build socket id -> node id, pnode */ - num =3D maxsock - minsock + 1; - bytes =3D num * sizeof(_socket_to_node[0]); - _socket_to_node =3D kmalloc(bytes, GFP_KERNEL); - _socket_to_pnode =3D kmalloc(bytes, GFP_KERNEL); - + numn =3D num_possible_nodes(); nump =3D maxpnode - minpnode + 1; - bytes =3D nump * sizeof(_pnode_to_socket[0]); - _pnode_to_socket =3D kmalloc(bytes, GFP_KERNEL); - BUG_ON(!_socket_to_node || !_socket_to_pnode || !_pnode_to_socket); - - for (i =3D 0; i < num; i++) - _socket_to_node[i] =3D _socket_to_pnode[i] =3D SOCK_EMPTY; - - for (i =3D 0; i < nump; i++) - _pnode_to_socket[i] =3D SOCK_EMPTY; + nums =3D maxsock - minsock + 1; + + /* Allocate and clear tables */ + if ((alloc_conv_table(nump, &_pnode_to_socket) < 0) + || (alloc_conv_table(nums, &_socket_to_pnode) < 0) + || (alloc_conv_table(numn, &_node_to_pnode) < 0) + || (alloc_conv_table(nums, &_socket_to_node) < 0)) { + kfree(_pnode_to_socket); + kfree(_socket_to_pnode); + kfree(_node_to_pnode); + return; + } =20 /* Fill in pnode/node/addr conversion list values: */ pr_info("UV: GAM Building socket/pnode conversion tables\n"); @@ -1565,10 +1597,6 @@ static void __init build_socket_tables(void) } =20 /* Set up physical blade to pnode translation from GAM Range Table: */ - bytes =3D num_possible_nodes() * sizeof(_node_to_pnode[0]); - _node_to_pnode =3D kmalloc(bytes, GFP_KERNEL); - BUG_ON(!_node_to_pnode); - for (lnid =3D 0; lnid < num_possible_nodes(); lnid++) { unsigned short sockid; =20 @@ -1585,31 +1613,12 @@ static void __init build_socket_tables(void) } =20 /* - * If socket id =3D=3D pnode or socket id =3D=3D node for all nodes, + * If e.g. socket id =3D=3D pnode for all pnodes, * system runs faster by removing corresponding conversion table. */ - pr_info("UV: Checking socket->node/pnode for identity maps\n"); - if (minsock =3D=3D 0) { - for (i =3D 0; i < num; i++) - if (_socket_to_node[i] =3D=3D SOCK_EMPTY || i !=3D _socket_to_node[i]) - break; - if (i >=3D num) { - kfree(_socket_to_node); - _socket_to_node =3D NULL; - pr_info("UV: 1:1 socket_to_node table removed\n"); - } - } - if (minsock =3D=3D minpnode) { - for (i =3D 0; i < num; i++) - if (_socket_to_pnode[i] !=3D SOCK_EMPTY && - _socket_to_pnode[i] !=3D i + minpnode) - break; - if (i >=3D num) { - kfree(_socket_to_pnode); - _socket_to_pnode =3D NULL; - pr_info("UV: 1:1 socket_to_pnode table removed\n"); - } - } + FREE_1_TO_1_TABLE(_socket_to_node, _min_socket, nums, numn); + FREE_1_TO_1_TABLE(_socket_to_pnode, _min_pnode, nums, nump); + FREE_1_TO_1_TABLE(_pnode_to_socket, _min_pnode, nums, nump); } =20 /* Check which reboot to use */ --=20 2.26.2 From nobody Wed Feb 11 04:00:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5605DC76188 for ; Tue, 4 Apr 2023 21:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236505AbjDDVP2 (ORCPT ); Tue, 4 Apr 2023 17:15:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236398AbjDDVPM (ORCPT ); Tue, 4 Apr 2023 17:15:12 -0400 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C847C4C03 for ; Tue, 4 Apr 2023 14:15:05 -0700 (PDT) Received: from pps.filterd (m0148664.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334KSRF7024998; Tue, 4 Apr 2023 21:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=XImtGcXiswX7NuQoNcuvDMJglsAAhZSLOkMprpqznVM=; b=oTwt8szZ0IQ1OxVoKoSmrqLhscJ/pO41wLilq5HArw2GReybHTd/AfjR6wK+I25nMTNq P6/eJzJO4URnkcHPZwtaJdEKgLoAWNJTbFUinSQEaM9Iim0HpaE6QH3OSznv8Votc+56 OsAIGXhfH8d49IfZcK00ZFWMVq+UQg/0c2EjJJwxJ+3tzcb7HSN+NOfbyoFAFF4GEzCp DGX90GHMLqcYKF7OGnB9/gWtojUv9RJgziuMv5DoW05XXAB0Gw7NqFOfZqkobUDitGNZ CdY1ndEzU1ae/AcBsryacLZIEKuCJpZArJRAmD/t9dXRmE2NRhyRuJTFEyEQBAACz1UN sQ== Received: from p1lg14881.it.hpe.com (p1lg14881.it.hpe.com [16.230.97.202]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3prtxy89fr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 21:14:35 +0000 Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14881.it.hpe.com (Postfix) with ESMTPS id EB856806B7C; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 8A6B280D6A3; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id 0A6443031304A; Tue, 4 Apr 2023 16:14:32 -0500 (CDT) From: Steve Wahl To: Steve Wahl , Dimitri Sivanich , Russ Anderson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v5 6/8] x86/platform/uv: UV support for sub-NUMA clustering Date: Tue, 4 Apr 2023 16:14:29 -0500 Message-Id: <20230404211431.776248-7-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404211431.776248-1-steve.wahl@hpe.com> References: <20230404211431.776248-1-steve.wahl@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: PVqV5a6vG6I7ez9bo-hC2qSoPgBhuDuz X-Proofpoint-ORIG-GUID: PVqV5a6vG6I7ez9bo-hC2qSoPgBhuDuz X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_12,2023-04-04_05,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 adultscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Sub-NUMA clustering (SNC) invalidates previous assumptions of a 1:1 relationship between blades, sockets, and nodes. Fix these assumptions and build tables correctly when SNC is enabled. Signed-off-by: Steve Wahl --- arch/x86/include/asm/uv/uv_hub.h | 22 ++-- arch/x86/kernel/apic/x2apic_uv_x.c | 162 +++++++++++++++++------------ 2 files changed, 107 insertions(+), 77 deletions(-) diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_= hub.h index 0acfd1734c8b..5fa76c2ced51 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h @@ -177,6 +177,7 @@ struct uv_hub_info_s { unsigned short nr_possible_cpus; unsigned short nr_online_cpus; short memory_nid; + unsigned short *node_to_socket; }; =20 /* CPU specific info with a pointer to the hub common info struct */ @@ -531,19 +532,18 @@ static inline void *uv_pnode_offset_to_vaddr(int pnod= e, unsigned long offset) { unsigned int m_val =3D uv_hub_info->m_val; unsigned long base; - unsigned short sockid, node; + unsigned short sockid; =20 if (m_val) return __va(((unsigned long)pnode << m_val) | offset); =20 sockid =3D uv_pnode_to_socket(pnode); - node =3D uv_socket_to_node(sockid); =20 /* limit address of previous socket is our base, except node 0 is 0 */ - if (!node) + if (sockid =3D=3D 0) return __va((unsigned long)offset); =20 - base =3D (unsigned long)(uv_hub_info->gr_table[node - 1].limit); + base =3D (unsigned long)(uv_hub_info->gr_table[sockid - 1].limit); return __va(base << UV_GAM_RANGE_SHFT | offset); } =20 @@ -650,7 +650,7 @@ static inline int uv_cpu_blade_processor_id(int cpu) /* Blade number to Node number (UV2..UV4 is 1:1) */ static inline int uv_blade_to_node(int blade) { - return blade; + return uv_socket_to_node(blade); } =20 /* Blade number of current cpu. Numnbered 0 .. <#blades -1> */ @@ -662,23 +662,27 @@ static inline int uv_numa_blade_id(void) /* * Convert linux node number to the UV blade number. * .. Currently for UV2 thru UV4 the node and the blade are identical. - * .. If this changes then you MUST check references to this function! + * .. UV5 needs conversion when sub-numa clustering is enabled. */ static inline int uv_node_to_blade_id(int nid) { - return nid; + unsigned short *n2s =3D uv_hub_info->node_to_socket; + + return n2s ? n2s[nid] : nid; } =20 /* Convert a CPU number to the UV blade number */ static inline int uv_cpu_to_blade_id(int cpu) { - return uv_node_to_blade_id(cpu_to_node(cpu)); + return uv_cpu_hub_info(cpu)->numa_blade_id; } =20 /* Convert a blade id to the PNODE of the blade */ static inline int uv_blade_to_pnode(int bid) { - return uv_hub_info_list(uv_blade_to_node(bid))->pnode; + unsigned short *s2p =3D uv_hub_info->socket_to_pnode; + + return s2p ? s2p[bid] : bid; } =20 /* Nid of memory node on blade. -1 if no blade-local memory */ diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2ap= ic_uv_x.c index 1bd15b1f7712..10d3bdf874a0 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -546,7 +546,6 @@ unsigned long sn_rtc_cycles_per_second; EXPORT_SYMBOL(sn_rtc_cycles_per_second); =20 /* The following values are used for the per node hub info struct */ -static __initdata unsigned short *_node_to_pnode; static __initdata unsigned short _min_socket, _max_socket; static __initdata unsigned short _min_pnode, _max_pnode, _gr_table_len; static __initdata struct uv_gam_range_entry *uv_gre_table; @@ -554,6 +553,7 @@ static __initdata struct uv_gam_parameters *uv_gp_table; static __initdata unsigned short *_socket_to_node; static __initdata unsigned short *_socket_to_pnode; static __initdata unsigned short *_pnode_to_socket; +static __initdata unsigned short *_node_to_socket; =20 static __initdata struct uv_gam_range_s *_gr_table; =20 @@ -1293,6 +1293,7 @@ static void __init uv_init_hub_info(struct uv_hub_inf= o_s *hi) hi->nasid_shift =3D uv_cpuid.nasid_shift; hi->min_pnode =3D _min_pnode; hi->min_socket =3D _min_socket; + hi->node_to_socket =3D _node_to_socket; hi->pnode_to_socket =3D _pnode_to_socket; hi->socket_to_node =3D _socket_to_node; hi->socket_to_pnode =3D _socket_to_pnode; @@ -1526,6 +1527,11 @@ static void __init free_1_to_1_table(unsigned short = **tp, char *tname, int min, pr_info("UV: %s is 1:1, conversion table removed\n", tname); } =20 +/* + * Build Socket Tables + * If the number of nodes is >1 per socket, socket to node table will + * contain lowest node number on that socket. + */ static void __init build_socket_tables(void) { struct uv_gam_range_entry *gre =3D uv_gre_table; @@ -1552,27 +1558,25 @@ static void __init build_socket_tables(void) /* Allocate and clear tables */ if ((alloc_conv_table(nump, &_pnode_to_socket) < 0) || (alloc_conv_table(nums, &_socket_to_pnode) < 0) - || (alloc_conv_table(numn, &_node_to_pnode) < 0) + || (alloc_conv_table(numn, &_node_to_socket) < 0) || (alloc_conv_table(nums, &_socket_to_node) < 0)) { kfree(_pnode_to_socket); kfree(_socket_to_pnode); - kfree(_node_to_pnode); + kfree(_node_to_socket); return; } =20 /* Fill in pnode/node/addr conversion list values: */ - pr_info("UV: GAM Building socket/pnode conversion tables\n"); for (; gre->type !=3D UV_GAM_RANGE_TYPE_UNUSED; gre++) { if (gre->type =3D=3D UV_GAM_RANGE_TYPE_HOLE) continue; i =3D gre->sockid - minsock; - /* Duplicate: */ - if (_socket_to_pnode[i] !=3D SOCK_EMPTY) - continue; - _socket_to_pnode[i] =3D gre->pnode; + if (_socket_to_pnode[i] =3D=3D SOCK_EMPTY) + _socket_to_pnode[i] =3D gre->pnode; =20 i =3D gre->pnode - minpnode; - _pnode_to_socket[i] =3D gre->sockid; + if (_pnode_to_socket[i] =3D=3D SOCK_EMPTY) + _pnode_to_socket[i] =3D gre->sockid; =20 pr_info("UV: sid:%02x type:%d nasid:%04x pn:%02x pn2s:%2x\n", gre->sockid, gre->type, gre->nasid, @@ -1582,34 +1586,29 @@ static void __init build_socket_tables(void) =20 /* Set socket -> node values: */ lnid =3D NUMA_NO_NODE; - for_each_present_cpu(cpu) { + for_each_possible_cpu(cpu) { int nid =3D cpu_to_node(cpu); int apicid, sockid; =20 if (lnid =3D=3D nid) continue; lnid =3D nid; + apicid =3D per_cpu(x86_cpu_to_apicid, cpu); sockid =3D apicid >> uv_cpuid.socketid_shift; - _socket_to_node[sockid - minsock] =3D nid; - pr_info("UV: sid:%02x: apicid:%04x node:%2d\n", - sockid, apicid, nid); - } =20 - /* Set up physical blade to pnode translation from GAM Range Table: */ - for (lnid =3D 0; lnid < num_possible_nodes(); lnid++) { - unsigned short sockid; + if (_socket_to_node[sockid - minsock] =3D=3D SOCK_EMPTY) + _socket_to_node[sockid - minsock] =3D nid; =20 - for (sockid =3D minsock; sockid <=3D maxsock; sockid++) { - if (lnid =3D=3D _socket_to_node[sockid - minsock]) { - _node_to_pnode[lnid] =3D _socket_to_pnode[sockid - minsock]; - break; - } - } - if (sockid > maxsock) { - pr_err("UV: socket for node %d not found!\n", lnid); - BUG(); - } + if (_node_to_socket[nid] =3D=3D SOCK_EMPTY) + _node_to_socket[nid] =3D sockid; + + pr_info("UV: sid:%02x: apicid:%04x socket:%02d node:%03x s2n:%03x\n", + sockid, + apicid, + _node_to_socket[nid], + nid, + _socket_to_node[sockid - minsock]); } =20 /* @@ -1617,6 +1616,7 @@ static void __init build_socket_tables(void) * system runs faster by removing corresponding conversion table. */ FREE_1_TO_1_TABLE(_socket_to_node, _min_socket, nums, numn); + FREE_1_TO_1_TABLE(_node_to_socket, _min_socket, nums, numn); FREE_1_TO_1_TABLE(_socket_to_pnode, _min_pnode, nums, nump); FREE_1_TO_1_TABLE(_pnode_to_socket, _min_pnode, nums, nump); } @@ -1702,12 +1702,13 @@ static __init int uv_system_init_hubless(void) static void __init uv_system_init_hub(void) { struct uv_hub_info_s hub_info =3D {0}; - int bytes, cpu, nodeid; + int bytes, cpu, nodeid, bid; unsigned short min_pnode =3D USHRT_MAX, max_pnode =3D 0; char *hub =3D is_uv5_hub() ? "UV500" : is_uv4_hub() ? "UV400" : is_uv3_hub() ? "UV300" : is_uv2_hub() ? "UV2000/3000" : NULL; + struct uv_hub_info_s **uv_hub_info_list_blade; =20 if (!hub) { pr_err("UV: Unknown/unsupported UV hub\n"); @@ -1730,9 +1731,12 @@ static void __init uv_system_init_hub(void) build_uv_gr_table(); set_block_size(); uv_init_hub_info(&hub_info); - uv_possible_blades =3D num_possible_nodes(); - if (!_node_to_pnode) + /* If UV2 or UV3 may need to get # blades from HW */ + if (is_uv(UV2|UV3) && !uv_gre_table) boot_init_possible_blades(&hub_info); + else + /* min/max sockets set in decode_gam_rng_tbl */ + uv_possible_blades =3D (_max_socket - _min_socket) + 1; =20 /* uv_num_possible_blades() is really the hub count: */ pr_info("UV: Found %d hubs, %d nodes, %d CPUs\n", uv_num_possible_blades(= ), num_possible_nodes(), num_possible_cpus()); @@ -1741,79 +1745,98 @@ static void __init uv_system_init_hub(void) hub_info.coherency_domain_number =3D sn_coherency_id; uv_rtc_init(); =20 + /* + * __uv_hub_info_list[] is indexed by node, but there is only + * one hub_info structure per blade. First, allocate one + * structure per blade. Further down we create a per-node + * table (__uv_hub_info_list[]) pointing to hub_info + * structures for the correct blade. + */ + bytes =3D sizeof(void *) * uv_num_possible_blades(); - __uv_hub_info_list =3D kzalloc(bytes, GFP_KERNEL); - BUG_ON(!__uv_hub_info_list); + uv_hub_info_list_blade =3D kzalloc(bytes, GFP_KERNEL); + if (WARN_ON_ONCE(!uv_hub_info_list_blade)) + return; =20 bytes =3D sizeof(struct uv_hub_info_s); - for_each_node(nodeid) { + for_each_possible_blade(bid) { struct uv_hub_info_s *new_hub; =20 - if (__uv_hub_info_list[nodeid]) { - pr_err("UV: Node %d UV HUB already initialized!?\n", nodeid); - BUG(); + /* Allocate & fill new per hub info list */ + new_hub =3D (bid =3D=3D 0) ? &uv_hub_info_node0 + : kzalloc_node(bytes, GFP_KERNEL, uv_blade_to_node(bid)); + if (WARN_ON_ONCE(!new_hub)) { + /* do not kfree() bid 0, which is statically allocated */ + while (--bid > 0) + kfree(uv_hub_info_list_blade[bid]); + kfree(uv_hub_info_list_blade); + return; } =20 - /* Allocate new per hub info list */ - new_hub =3D (nodeid =3D=3D 0) ? &uv_hub_info_node0 : kzalloc_node(bytes= , GFP_KERNEL, nodeid); - BUG_ON(!new_hub); - __uv_hub_info_list[nodeid] =3D new_hub; - new_hub =3D uv_hub_info_list(nodeid); - BUG_ON(!new_hub); + uv_hub_info_list_blade[bid] =3D new_hub; *new_hub =3D hub_info; =20 /* Use information from GAM table if available: */ - if (_node_to_pnode) - new_hub->pnode =3D _node_to_pnode[nodeid]; + if (uv_gre_table) + new_hub->pnode =3D uv_blade_to_pnode(bid); else /* Or fill in during CPU loop: */ new_hub->pnode =3D 0xffff; =20 - new_hub->numa_blade_id =3D uv_node_to_blade_id(nodeid); + new_hub->numa_blade_id =3D bid; new_hub->memory_nid =3D NUMA_NO_NODE; new_hub->nr_possible_cpus =3D 0; new_hub->nr_online_cpus =3D 0; } =20 + /* + * Now populate __uv_hub_info_list[] for each node with the + * pointer to the struct for the blade it resides on. + */ + + bytes =3D sizeof(void *) * num_possible_nodes(); + __uv_hub_info_list =3D kzalloc(bytes, GFP_KERNEL); + if (WARN_ON_ONCE(!__uv_hub_info_list)) { + for_each_possible_blade(bid) + /* bid 0 is statically allocated */ + if (bid !=3D 0) + kfree(uv_hub_info_list_blade[bid]); + kfree(uv_hub_info_list_blade); + return; + } + + for_each_node(nodeid) + __uv_hub_info_list[nodeid] =3D uv_hub_info_list_blade[uv_node_to_blade_i= d(nodeid)]; + /* Initialize per CPU info: */ for_each_possible_cpu(cpu) { - int apicid =3D per_cpu(x86_cpu_to_apicid, cpu); - int numa_node_id; + int apicid =3D early_per_cpu(x86_cpu_to_apicid, cpu); + unsigned short bid; unsigned short pnode; =20 - nodeid =3D cpu_to_node(cpu); - numa_node_id =3D numa_cpu_node(cpu); pnode =3D uv_apicid_to_pnode(apicid); + bid =3D uv_pnode_to_socket(pnode) - _min_socket; =20 - uv_cpu_info_per(cpu)->p_uv_hub_info =3D uv_hub_info_list(nodeid); + uv_cpu_info_per(cpu)->p_uv_hub_info =3D uv_hub_info_list_blade[bid]; uv_cpu_info_per(cpu)->blade_cpu_id =3D uv_cpu_hub_info(cpu)->nr_possible= _cpus++; if (uv_cpu_hub_info(cpu)->memory_nid =3D=3D NUMA_NO_NODE) uv_cpu_hub_info(cpu)->memory_nid =3D cpu_to_node(cpu); =20 - /* Init memoryless node: */ - if (nodeid !=3D numa_node_id && - uv_hub_info_list(numa_node_id)->pnode =3D=3D 0xffff) - uv_hub_info_list(numa_node_id)->pnode =3D pnode; - else if (uv_cpu_hub_info(cpu)->pnode =3D=3D 0xffff) + if (uv_cpu_hub_info(cpu)->pnode =3D=3D 0xffff) uv_cpu_hub_info(cpu)->pnode =3D pnode; } =20 - for_each_node(nodeid) { - unsigned short pnode =3D uv_hub_info_list(nodeid)->pnode; + for_each_possible_blade(bid) { + unsigned short pnode =3D uv_hub_info_list_blade[bid]->pnode; =20 - /* Add pnode info for pre-GAM list nodes without CPUs: */ - if (pnode =3D=3D 0xffff) { - unsigned long paddr; + if (pnode =3D=3D 0xffff) + continue; =20 - paddr =3D node_start_pfn(nodeid) << PAGE_SHIFT; - pnode =3D uv_gpa_to_pnode(uv_soc_phys_ram_to_gpa(paddr)); - uv_hub_info_list(nodeid)->pnode =3D pnode; - } min_pnode =3D min(pnode, min_pnode); max_pnode =3D max(pnode, max_pnode); - pr_info("UV: UVHUB node:%2d pn:%02x nrcpus:%d\n", - nodeid, - uv_hub_info_list(nodeid)->pnode, - uv_hub_info_list(nodeid)->nr_possible_cpus); + pr_info("UV: HUB:%2d pn:%02x nrcpus:%d\n", + bid, + uv_hub_info_list_blade[bid]->pnode, + uv_hub_info_list_blade[bid]->nr_possible_cpus); } =20 pr_info("UV: min_pnode:%02x max_pnode:%02x\n", min_pnode, max_pnode); @@ -1821,6 +1844,9 @@ static void __init uv_system_init_hub(void) map_mmr_high(max_pnode); map_mmioh_high(min_pnode, max_pnode); =20 + kfree(uv_hub_info_list_blade); + uv_hub_info_list_blade =3D NULL; + uv_nmi_setup(); uv_cpu_init(); uv_setup_proc_files(0); --=20 2.26.2 From nobody Wed Feb 11 04:00:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FE2AC6FD1D for ; Tue, 4 Apr 2023 21:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236528AbjDDVPg (ORCPT ); Tue, 4 Apr 2023 17:15:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236433AbjDDVPM (ORCPT ); Tue, 4 Apr 2023 17:15:12 -0400 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F14271C for ; Tue, 4 Apr 2023 14:15:08 -0700 (PDT) Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334KJb18015829; Tue, 4 Apr 2023 21:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=UMdJ6dPRWg9qYBO+924mw4Sp9YYoC2nRG2nYkjyua60=; b=XSbu14P2xG43u797qh0amJxqTX8sjjBUvHNjC2XRvgdAF95ozsMDjM0s8loSVINchcOE 1yG+l+IIPQRUljfhzyboBOmdBp2AIIcRBibk34SEhsqUIwbwMlfaQsSwYRZw/NpsibcQ PoAGnawKC3FEe1ZdxjHMnTrSmWBbR/fsqrKBMcj6DQWkRBThxK/Tei/6yrsVjF2NV6xy EvkolNle675QNp+eilcF/akNlJmGwLjSBhJA9w6OdRmgmnaJ3rqg2YbMiQA3MuTZ9pbX 3YaUP4X9kCHUOcIYsOV+AsP6GrjulMTUIVV08bQxKv8Zr8kjCad4FHiFf+JvRK47S/MC 3A== Received: from p1lg14878.it.hpe.com (p1lg14878.it.hpe.com [16.230.97.204]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3prtu48b4q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 21:14:35 +0000 Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14878.it.hpe.com (Postfix) with ESMTPS id B1DC913068; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 879FE80D086; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id 0CFB93031304C; Tue, 4 Apr 2023 16:14:32 -0500 (CDT) From: Steve Wahl To: Steve Wahl , Dimitri Sivanich , Russ Anderson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v5 7/8] x86/platform/uv: Remove remaining BUG_ON() and BUG() calls Date: Tue, 4 Apr 2023 16:14:30 -0500 Message-Id: <20230404211431.776248-8-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404211431.776248-1-steve.wahl@hpe.com> References: <20230404211431.776248-1-steve.wahl@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: qSTL_c6uv6A9z1-DxC6FKpt0nqkcKY_k X-Proofpoint-ORIG-GUID: qSTL_c6uv6A9z1-DxC6FKpt0nqkcKY_k X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_12,2023-04-04_05,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 priorityscore=1501 suspectscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 clxscore=1015 malwarescore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replace BUG and BUG_ON with WARN_ON_ONCE and carry on as best as we can. Signed-off-by: Steve Wahl --- arch/x86/kernel/apic/x2apic_uv_x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2ap= ic_uv_x.c index 10d3bdf874a0..1836330ff7b3 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -617,7 +617,8 @@ static __init void build_uv_gr_table(void) =20 bytes =3D _gr_table_len * sizeof(struct uv_gam_range_s); grt =3D kzalloc(bytes, GFP_KERNEL); - BUG_ON(!grt); + if (WARN_ON_ONCE(!grt)) + return; _gr_table =3D grt; =20 for (; gre->type !=3D UV_GAM_RANGE_TYPE_UNUSED; gre++) { @@ -1548,7 +1549,8 @@ static void __init build_socket_tables(void) return; } pr_err("UV: Error: UVsystab address translations not available!\n"); - BUG(); + WARN_ON_ONCE(!gre); + return; } =20 numn =3D num_possible_nodes(); --=20 2.26.2 From nobody Wed Feb 11 04:00:58 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3C9AC761A6 for ; Tue, 4 Apr 2023 21:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236415AbjDDVPM (ORCPT ); Tue, 4 Apr 2023 17:15:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232269AbjDDVPJ (ORCPT ); Tue, 4 Apr 2023 17:15:09 -0400 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E63A49ED for ; Tue, 4 Apr 2023 14:15:04 -0700 (PDT) Received: from pps.filterd (m0134423.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 334KJl2R025055; Tue, 4 Apr 2023 21:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=MwEcF3wqivG6f5Xew+DgcPMveJbhktL16VB8vHcGDMQ=; b=FXEArhMVODkgd3qO+LLTFYHEmQaX0W/HcsQ8rYXG7X+edKi9mcv2D/GEvwMGEWvDwpQG 2VpRFnP1cB3wZoW8Ir9G78GDkDurS3Qb0e15drbSthX5OrZPCDVmUb+9F8AHy3f23SYk tverVrb+v+drQV1PuuMZxgrYu64ditTMSLcm6Knih69YJzsDRzpuGgp7wCIEomd/Aab+ tJD6ST4fDH7mGr2ggPMcTW+irTKKHwDGLWEwSC8qmlzoVq2PVngj/6D3zXkObCz9pWZV 4aX7Ojqe12N7BeLJFlIiVu30NthC64HDYatO9uMW1NCwXuT7VlsAO7Ur/DxZaZcxNu/M Ag== Received: from p1lg14879.it.hpe.com (p1lg14879.it.hpe.com [16.230.97.200]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3prtu18byt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Apr 2023 21:14:35 +0000 Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14879.it.hpe.com (Postfix) with ESMTPS id C017113053; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: from dog.eag.rdlabs.hpecorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id 9CE7A8161B6; Tue, 4 Apr 2023 21:14:34 +0000 (UTC) Received: by dog.eag.rdlabs.hpecorp.net (Postfix, from userid 200934) id 0F8D93031304D; Tue, 4 Apr 2023 16:14:32 -0500 (CDT) From: Steve Wahl To: Steve Wahl , Dimitri Sivanich , Russ Anderson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v5 8/8] x86/platform/uv: Update UV[23] platform code for SNC Date: Tue, 4 Apr 2023 16:14:31 -0500 Message-Id: <20230404211431.776248-9-steve.wahl@hpe.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20230404211431.776248-1-steve.wahl@hpe.com> References: <20230404211431.776248-1-steve.wahl@hpe.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: tXiyCVJTYwUL4DMoZd9buqY6T9OB1TOh X-Proofpoint-ORIG-GUID: tXiyCVJTYwUL4DMoZd9buqY6T9OB1TOh X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-04_12,2023-04-04_05,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 spamscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304040193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Previous Sub-NUMA Clustering changes need not just a count of blades present, but a count that includes any missing ids for blades not present; in other words, the range from lowest to highest blade id. Signed-off-by: Steve Wahl --- arch/x86/kernel/apic/x2apic_uv_x.c | 42 +++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2ap= ic_uv_x.c index 1836330ff7b3..d9384d5b4b8e 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -1462,11 +1462,37 @@ static int __init decode_uv_systab(void) return 0; } =20 +/* + * Given a bitmask 'bits' representing presnt blades, numbered + * starting at 'base', masking off unused high bits of blade number + * with 'mask', update the minimum and maximum blade numbers that we + * have found. (Masking with 'mask' necessary because of BIOS + * treatment of system partitioning when creating this table we are + * interpreting.) + */ +static inline void blade_update_min_max(unsigned long bits, int base, int = mask, int *min, int *max) +{ + int first, last; + + if (!bits) + return; + first =3D (base + __ffs(bits)) & mask; + last =3D (base + __fls(bits)) & mask; + + if (*min > first) + *min =3D first; + if (*max < last) + *max =3D last; +} + /* Set up physical blade translations from UVH_NODE_PRESENT_TABLE */ static __init void boot_init_possible_blades(struct uv_hub_info_s *hub_inf= o) { unsigned long np; int i, uv_pb =3D 0; + int sock_min =3D INT_MAX, sock_max =3D -1, s_mask; + + s_mask =3D (1 << uv_cpuid.n_skt) - 1; =20 if (UVH_NODE_PRESENT_TABLE) { pr_info("UV: NODE_PRESENT_DEPTH =3D %d\n", @@ -1474,23 +1500,31 @@ static __init void boot_init_possible_blades(struct= uv_hub_info_s *hub_info) for (i =3D 0; i < UVH_NODE_PRESENT_TABLE_DEPTH; i++) { np =3D uv_read_local_mmr(UVH_NODE_PRESENT_TABLE + i * 8); pr_info("UV: NODE_PRESENT(%d) =3D 0x%016lx\n", i, np); - uv_pb +=3D hweight64(np); + blade_update_min_max(np, i * 64, s_mask, &sock_min, &sock_max); } } if (UVH_NODE_PRESENT_0) { np =3D uv_read_local_mmr(UVH_NODE_PRESENT_0); pr_info("UV: NODE_PRESENT_0 =3D 0x%016lx\n", np); - uv_pb +=3D hweight64(np); + blade_update_min_max(np, 0, s_mask, &sock_min, &sock_max); } if (UVH_NODE_PRESENT_1) { np =3D uv_read_local_mmr(UVH_NODE_PRESENT_1); pr_info("UV: NODE_PRESENT_1 =3D 0x%016lx\n", np); - uv_pb +=3D hweight64(np); + blade_update_min_max(np, 64, s_mask, &sock_min, &sock_max); + } + + /* Only update if we actually found some bits indicating blades present */ + if (sock_max >=3D sock_min) { + _min_socket =3D sock_min; + _max_socket =3D sock_max; + uv_pb =3D sock_max - sock_min + 1; } if (uv_possible_blades !=3D uv_pb) uv_possible_blades =3D uv_pb; =20 - pr_info("UV: number nodes/possible blades %d\n", uv_pb); + pr_info("UV: number nodes/possible blades %d (%d - %d)\n", + uv_pb, sock_min, sock_max); } =20 static int __init alloc_conv_table(int num_elem, unsigned short **table) --=20 2.26.2