Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6525470rwl; Tue, 4 Apr 2023 14:17:57 -0700 (PDT) X-Google-Smtp-Source: AKy350ZQlFQgLtOqznQz/1vP5owyv/J7bPvu4gN70gYBXtVui/Vi1Kp9dmyuOy8doZYw7975NIGA X-Received: by 2002:a17:90b:1a8c:b0:23b:3682:c899 with SMTP id ng12-20020a17090b1a8c00b0023b3682c899mr4398916pjb.23.1680643077453; Tue, 04 Apr 2023 14:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680643077; cv=none; d=google.com; s=arc-20160816; b=x04UF/qRV31d4mLYVEHuxm6fbBLW0/feNejQSnk5+Q6DffrZcrSgF8uQQwx/3xbAcy y9cZSYvBiZMKs914ok+QSGHwZ1rCZhMNHDWlQ5p8gNE1mF1vL6WbCVdt6dfEvglptB1y zikuh7tgYkcTaHQol1un8vKvRt+mkntGCVz7wqHzaqWvPbWKN/TmH0rvkzgfrwFpYBFG Cunakjtv3SxkvYhOtVPcdhbgUk8z6bgXfnPFMAZt6xv3SHquRjkf/0BTnuPGvhbEGvZc JI8vbPqCWJo5SHaxzKGUgjoofioPSvkINUXAfOkVxAdP9umipv10EguwcrqUDaM9sqrr /UMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=MwEcF3wqivG6f5Xew+DgcPMveJbhktL16VB8vHcGDMQ=; b=05S+BNvEvJE1hpJFyYkd4CKvAjFHyfY+llIYA/QSNupx51HZm3Jo5S/SsfpngTj9P9 1i8wQFRZjfVPDwMT0QnZza0NDuDJf+QTr0RHp7E+Y4G+tgypIbOaEikQ24UZnUUDL7+v gJq33TiHbvo4FXvBLJSBsS7CFJQDB4FczOTEYE+GTMCIdo3ForZzSLVJZilgrHW5pNZj BMi9AG2qyJnMlHHe1/aXAi2EdQD0NaZIuZmDzfAfCehd01oUrGsQtcRl/kLStxk3k1mM iUkm0tLTU66Q0gc5+VZ95gilM2e7ZMu+1OJfY84EHPnr18vjO4BtiAvkCSu2Yfc4yd+U jUvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=FXEArhMV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hpe.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id em19-20020a17090b015300b002400da5dd18si65318pjb.57.2023.04.04.14.17.42; Tue, 04 Apr 2023 14:17:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=FXEArhMV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hpe.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236374AbjDDVPL (ORCPT + 99 others); Tue, 4 Apr 2023 17:15:11 -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: 8bit 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 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/x2apic_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; } +/* + * 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 = (base + __ffs(bits)) & mask; + last = (base + __fls(bits)) & mask; + + if (*min > first) + *min = first; + if (*max < last) + *max = last; +} + /* Set up physical blade translations from UVH_NODE_PRESENT_TABLE */ static __init void boot_init_possible_blades(struct uv_hub_info_s *hub_info) { unsigned long np; int i, uv_pb = 0; + int sock_min = INT_MAX, sock_max = -1, s_mask; + + s_mask = (1 << uv_cpuid.n_skt) - 1; if (UVH_NODE_PRESENT_TABLE) { pr_info("UV: NODE_PRESENT_DEPTH = %d\n", @@ -1474,23 +1500,31 @@ static __init void boot_init_possible_blades(struct uv_hub_info_s *hub_info) for (i = 0; i < UVH_NODE_PRESENT_TABLE_DEPTH; i++) { np = uv_read_local_mmr(UVH_NODE_PRESENT_TABLE + i * 8); pr_info("UV: NODE_PRESENT(%d) = 0x%016lx\n", i, np); - uv_pb += hweight64(np); + blade_update_min_max(np, i * 64, s_mask, &sock_min, &sock_max); } } if (UVH_NODE_PRESENT_0) { np = uv_read_local_mmr(UVH_NODE_PRESENT_0); pr_info("UV: NODE_PRESENT_0 = 0x%016lx\n", np); - uv_pb += hweight64(np); + blade_update_min_max(np, 0, s_mask, &sock_min, &sock_max); } if (UVH_NODE_PRESENT_1) { np = uv_read_local_mmr(UVH_NODE_PRESENT_1); pr_info("UV: NODE_PRESENT_1 = 0x%016lx\n", np); - uv_pb += 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 >= sock_min) { + _min_socket = sock_min; + _max_socket = sock_max; + uv_pb = sock_max - sock_min + 1; } if (uv_possible_blades != uv_pb) uv_possible_blades = uv_pb; - 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); } static int __init alloc_conv_table(int num_elem, unsigned short **table) -- 2.26.2