From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (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 5493D43687; Fri, 19 Jul 2024 18:16:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721412969; cv=none; b=EY+T6GE36jqi38fmshp/jEiggZBvxfaiFxN9By7kJ+yVXQQZ5wPb+gQCVNfT/0VZkxfpsKl8PM3jABIDpb7kAWl5x1+H9sTAYNBa0O3RIwuvvyuwB3qeT9f/E6LiKhDNTDHtW2ooFcS8LyCkcI4KH/9yMAO4ZMOwsv0IEx8d8ao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721412969; c=relaxed/simple; bh=qNf5UpMd67REEcicZX3rLO8ek+sXJ1i60zkOjoh4XE8=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W0iPIWV7RfXFnfEOdCZFGCKKcODCRuDsOmraAlT9qli8zEhhtBn1XIuRvBX2VmKe+Lc7+KaC/N0mB+F9nlcUqkGQb/NT1iIZname3ayjdkCZhGaa/9udewIn1rReIqbPdo7ZUeOsACOt0SoyyLR7QG9jRR6hhq46rKpSJdnUE6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4WQd9q016gz6JBkF; Sat, 20 Jul 2024 02:14:39 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 1F7D11408FE; Sat, 20 Jul 2024 02:16:04 +0800 (CST) Received: from localhost (10.48.157.16) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 19 Jul 2024 19:16:03 +0100 Date: Fri, 19 Jul 2024 19:16:02 +0100 From: Jonathan Cameron To: Mike Rapoport CC: , Alexander Gordeev , Andreas Larsson , "Andrew Morton" , Arnd Bergmann , "Borislav Petkov" , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , "John Paul Adrian Glaubitz" , Michael Ellerman , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , "Thomas Bogendoerfer" , Thomas Gleixner , Vasily Gorbik , Will Deacon , , , , , , , , , , , , , , , Subject: Re: [PATCH 16/17] arch_numa: switch over to numa_memblks Message-ID: <20240719191602.000075d2@Huawei.com> In-Reply-To: <20240716111346.3676969-17-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> <20240716111346.3676969-17-rppt@kernel.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500001.china.huawei.com (7.191.163.213) To lhrpeml500005.china.huawei.com (7.191.163.240) On Tue, 16 Jul 2024 14:13:45 +0300 Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > Until now arch_numa was directly translating firmware NUMA information > to memblock. > > Using numa_memblks as an intermediate step has a few advantages: > * alignment with more battle tested x86 implementation > * availability of NUMA emulation > * maintaining node information for not yet populated memory > > Replace current functionality related to numa_add_memblk() and > __node_distance() with the implementation based on numa_memblks and add > functions required by numa_emulation. > > Signed-off-by: Mike Rapoport (Microsoft) One trivial comment inline, Jonathan > /* > * Initialize NODE_DATA for a node on the local memory > */ > @@ -226,116 +204,9 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) > NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn; > } > > @@ -454,3 +321,54 @@ void __init arch_numa_init(void) > > numa_init(dummy_numa_init); > } > + > +#ifdef CONFIG_NUMA_EMU > +void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, > + unsigned int nr_emu_nids) > +{ > + int i, j; > + > + /* > + * Transform __apicid_to_node table to use emulated nids by Comment needs an update seeing as there is no __apicid_to_node table here. > + * reverse-mapping phys_nid. The maps should always exist but fall > + * back to zero just in case. > + */ > + for (i = 0; i < ARRAY_SIZE(cpu_to_node_map); i++) { > + if (cpu_to_node_map[i] == NUMA_NO_NODE) > + continue; > + for (j = 0; j < nr_emu_nids; j++) > + if (cpu_to_node_map[i] == emu_nid_to_phys[j]) > + break; > + cpu_to_node_map[i] = j < nr_emu_nids ? j : 0; > + } > +} > + > +u64 __init numa_emu_dma_end(void) > +{ > + return PFN_PHYS(memblock_start_of_DRAM() + SZ_4G); > +} From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1A4E6C3DA59 for ; Fri, 19 Jul 2024 18:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Rh5sD6+aGHTLGm2HdBCVn62wmUO5xh4iQdICrk+FL1g=; b=ozerXF8/BBt5h5 haX2UgjXFPGNzyTIx7QIdbadzqov4fO6DAGkz/YB9WChl0geyPVH/04I4vWWCMQxo2BGUe/xz2r94 HKcw/jmx+p6a5PIADmZHTW9gxGN5iF2UgGE4k5aMJhlE2UZSgh67f7KzffVQGmM0RSAIys93siJTO rBlPhaGn4b64aeMq4b1Y7oYXyjWnJRhr1Hb1zaZHoMveyrDIvYqe+Q14mldeuoLtA5OOxHIoLkACe wtjoBX3Romsbv97Rtoze5EWNJHxXY2MWSuOtyMnimOamE/k7hbGuhpyfNITbvR0UXiSov6ucN8WcW 4quobqeqZaMq15TBwrTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUs9g-00000003Ufl-3Jx9; Fri, 19 Jul 2024 18:16:32 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sUs9K-00000003UYc-0wtS; Fri, 19 Jul 2024 18:16:11 +0000 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4WQd9q016gz6JBkF; Sat, 20 Jul 2024 02:14:39 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 1F7D11408FE; Sat, 20 Jul 2024 02:16:04 +0800 (CST) Received: from localhost (10.48.157.16) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 19 Jul 2024 19:16:03 +0100 Date: Fri, 19 Jul 2024 19:16:02 +0100 From: Jonathan Cameron To: Mike Rapoport CC: , Alexander Gordeev , Andreas Larsson , "Andrew Morton" , Arnd Bergmann , "Borislav Petkov" , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , "John Paul Adrian Glaubitz" , Michael Ellerman , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , "Thomas Bogendoerfer" , Thomas Gleixner , Vasily Gorbik , Will Deacon , , , , , , , , , , , , , , , Subject: Re: [PATCH 16/17] arch_numa: switch over to numa_memblks Message-ID: <20240719191602.000075d2@Huawei.com> In-Reply-To: <20240716111346.3676969-17-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> <20240716111346.3676969-17-rppt@kernel.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.48.157.16] X-ClientProxiedBy: lhrpeml500001.china.huawei.com (7.191.163.213) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240719_111610_563994_188EE6A0 X-CRM114-Status: GOOD ( 18.34 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, 16 Jul 2024 14:13:45 +0300 Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > Until now arch_numa was directly translating firmware NUMA information > to memblock. > > Using numa_memblks as an intermediate step has a few advantages: > * alignment with more battle tested x86 implementation > * availability of NUMA emulation > * maintaining node information for not yet populated memory > > Replace current functionality related to numa_add_memblk() and > __node_distance() with the implementation based on numa_memblks and add > functions required by numa_emulation. > > Signed-off-by: Mike Rapoport (Microsoft) One trivial comment inline, Jonathan > /* > * Initialize NODE_DATA for a node on the local memory > */ > @@ -226,116 +204,9 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) > NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn; > } > > @@ -454,3 +321,54 @@ void __init arch_numa_init(void) > > numa_init(dummy_numa_init); > } > + > +#ifdef CONFIG_NUMA_EMU > +void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, > + unsigned int nr_emu_nids) > +{ > + int i, j; > + > + /* > + * Transform __apicid_to_node table to use emulated nids by Comment needs an update seeing as there is no __apicid_to_node table here. > + * reverse-mapping phys_nid. The maps should always exist but fall > + * back to zero just in case. > + */ > + for (i = 0; i < ARRAY_SIZE(cpu_to_node_map); i++) { > + if (cpu_to_node_map[i] == NUMA_NO_NODE) > + continue; > + for (j = 0; j < nr_emu_nids; j++) > + if (cpu_to_node_map[i] == emu_nid_to_phys[j]) > + break; > + cpu_to_node_map[i] = j < nr_emu_nids ? j : 0; > + } > +} > + > +u64 __init numa_emu_dma_end(void) > +{ > + return PFN_PHYS(memblock_start_of_DRAM() + SZ_4G); > +} _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 53827C3DA59 for ; Fri, 19 Jul 2024 18:16:31 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WQdCy0MLpz3d2N for ; Sat, 20 Jul 2024 04:16:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=185.176.79.56; helo=frasgout.his.huawei.com; envelope-from=jonathan.cameron@huawei.com; receiver=lists.ozlabs.org) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WQdCW3qzsz3cD1 for ; Sat, 20 Jul 2024 04:16:07 +1000 (AEST) Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4WQd9q016gz6JBkF; Sat, 20 Jul 2024 02:14:39 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 1F7D11408FE; Sat, 20 Jul 2024 02:16:04 +0800 (CST) Received: from localhost (10.48.157.16) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 19 Jul 2024 19:16:03 +0100 Date: Fri, 19 Jul 2024 19:16:02 +0100 From: Jonathan Cameron To: Mike Rapoport Subject: Re: [PATCH 16/17] arch_numa: switch over to numa_memblks Message-ID: <20240719191602.000075d2@Huawei.com> In-Reply-To: <20240716111346.3676969-17-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> <20240716111346.3676969-17-rppt@kernel.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.48.157.16] X-ClientProxiedBy: lhrpeml500001.china.huawei.com (7.191.163.213) To lhrpeml500005.china.huawei.com (7.191.163.240) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nvdimm@lists.linux.dev, x86@kernel.org, Andreas Larsson , Catalin Marinas , Dave Hansen , David Hildenbrand , Jiaxun Yang , linux-mips@vger.kernel.org, linux-mm@kvack.org, sparclinux@vger.kernel.org, Alexander Gordeev , Will Deacon , Thomas Gleixner , linux-arch@vger.kernel.org, Rob Herring , Vasily Gorbik , linux-sh@vger.kernel.org, Huacai Chen , Christophe Leroy , linux-acpi@vger.kernel.org, Ingo Molnar , devicetree@vger.kernel.org, Arnd Bergmann , linux-s390@vger.kernel.org, Heiko Carstens , Borislav Petkov , linux-cxl@vger.kernel.org, loongarch@lists.linux.dev, John Paul Adrian Glaubitz , Dan Williams , linux-arm-kernel@lists.infradead.org, Thomas Bogendoerfer , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , "Rafael J. Wysocki" , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, 16 Jul 2024 14:13:45 +0300 Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > Until now arch_numa was directly translating firmware NUMA information > to memblock. > > Using numa_memblks as an intermediate step has a few advantages: > * alignment with more battle tested x86 implementation > * availability of NUMA emulation > * maintaining node information for not yet populated memory > > Replace current functionality related to numa_add_memblk() and > __node_distance() with the implementation based on numa_memblks and add > functions required by numa_emulation. > > Signed-off-by: Mike Rapoport (Microsoft) One trivial comment inline, Jonathan > /* > * Initialize NODE_DATA for a node on the local memory > */ > @@ -226,116 +204,9 @@ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) > NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn; > } > > @@ -454,3 +321,54 @@ void __init arch_numa_init(void) > > numa_init(dummy_numa_init); > } > + > +#ifdef CONFIG_NUMA_EMU > +void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, > + unsigned int nr_emu_nids) > +{ > + int i, j; > + > + /* > + * Transform __apicid_to_node table to use emulated nids by Comment needs an update seeing as there is no __apicid_to_node table here. > + * reverse-mapping phys_nid. The maps should always exist but fall > + * back to zero just in case. > + */ > + for (i = 0; i < ARRAY_SIZE(cpu_to_node_map); i++) { > + if (cpu_to_node_map[i] == NUMA_NO_NODE) > + continue; > + for (j = 0; j < nr_emu_nids; j++) > + if (cpu_to_node_map[i] == emu_nid_to_phys[j]) > + break; > + cpu_to_node_map[i] = j < nr_emu_nids ? j : 0; > + } > +} > + > +u64 __init numa_emu_dma_end(void) > +{ > + return PFN_PHYS(memblock_start_of_DRAM() + SZ_4G); > +}