Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1179707rdb; Fri, 16 Feb 2024 07:36:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWvyiwz2y7XRbIWibCBLHbpvI8drYHQLoQ3vtEaLSta7nh137tDUPK8ZST/l5GMSKVHsHQC5MDFX1Gl8W/nCe8XmOzV3827m6CEV+tWxg== X-Google-Smtp-Source: AGHT+IEsfrjfF6A1clcxWLv6jAw/L5rdIzFinbMSl9J4oGnJjE0QDAeOC/383wHzp9/V93UHNG39 X-Received: by 2002:a17:902:9047:b0:1db:2d8d:92e with SMTP id w7-20020a170902904700b001db2d8d092emr4540734plz.41.1708097804916; Fri, 16 Feb 2024 07:36:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708097804; cv=pass; d=google.com; s=arc-20160816; b=vS6GYaItnvT8zgd2eQ7TVfWufJk844V8iCcuVCey7yOgipThGp/dXKWH2VK7RZFATR z3TuVkqiCuTmyjcX5WryL7B9jIt4q8LKDMN5DeypdfXz9JuolwZrR51bPZCVcRzHLThv /4Pl+Dwg5MeUioUEAvcEX/l0uNw+B3WQIxFHHeHy7ME1kh0gQM7NSZ1J99cXj+cpe83G toLl2BO4c0aPY6GRqhVfEtXutBvY2CcKOeH3eexW8lHzAAJW8zwoLN1dTZMQQr6HQ52c ckUkFFHpqzfj99/55b0PSktAb/8tb3JNIw57bocOQLZLMgoPmughr588SYEZJ5Ms5Auc 1XuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=6JL3AVNxS6+XrDGfi2ULyasbPvT1ZPYAFPvp8FlG+tM=; fh=bKFZC7eFAaoHEVJ40HlAwnrPNXnqvg4zDQ5eWTP23JU=; b=oqsHO9UPqaHt+0359uI2GZ08NqMQIWL46EgfJODf9tzAzOdZhTEjSLbzF/ymxGlhTF cTqlnC59yNXZyHaymyexlassO4ozCoD4p+mKKzL5wT4wDEljDE07QRqEwRCW5PfaVf8b TsraSfPilCoxNjZ7bSTZNf/A+I7xItvRItnzcPvbibt3ctOzXNdh6EsLesfs+OiZiwFG nU/JQqOzm7jKsjSIOF05IXKhtWATh2w0rey/1wW2bxBqH3ByzxKGLwA4tdtUGPLuXQpt w+/aa1sPGttYAh/TGn+6E7hjfeaFbYr/h0AIPOmQTcBTW4fwV5HYeE0zK08GyNFEnlb9 loFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="KnUtqP/C"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-68848-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68848-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k18-20020a170902c41200b001d9f57ef641si14936plk.425.2024.02.16.07.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:36:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68848-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="KnUtqP/C"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-68848-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68848-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 31C4BB22085 for ; Fri, 16 Feb 2024 15:28:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B516151CC7; Fri, 16 Feb 2024 15:17:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KnUtqP/C"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lG7xGSGd" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA59B14E2F3; Fri, 16 Feb 2024 15:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708096652; cv=none; b=LDoo8oW3Z++A9GaSmjvbYSWAIcXM8Wc4Nd19J+iHiHnJ+fPZr5H+GQiwPHQjl1YEMdzzrlmHSkJVyyJKIBMqbNjPXdL++nekd779fhL45A8OS2sv/FlT+9vmL6LDP2oC36JFmu9iKj4E8sOQJZAfdECkUQugjnqgV/+wGBNw1Ro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708096652; c=relaxed/simple; bh=u0vfNjz6EkPGPyptEeG9+sFywPr52PwvU05H/dZjJCs=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=hvYvoPXWPRcByF53gpeRJr8j4MZlzf7XoRXK1CXF+zLtNUynmlHud7NPZ3Bafgv9Et+hYEOPXvz6qWRVdBBZIVeWaHLQaO3dSQv3bHDNetVe7lE1loIBIAYAocUlv+k1HXGKQHGVvcmMyfn1Gzyxs1y8qO1Msd+tTGSRn+kzaIE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KnUtqP/C; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=lG7xGSGd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Fri, 16 Feb 2024 15:17:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1708096649; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6JL3AVNxS6+XrDGfi2ULyasbPvT1ZPYAFPvp8FlG+tM=; b=KnUtqP/CdmIc9XJn58a3Cb8BzEucQONOlRQBWkEN7prQ0d2HEeatXKQ7Vi/HaV7U1dxcEr /IBj/FJT4d5GdnU69J0w+veGcdW9fKgozbqMiO2boWLBWTTHKtq/1nJ0qqzX0LrE/EwLqd OWH7Sk4ViDXUsPgRPNJ1DdBMfMV7ruI/ilWi1tjjhhlGaJdE4VS3H2M7eboOLs68VAZVMa N9re2ILADUMMOmh/P5QL+qxa+BlyKj21pSvCsimqSa9V8M7a1aYuh4LRrlO43xfcJ8LDea oJh4tcT6X9M7KwLd6Dy/HDD+KakC+6nn0smH/OJbRJxn9VhgB+2W6fyU3xrPRw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1708096649; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6JL3AVNxS6+XrDGfi2ULyasbPvT1ZPYAFPvp8FlG+tM=; b=lG7xGSGdeZijO2gGuyxD2PGbje+b45PrP4S/pMTxSqhonRQ49fXThZhDAbvXPkQTHlxoGt fVZwU2YtIukFkeDQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/apic] x86/mm/numa: Use core domain size on AMD Cc: Thomas Gleixner , Juergen Gross , Sohil Mehta , Michael Kelley , Zhang Rui , Wang Wendy , K Prateek Nayak , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240212153625.270320718@linutronix.de> References: <20240212153625.270320718@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170809664856.398.10325703229977624429.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/apic branch of tip: Commit-ID: d805a6916037a716e858a0a91d844bad1ca8f48b Gitweb: https://git.kernel.org/tip/d805a6916037a716e858a0a91d844bad1ca8f48b Author: Thomas Gleixner AuthorDate: Tue, 13 Feb 2024 22:04:17 +01:00 Committer: Thomas Gleixner CommitterDate: Thu, 15 Feb 2024 22:07:38 +01:00 x86/mm/numa: Use core domain size on AMD cpuinfo::topo::x86_coreid_bits is about to be phased out. Use the core domain size from the topology information. Add a comment why the early MPTABLE parsing is required and decrapify the loop which sets the APIC ID to node map. Signed-off-by: Thomas Gleixner Tested-by: Juergen Gross Tested-by: Sohil Mehta Tested-by: Michael Kelley Tested-by: Zhang Rui Tested-by: Wang Wendy Tested-by: K Prateek Nayak Link: https://lore.kernel.org/r/20240212153625.270320718@linutronix.de --- arch/x86/include/asm/topology.h | 5 +++++- arch/x86/mm/amdtopology.c | 35 ++++++++++++++------------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index 9bca92b..be27ef7 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -121,6 +121,11 @@ struct x86_topology_system { extern struct x86_topology_system x86_topo_system; +static inline unsigned int topology_get_domain_size(enum x86_topology_domains dom) +{ + return x86_topo_system.dom_size[dom]; +} + extern const struct cpumask *cpu_coregroup_mask(int cpu); extern const struct cpumask *cpu_clustergroup_mask(int cpu); diff --git a/arch/x86/mm/amdtopology.c b/arch/x86/mm/amdtopology.c index b3ca7d2..5681b99 100644 --- a/arch/x86/mm/amdtopology.c +++ b/arch/x86/mm/amdtopology.c @@ -54,13 +54,11 @@ static __init int find_northbridge(void) int __init amd_numa_init(void) { - u64 start = PFN_PHYS(0); + unsigned int numnodes, cores, apicid; + u64 prevbase, start = PFN_PHYS(0); u64 end = PFN_PHYS(max_pfn); - unsigned numnodes; - u64 prevbase; - int i, j, nb; u32 nodeid, reg; - unsigned int bits, cores, apicid_base; + int i, j, nb; if (!early_pci_allowed()) return -EINVAL; @@ -158,26 +156,25 @@ int __init amd_numa_init(void) return -ENOENT; /* - * We seem to have valid NUMA configuration. Map apicids to nodes - * using the coreid bits from early_identify_cpu. + * We seem to have valid NUMA configuration. Map apicids to nodes + * using the size of the core domain in the APIC space. */ - bits = boot_cpu_data.x86_coreid_bits; - cores = 1 << bits; - apicid_base = 0; + cores = topology_get_domain_size(TOPO_CORE_DOMAIN); /* - * get boot-time SMP configuration: + * Scan MPTABLE to map the local APIC and ensure that the boot CPU + * APIC ID is valid. This is required because on pre ACPI/SRAT + * systems IO-APICs are mapped before the boot CPU. */ early_get_smp_config(); - if (boot_cpu_physical_apicid > 0) { - pr_info("BSP APIC ID: %02x\n", boot_cpu_physical_apicid); - apicid_base = boot_cpu_physical_apicid; - } - - for_each_node_mask(i, numa_nodes_parsed) - for (j = apicid_base; j < cores + apicid_base; j++) - set_apicid_to_node((i << bits) + j, i); + apicid = boot_cpu_physical_apicid; + if (apicid > 0) + pr_info("BSP APIC ID: %02x\n", apicid); + for_each_node_mask(i, numa_nodes_parsed) { + for (j = 0; j < cores; j++, apicid++) + set_apicid_to_node(apicid, i); + } return 0; }