From patchwork Fri Jul 28 12:13:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 127606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp407061vqg; Fri, 28 Jul 2023 05:44:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlGlUi3viK3RBXbTrRiaXBSfngPoG8y42j5m7ThlWHy477YOnpNvO89FaeAsQPZBaNFTzfyW X-Received: by 2002:a05:6a00:1302:b0:686:bd88:605e with SMTP id j2-20020a056a00130200b00686bd88605emr1844247pfu.11.1690548262191; Fri, 28 Jul 2023 05:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690548262; cv=none; d=google.com; s=arc-20160816; b=KwcdviH+oyZY/jIINQbiJXNvFNMVznA8tWXQpUfEWnxAJFZrRq2SICxq51cH4mKwHg h1k7yJ85+EFHzCBo3xukqAyIXci2HielVMKvHJ7/dvHJGaaHBkqee1GpCx3cBNgNEYB3 Qlha+fb/7bAwHNW8iY5CkaPNjbHwFrgfOojXqernu2C+LPjkxs5OjVU7WLBEyGeg9IqH mXXosDUXW/PDFLIMVR45tMItXraD8wULqE+MHyrTWRFs3UZwGAZ7/EMjD9xJQyctMdak xfvSmoJSK4+dP2MMCkCiiccUxqjHh3NLGkW6qHL6kWUcYlUu8AQX14vkQ9fBlo+MEiK1 cgiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=v1jagm3qezJbhLi1KwbMq1PXX83lXTZZ+4TGqrP0z90=; fh=y/slnYrqOPbByUK75sFPvq3cYp2SbZKM1q7UWSqjNrY=; b=xt+JYr3z5aiLYnwc1fxupTCDeUUeOAjl04QM2Y2uyk6u7AuxMo0oDoymkuDi4xJhT1 RR2EKkvPAsXDFYJKsJ4e+4UPYtNaDhRCawq5OO31S9aAR12oR3rP6J5bHGDukTJgaWZo 2T0TlGM+Qn9sQWI3zSknBfG4YSXpu1zp9yWdTMkFjycPRcT6VlregTPlzn5o732HijPa fMhE6I1joVkNGbOBnjIjY9YQX1dJpMmmPlVI4kIhTdRC0OrzbqybebgWlYveUiSjPyxA 6cOZIz1CdIurV5QxH/XpI+yqaytr3z9553QcdumO5E20eJ7Wu6Q/KnZnAWurB4S5ufr6 eIJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OaTxVvEk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=vjKBc1lA; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay21-20020a056a00301500b006862e207c34si3104966pfb.66.2023.07.28.05.44.09; Fri, 28 Jul 2023 05:44:22 -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=@linutronix.de header.s=2020 header.b=OaTxVvEk; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=vjKBc1lA; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236589AbjG1MQ1 (ORCPT + 99 others); Fri, 28 Jul 2023 08:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234567AbjG1MPb (ORCPT ); Fri, 28 Jul 2023 08:15:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C1949CC; Fri, 28 Jul 2023 05:13:24 -0700 (PDT) Message-ID: <20230728120931.448157949@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1690546402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=v1jagm3qezJbhLi1KwbMq1PXX83lXTZZ+4TGqrP0z90=; b=OaTxVvEkBn8or9jvNdmQrVSkU7kbk6MdUYHBPqPvE3wbQk91EKdmBkdwW5cTUh0ohjVeZ/ 12rsXDyg/bDlbfRu5PQDd2wnvaxpTqYmed4W8xQCBeFIZeHfFqTxccMjm77jD4t/LmEE1g FzqGG24CYrpgWPN7yF8zMw0SMqm4PojNWv4ohANuHzeA3Li1O2Pe+7cmHFI1eZyI9awM4i 5KVSm+7/Ts4oVObTBC5T2vcvMjy6g7yyQdZBQnWV85yhhrZTdopob/PWtaIJvjWCOGAWBk g2OaccF3YJckfYJfKdtYSxcpKSvoS2/OGETHJUXA5WkQa0e7kFfVHE67BYw5qg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1690546402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=v1jagm3qezJbhLi1KwbMq1PXX83lXTZZ+4TGqrP0z90=; b=vjKBc1lAvNSZpBzqQct6EMy+KlJwl47uNDI5KZB7JlhCw7KdOCBpBKMVBDQ/FCoheBWmal ewVNnLaHvO6uwXDw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Tom Lendacky , Andrew Cooper , Arjan van de Ven , "James E.J. Bottomley" , Dick Kennedy , James Smart , "Martin K. Petersen" , linux-scsi@vger.kernel.org, Guenter Roeck , linux-hwmon@vger.kernel.org, Jean Delvare , Huang Rui , Juergen Gross , Steve Wahl , Mike Travis , Dimitri Sivanich , Russ Anderson Subject: [patch v2 32/38] x86/mm/numa: Use core domain size on AMD References: <20230728105650.565799744@linutronix.de> MIME-Version: 1.0 Date: Fri, 28 Jul 2023 14:13:22 +0200 (CEST) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772668334744431878 X-GMAIL-MSGID: 1772668334744431878 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 --- arch/x86/mm/amdtopology.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) --- 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; + 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); } - - 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); - return 0; }