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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 381A7C3DA59 for ; Fri, 19 Jul 2024 18:16:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FE386B0088; Fri, 19 Jul 2024 14:16:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9ADBF6B0089; Fri, 19 Jul 2024 14:16:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8756F6B008C; Fri, 19 Jul 2024 14:16:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 68A416B0088 for ; Fri, 19 Jul 2024 14:16:08 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2A9C01208B7 for ; Fri, 19 Jul 2024 18:16:08 +0000 (UTC) X-FDA: 82357306416.03.9FAD7FE Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by imf21.hostedemail.com (Postfix) with ESMTP id 1A3991C001F for ; Fri, 19 Jul 2024 18:16:05 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721412946; h=from:from:sender: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=QlQFoCPPnoApH7o4QfG35+7v775mfwW+rHZf/q1Jvw0=; b=1roVVFV/HIzfTllwe4YycERlHCa64OyIfTAQQUHP1tBkFAIaGXVmpM/4WFYSZreWNxoKBc ODsm2kH8VYSua0rRYjp9fHyeO+xFIAujGdAa7n7rkM0FDcuoLuqp04CBzMTqfH7nvLPUW2 GgBNgraRQApE/zNOILwGFS1gh0TbwGw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of jonathan.cameron@huawei.com designates 185.176.79.56 as permitted sender) smtp.mailfrom=jonathan.cameron@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721412946; a=rsa-sha256; cv=none; b=g44mtxs9hb49y+KF5g0Xyj5wi8rwz3YVjzj/heAnLtf+9lcPVMSqsJZG9ctlQ94c0is8+g DuFRfYPhCGFoloM8ANmZPjilXGscBafDuqr1NNJ2C6hhwvgW6kqM2eJyNGCok2JEuJYZUy YhRyEXtHGYaBYBUbT2qzcxCGJfalB4M= 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 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-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1A3991C001F X-Stat-Signature: m4aaqjq79gq7zem9z198ah915hwerhja X-HE-Tag: 1721412965-920452 X-HE-Meta: U2FsdGVkX19CSThGtXapkyDQiZangyLeqxjYdEzSfD+pPAnRQmJETTjQ44O0a4uNAavhge2K/7E0CsHLgI9irdziuVntq6irkxKBPXVz7roWJtaYPddGSUWSu5im+qOfKGFSi4o/W1admcTjdxWvJiwt3wPu6VNgL4mjdo3BwwAOqz7ConPsYaZilBqKA/FXmID3Th3DwnpSZItLB9fBYOgdE1IrnWdVAdfDDt2VJEAIa9Jk4uR3MYrJJMWbOEeBsiLq1mwvwf0Kj8mmyfF6AzlITLN/5gjzoin6h953UZofgrkFLamFcSy8Cc1wBuhl2QzfnxQz1melwM6J/U7NOvGYryR8fer87AZM80Y/XVeKiJj4nz8ukBKQTjPE+X7SAG0YXTp3jSD3OzSls/BiRAMAjGLgME5IsGS+DD71CQPO2Ss/yb2jT2KtRwpibB8xnOtVbkpMjQ5+pAmq/MdmNGtxBBr3kJFkMS6n/YYeKt5yswOC/GFPt5JV1eIcUyMEStPk16RZebxM0/ovc2kWTO8UOnDnfHF8i5jtFVft860ib2CKOwcm1gR62UmhD73Nrw2uF9cMuRZWVHl4CbiJiTjdoX3C2Apa9XCoucmmdZrdQ/4wzF9HR8dQc4/M+r9lv8BL7GOZD+hyTuWplYQEGM4I0OYdCeh5MMdeCCCorFgMVzn4hxYB96+4gJJYjWxhWcHDmA6i0i1tGh01HViNH3saB0FJsdYujQXlsm1e1hrlfGIxWrdssa8EaJyLCxzsXN0JuP1YeA0/R3s8H7vdXgXs52/upKNOu8JhUuXpwNMo0OvaZBBESD5bYmW1c591CtWDNL7FvO1xEzHxPGGzPhWqEfl8+ngH+czRUFhWAzGwAgBkf5HN7C6yHaDwZVt1DWFT+6c6MgvTcAkQf6Wbby7Mut9ggVaUwXenctqa2PwPq2We5k5F0VGgjt6jjFR7tzzE2+2DWyaZEWXUMre q+3qSykC bBqpXnXbht/LHQOZKzs2LYA7awqoCaeu1PA/GjQRJiGkr8RT1DHW2fRY/RLfrRpsCKHsy0Wzj5qwh2GX4Kzst8UdygG8qpyi3YBHk2Zge0ANd9hJP38iRAA6WgRHfKord5y/h/nb8v7hXkVpwRDGXR2UQsLOwwnrlALqrtL7tV4Cb8G4qwCy0yAaptcxAVQZkydwOTmx5Tf8m7Vmaye7glcfDZ7Nbqw+Hs5wA1ComeBMNHqAbIgyohru2bWBl4baN3fOST0aChCCn3JZOSf9cM2Z4Rynejilr715N1WxV0RtIM/9MHUirbXN6w/QoTLTF9tX+Z3LEd8azWv7g0Pb3AdsHeKVcpPyXmPbH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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); > +}