From patchwork Thu Aug 1 06:08:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749630 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 04627C3DA4A for ; Thu, 1 Aug 2024 06:09:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80AC06B0083; Thu, 1 Aug 2024 02:09:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E1776B0088; Thu, 1 Aug 2024 02:09:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A9D86B0089; Thu, 1 Aug 2024 02:09:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4BB3E6B0083 for ; Thu, 1 Aug 2024 02:09:07 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B3E0E1C1B57 for ; Thu, 1 Aug 2024 06:09:06 +0000 (UTC) X-FDA: 82402648692.15.979DED6 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf05.hostedemail.com (Postfix) with ESMTP id 579EC100017 for ; Thu, 1 Aug 2024 06:09:03 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jnYRQTD4; spf=pass (imf05.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492470; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wZ242ZOd8/0+flpTZ9kfJElYFRYLhOV1ntrlJ80jrR4=; b=fuRTHu7lWS5QjqTxfkv5oddHMsHO5IbxJfIhOxJXEEBZvJL1kq+fx77Ohx87+WSp2E9yVh 5B7EirJ9iTl5y1u8pbyt08pDga8h3OsnIorGiVpQrs/ibraO6GMGDEE9+tJMtahoheExMl XLSwvBK8WHDsF2X7NEF0m+Ef/aLgqFs= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jnYRQTD4; spf=pass (imf05.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492470; a=rsa-sha256; cv=none; b=TX8PokLRguLmkeVtX0V7KkAa2A44kbUBtaXaFOx+9pI4/jpJYG61GaSIAvoVtQl/PgGrgn Sta0nLQtmgeCIaLN6EmeNNmUClxiE0Jw/3D7yjR8IbzRKgseFG3iuuMyThNQq30uvU4eY6 oIBwglIq/ysW4iVM0SYmYGK3Mxk0Eys= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E5BCDCE12D4; Thu, 1 Aug 2024 06:09:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 160B6C4AF0D; Thu, 1 Aug 2024 06:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492539; bh=ahZO7HcpjJfu28QyxaeMh/IeX+F8/tsP9+GBaY7P+JU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jnYRQTD4LOi6UYgIg7wnq6U4iqrnpuP08zjDaKgtXu3WJUYa/E097kuxH2aeK5VY/ Bcq+eK7GU5lblfPhzlOYIPo3Arzk4E40wMmg3gN1FTZ2TxhvcvhTRw68CsZTvioJTn Wk3ISPON95CHAcboKkfATHNIu6XwkVsh4264IZAISjY8p9ijm4bYlQ+mnOeh5hZziE RPlKjD3veB4BttqTLV9MIi8S0/XpTfL9SupmvL01R3UMwD8Xz5dAC7pERBZLD3bqkX W9+XZrhHYiJ2Mids5IYyn3anSkKL5z5ZYL4TiQyrUAV2GaerVPAbMpNy9iVuloAcq2 f8gJBIb48MQag== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 01/26] mm: move kernel/numa.c to mm/ Date: Thu, 1 Aug 2024 09:08:01 +0300 Message-ID: <20240801060826.559858-2-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 579EC100017 X-Stat-Signature: 4i6p6tbmtpu3t398kiyyfsjp5efsyrct X-Rspam-User: X-HE-Tag: 1722492543-277408 X-HE-Meta: U2FsdGVkX1/lc+9dX3y72eOTceCNeDHpNCVmiTfN4Os/QvvnKXgbpWvc41CikWaw46O0mGuE+E2NtUahpMX4ZKRtYZ5hFPRsHYx8tdKLBBRIY5qI9ATWb2kwcEeldaD02s9o5P7zqc78scAarnCGwlRpAWgSMbkoox72b2VAo2gVdroP2WfY+VbORBWEb6ojlc1mhmvk4w4b+wHKwna1J2WcaIoq1v5ia/VB7+IoDIJqBcmLxVjXYercPlVE2v1UDyIj0Cg655l0+g9QsXOll0AGzsbCS/KhWpG/LzUnelUI7m8QjP6mexdA4AGFFyx4p3+LrdnbjtOcF/ltkDL8Hgyc+GekBeF1BSY2MZczAgLQyIbkhgBdfJlCYJnSwUqRMwWdlsdM/7LErm13CeE6yy4LVPxKCgWiZ8gRYYywGEUQQgLK/fjEC9asQ1lOKgR/pzNKmS6FFSInI2sNF0X23beAOA1RrrJAFD89QO1NCplGcMDbkWowTTup0I5WnJOc9XnhU06tIwelgVguFSmAyF4pECAUwCmlas2JcL+IBT3Vu3zqBjEWwmTWHEQoIu8JWlwngnUlGX7/ru2popKsOGUO2gM0qKOIeK0pbEPKRSljZpe2TlIGpc2/bJUzsgHZTPIw4xic5NAEDvZkm9W3dooYIec69quRd1ALsoVvIAn+l2jz7dA5dyghmtlQoPjfkDLJw4Z45W2gu12X7HSS4H66JUxAyU4QaiMl8Nn9yiAtAUKdlc/BG77OX3z7hRMVxMBZPnEIiwQTo4epXS7yUaaCiWVv97qOpW1ZGaNbe96mRFY10sser9+jnwSVjElXnQQTT/f6xH/4E9S9QO8a4amrsNv1MTxPaYIibKGoiXUJpy6OOP7GUGqvfnn1txsi+Wvra3KA7omeeMRbXHBjsGKXDZj5OQPLJN/kifJUNV/geMND2eWHvNvEMEEoxE63lpZ05MvzDv9vd4vVUkc zr/zspSW 6pjow14r3mBMgPBpta6CjQprX1iBrHVjJkZs1xtoHh2B6UNd9TDDJf5KeArKxxsTELouqiKMQhhfltfY3068McNVsaMFmzsvN2kLtECF/Uas0OYSY5NUn6NRpv0R9XpxKXkEdv8pFaVVdAdXW7khxUyms7UdMUSyGHsDvQM7tFk41fpdGIfWIwLK/RpEQKd8UUkMOF7eFNBi93ArZtAKW15mnmtC92D1MLY1r0VTgCixdvDFM+rBLV/6WLHL82vzjlAZAN1yd6wsJTfYz8tSgDFIgA5s9fLCqTna3KAPKY6YW1C2mZyJIRdEgsuLvUUp1QRTiRpSDP3AaTM61ZLsz08+jNg== 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: From: "Mike Rapoport (Microsoft)" The stub functions in kernel/numa.c belong to mm/ rather than to kernel/ Signed-off-by: Mike Rapoport (Microsoft) Acked-by: David Hildenbrand Reviewed-by: Jonathan Cameron Tested-by: Zi Yan # for x86_64 and arm64 --- kernel/Makefile | 1 - mm/Makefile | 1 + {kernel => mm}/numa.c | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename {kernel => mm}/numa.c (100%) diff --git a/kernel/Makefile b/kernel/Makefile index 3c13240dfc9f..87866b037fbe 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -116,7 +116,6 @@ obj-$(CONFIG_SHADOW_CALL_STACK) += scs.o obj-$(CONFIG_HAVE_STATIC_CALL) += static_call.o obj-$(CONFIG_HAVE_STATIC_CALL_INLINE) += static_call_inline.o obj-$(CONFIG_CFI_CLANG) += cfi.o -obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_PERF_EVENTS) += events/ diff --git a/mm/Makefile b/mm/Makefile index d2915f8c9dc0..4e668be85f0b 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -141,3 +141,4 @@ obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o obj-$(CONFIG_EXECMEM) += execmem.o +obj-$(CONFIG_NUMA) += numa.o diff --git a/kernel/numa.c b/mm/numa.c similarity index 100% rename from kernel/numa.c rename to mm/numa.c From patchwork Thu Aug 1 06:08:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749631 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 648A6C3DA4A for ; Thu, 1 Aug 2024 06:09:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A06376B0089; Thu, 1 Aug 2024 02:09:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B74D6B008A; Thu, 1 Aug 2024 02:09:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87EC76B008C; Thu, 1 Aug 2024 02:09:14 -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 695C56B0089 for ; Thu, 1 Aug 2024 02:09:14 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E196E1608E4 for ; Thu, 1 Aug 2024 06:09:13 +0000 (UTC) X-FDA: 82402648986.05.A2218AB Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 336254000A for ; Thu, 1 Aug 2024 06:09:12 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UlXPnIkk; spf=pass (imf11.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492523; a=rsa-sha256; cv=none; b=knYZnEuzIPWVVDeu6Lkj0VPF4ycZ+HMxQtO7gFqUHkjrLRsUsnSQwwlGkvmINCMD+CIWzm N65Q2kIcS5jIBTKFsjVmIvutqBiZcFwydiJVEfhuKaQx8Oe8n5gskThKajPMf1tUb4Frtz /7TQr0dyGHNmsKjJuMqkBS/FGuW9pV4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UlXPnIkk; spf=pass (imf11.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492523; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mpDA7GewTCgHjnhlaK2zN79CV/6fdKT07FqjCbVF80I=; b=35+ADEu3My7e3EI9j0KAvtEfzk0IRj5RDofJijE/H/3E8E51NKgx3XWynW7bJhcqnBC7at PqtMXd2ciHd9+HX8OYFiBzkQ7VjX+bzhoh4n5gwTG/LsL0vZwymXNz4XCm4PzaqbXI7toT dWZ8wNiVv7WbHrjxKmnsRpntP4wPYMU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 31D6E61B43; Thu, 1 Aug 2024 06:09:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D56BCC4AF0E; Thu, 1 Aug 2024 06:08:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492550; bh=wE9udk3T5PUOzWhffSqfqF0jfi91yVWMRgCuaEhaWIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UlXPnIkkZQR2dXJRdGRF6ypg+KOsiM9/67c6rYYrhDo2FguVGlVV8shyU7Gz8VzYr +u4Ya4vP+UoPOnxh6t1MSmRl1cHJ08bQvMpxgJIkc9zewWuRHTWoiilbb7qKzEj/Ma RD1tGKdlLTPrJaG8ZEblPomDJdXVPP7dAGf4NXPs+5wYFBxEN5X0Hp589/maJAgny+ TIWDD/cr8uy0CHdC8oTDx0a0OUfJcsPttk+4G1CzKYSKRQW3M5bjNgPSdfPRy3HQTZ ASefzpnG9NOh2q5N+dfBb4Hi3WipAZUAo6fBCWwI90MfToAMZrVqzzDByoyHFMeEDu vLoDKbCBr6w0g== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 02/26] MIPS: sgi-ip27: make NODE_DATA() the same as on all other architectures Date: Thu, 1 Aug 2024 09:08:02 +0300 Message-ID: <20240801060826.559858-3-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: iipxwf5u7nbtqicwntqx1eocbpozb16d X-Rspamd-Queue-Id: 336254000A X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722492552-74209 X-HE-Meta: U2FsdGVkX1+VvxsYYAt7iAcwEGA4lwvenDj5ZyKGqVEjwhVBT8b3RUXxUIutX9Q1deOEsgCEQdlUKpbRPa+DxwmJDl62v4Ql2G95nDISltkKOHY/EXwyLw55gVJj9xXssv4VKW9SY+dsB3cDlH4Q4Em5u3YrVhGs3p58OGnXWEaf9w4D6h5oSo3CGCSNdUq6eR8goauOVTGIwhkrMNWBor5wTQD5/hPMQ8Ga5KKCj2sS/MAz00CMjfhsT56Tbb1zs/2ijI32ZnXVuzzCRJUd05JGfaFvJUXl3Ft3o1GIWcQV9KrL7CWsXUhgl2Yd35g69ZgeA9iVovqdqD6oYb08a7APkmFIeWdg5doFDiGYId3sjcTSjt8lP61JW7rA3KOcAMeE0FQrVBleAOfLaD92BCoj3njXm0mspOmII0LFnuC+65Il2xRMmNPERSrwS5J8rUnaENCcPOSj+3yAvlO3a14cQMJbonT9fQvkyn+lCwIMOi6zXZpxWqCaSuudiCFeAZQox3bdUnZk7WQWQS8xS1mLAOjwgOvtH2uWlp2XePsbzLN3X4G+YKXZlWwP8kNwaOTRpC3uZSdZ60Qo9vFLUthJfD8uUXE5hK6jLhHHqNjQEhqoJeTeIAjiU+C+VDDrHTCp+S2ibcmp70Mn0Dz+kOYkUZqteA3LBroeFLF9uDAxlrW8JkcVBCAdEMWJWglLATTpC82YXnomSEfPHjDOm2ygnBWjT/VnL3rKYqGxBeCH3SG5X8gO0e+93iqFDOGQS2IQlSd7Zf6u225XZ9lUPUHrGDEXNbfhopgw/xOZHv5sZlEiWHqf9t/NWJw7tOoH+1dClfUcv8SxkO3X0qgIVv7vONH//sQ0a/YOobkUeS+DPYFKohAI+5y258XsIaX6c3tCtJrBOPfjw95sSRs5Wp8iDvZKVazRpVdhC+/UtQ3EitDgmm/mYboQuTo/lfESNmSrrSK003RunpPM3OU WI1DQMf2 bkd2bo8t2TYvEwyWBHyoAD8MjGd82q1rUxcGNwL/wHc+Z3omReUdZGjt/WWqVg97g729t8pFJoHMHwPs9MnrmOnaFLxCsgoIsV/wDSt8SPo2am+ezw/8RWxlgm1aBVwnTDQDNV0hz7T1HkcR9y3MZniob5iP8LlEIHyCqCkgXwSM06purtLDiCyzipSauyVYVVb3M0PEyV1Yu95IDD8E78uNpb5sVHFrNSjZMTBpaS0G3gpBQNl7mfrskVBNU23Aorhsi4fI+93s9vnPN0h0fjU+FljCZ5EiaUmQYisHJur+tWf+QGVNPzqXBXRJVWbODTkDmUfVbsC9h/lXZ4N4n1leeVivzBX4U9A8MZ5dSfFE35/2VehMy9zSal2NfT+N2ofLzNGnKYZLnjLEww7oS3dG/Gg== 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: From: "Mike Rapoport (Microsoft)" sgi-ip27 is the only system that defines NODE_DATA() differently than the rest of NUMA machines. Add node_data array of struct pglist pointers that will point to __node_data[node]->pglist and redefine NODE_DATA() to use node_data array. This will allow pulling declaration of node_data to the generic mm code in the next commit. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/mips/include/asm/mach-ip27/mmzone.h | 5 ++++- arch/mips/sgi-ip27/ip27-memory.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/asm/mach-ip27/mmzone.h b/arch/mips/include/asm/mach-ip27/mmzone.h index 08c36e50a860..629c3f290203 100644 --- a/arch/mips/include/asm/mach-ip27/mmzone.h +++ b/arch/mips/include/asm/mach-ip27/mmzone.h @@ -22,7 +22,10 @@ struct node_data { extern struct node_data *__node_data[]; -#define NODE_DATA(n) (&__node_data[(n)]->pglist) #define hub_data(n) (&__node_data[(n)]->hub) +extern struct pglist_data *node_data[]; + +#define NODE_DATA(nid) (node_data[nid]) + #endif /* _ASM_MACH_MMZONE_H */ diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index b8ca94cfb4fe..c30ef6958b97 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c @@ -34,8 +34,10 @@ #define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) #define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) -struct node_data *__node_data[MAX_NUMNODES]; +struct pglist_data *node_data[MAX_NUMNODES]; +EXPORT_SYMBOL(node_data); +struct node_data *__node_data[MAX_NUMNODES]; EXPORT_SYMBOL(__node_data); static u64 gen_region_mask(void) @@ -361,6 +363,7 @@ static void __init node_mem_init(nasid_t node) */ __node_data[node] = __va(slot_freepfn << PAGE_SHIFT); memset(__node_data[node], 0, PAGE_SIZE); + node_data[node] = &__node_data[node]->pglist; NODE_DATA(node)->node_start_pfn = start_pfn; NODE_DATA(node)->node_spanned_pages = end_pfn - start_pfn; From patchwork Thu Aug 1 06:08:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749632 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 3529DC49EA1 for ; Thu, 1 Aug 2024 06:09:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB4526B008C; Thu, 1 Aug 2024 02:09:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B64776B0092; Thu, 1 Aug 2024 02:09:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A54236B0093; Thu, 1 Aug 2024 02:09:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 87CF46B008C for ; Thu, 1 Aug 2024 02:09:25 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3FF6FC0849 for ; Thu, 1 Aug 2024 06:09:25 +0000 (UTC) X-FDA: 82402649490.02.252B8D6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id A01DB140017 for ; Thu, 1 Aug 2024 06:09:23 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bucdLnSW; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492558; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9FVQIJBvwpLpWnxssYSpgj10sNF0Z4o30ZuUMNufdPk=; b=iM/Ru2yTHjudLka3+8WAeOxKaOAyBXzUfaBSVgYxG8vFbAwht19bwgn0FX7Q8gEx8Afvzo a5B+26hEAvYIomrWobTQZJacgp43Cdlnaha/Y8ExZ0AMb+/k4ziZo54qBoD6s03zHigpYO Tw6xrs1NgqOGdgE6IOGqAox/I/5W5rk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bucdLnSW; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492558; a=rsa-sha256; cv=none; b=uxZtEFnDbv5Ah5Tkx0p22h9RqdfGbe2XBpK74hteGZ5W9csImKya0BFJFZD3y4AZN3uRu/ N6dM+WhRmzZrkR0acheVDpTzjkZMGClJW4gprSjL3byRz4ZlMupRxu8GhmxZhPmxF+lMUB +M+HySSvBbj2Or8273I0GeD+KYuqWmM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BFDE362772; Thu, 1 Aug 2024 06:09:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A06DC4AF14; Thu, 1 Aug 2024 06:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492562; bh=mRZLqq2N2ryJ5ZO7g59g+rrLvkwOpPlbSt8yNKJxh4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bucdLnSWpcdcRT5+EXB/9Vj9t5MS7Qn5CSNmaKRNv6NvVMt0IwHITPfQUHQKw5W4m KADunInG9ypv2EkiXb1dRp15PO6S9ZkhHC5orlcNDwZxNq0LAq7vdXnHs51UeN8XC1 qCCdGkD+IwBfa9Dhu62NGSOzskzofKuRJmzlYh8EWIjKqjsCMlnSFjv0suv/LWA7bE /v17MsWN6GsK6hkUk2PpkklVDGARhQKEyYhJxEEdEsm6jaYBM6ERY08yC3+8fZvikl QSv5CNmiG7++F2AcsgKSBHXAeR922kJ8/hbCjc1GagkI6K0Ok0uQtB2agu2yqJ1ylk Nz7e1f94h+Kfg== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 03/26] MIPS: sgi-ip27: ensure node_possible_map only contains valid nodes Date: Thu, 1 Aug 2024 09:08:03 +0300 Message-ID: <20240801060826.559858-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: jchoog1bncr61djw38hitwb687nho83z X-Rspamd-Queue-Id: A01DB140017 X-Rspamd-Server: rspam11 X-HE-Tag: 1722492563-812228 X-HE-Meta: U2FsdGVkX1/OWQsCzWmu54SIMBpm6qyqSUzIZfFeaBO6oIUO/SXyqzXzmvwYqItLiq0CqUjhTZxeB8VlQ0dy8TMTcLezc1PCUGAtFWRYXDWwh3YQaJzu0FdHq2T4dVCKW2ba36GyvJS/gqrCgdL1foKo5hlwfia6K8ioTAVHxzCYrwmg6FaVVabqQiK0zg0QG8SBmtJR8y4odEt6UUoEsCqpPAivx7ZOtc/kJfxiz8KQVJ3BVCVKNHttzFXg4z01BUu6OVcTmkuXO0VT2Pm9LVfbVVvkCZhdZFBjlm3uOnli/f/E5gjmlVDDtdqxf4WVy3sDRAlLDrNP6z1kQlHu+5QPj1RQ0r7SPljAGrmlA013KzBz9qO4Je6OT0Vf75BN2y0m0uEtKnwQMpKPWYzDcLkoq78rW1N9JfpeA+o8G8iIE6j4CLCTLncCt+zPtcTLDGShPewF9LEnPtU7obAwvQyokCZTuPA1Zb3gq175EieztVLz1TfoJNo7PGSxP0cmkiliGBa21eALcgoNwuQq70kkPDmUmsIztGDMCL4PA7xl2pmTv8qTorNo07wa1b978OjQsMjeSTTPaf4UnwbKCeYQgwYKfcbsdNseYe4kO3+p6O1ySsXYX34k/R/z8t1NpH3h1Xvg9fDuCIxRpZG6zE96LyuCEx/cadXU7H3YhseyqCO95zk3QmTuJdtlk2XgfEVWqshA0iVA5wEMyvtEscx8CXjdzNuDyay9tJlsD1B9W/6NXrQZ4Hm5bdJwUbxCJ7ZU9iX3Bbei5h+7JbHdKFe00IdDj/6c8hu5SQDKGmOPC8Y6o+xXAxu3QO2kS+A+xK0nISkIxe+rV+rQHlY2qzSKvKMyRBKHWI9as7HGuxIbx2xWG2mrtYkh/iU35q4jdDZieKRqPCU576zTidjQgm+0dGahyct9k4I0o09ZUlXlNljloK/IdkvK50wyXxvlv7DTBUl+2/LyYXCEysg AIN0UTZX ZYPw3NWv1hlVqIqAIt6tFhtYi5F3XLCJyEG3h4g8JtMP82H82gIVSvmEY/EH5oFBg27XSooUlO6LCT0IQq3MBBulgCKPvr24WA9sSQUcz5hi4YbuCIZv1fpfaI7ABtVkUKXxtfC6o+NhA42fGje9B/U7+p62hXHktn4tl+N38qXLYT7VDuf5AETn2Q/2vGUU5+00wyaLVecQEKRD9pGPXAvVJ5CdSDdrE8SdHndLJQUzzJLnIGqPv5IaDGN/lEeSG0cIboRQvcsCLig2+o2GjY1bExaCUxxCPxtBAb5MGf49F+lDu/rXRTPShbH+aB7RVGY5sfqFFTadbPJg= 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: From: "Mike Rapoport (Microsoft)" For SGI IP27 machines node_possible_map is statically set to NODE_MASK_ALL and it is not updated during NUMA initialization. Ensure that it only contains nodes present in the system. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/mips/sgi-ip27/ip27-smp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/sgi-ip27/ip27-smp.c b/arch/mips/sgi-ip27/ip27-smp.c index 5d2652a1d35a..62733e049570 100644 --- a/arch/mips/sgi-ip27/ip27-smp.c +++ b/arch/mips/sgi-ip27/ip27-smp.c @@ -70,11 +70,13 @@ void cpu_node_probe(void) gda_t *gdap = GDA; nodes_clear(node_online_map); + nodes_clear(node_possible_map); for (i = 0; i < MAX_NUMNODES; i++) { nasid_t nasid = gdap->g_nasidtable[i]; if (nasid == INVALID_NASID) break; node_set_online(nasid); + node_set(nasid, node_possible_map); highest = node_scan_cpus(nasid, highest); } From patchwork Thu Aug 1 06:08:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749633 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 8B8F4C3DA4A for ; Thu, 1 Aug 2024 06:09:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DBA46B0093; Thu, 1 Aug 2024 02:09:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B1F86B0095; Thu, 1 Aug 2024 02:09:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17A5D6B0096; Thu, 1 Aug 2024 02:09:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id ECA176B0093 for ; Thu, 1 Aug 2024 02:09:39 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id B2E0AA086E for ; Thu, 1 Aug 2024 06:09:39 +0000 (UTC) X-FDA: 82402650078.14.175E237 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 85E4E1C002D for ; Thu, 1 Aug 2024 06:09:37 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Cr1CiLPN; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492515; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HoCKeIzmAcywFsgpFMMqCqoLsKNItI9k7YH0FvDgTJg=; b=7Mh3P2F3juMuWskV1V9RAlB/No0X/y5Rmj/6PPwAQRChoIBaNWXgLhiB1WbGwoSHUzjkxU XykqT/HGeD4NiTDVjm1PmcxSdgxFQqQ4Lg2K/Mx1CFmT9Rv64/l4Lb3vhtYT2rxzPpwGRh EIQXcwJw7yPIkmaCeTKLCIlyMWcA+HM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492515; a=rsa-sha256; cv=none; b=IDpSE7wdYKkxEmFeGEGZkQP5W247XYhq8DouERHtXN9VaYqMm6E2w+DcXN4OAbpPbnpOpD kicKbt2V+NjzCJt+OF7D0+1Lqu+RdW6RzD4/iQBdkO3eNdoJqBbRGIBNd191K7DaL8q51o jTYSjiqKO65cKLPPGjZzGjthUTyFuTs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Cr1CiLPN; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E566ACE1872; Thu, 1 Aug 2024 06:09:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0025DC4AF09; Thu, 1 Aug 2024 06:09:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492574; bh=mmhHQYCETRJBHfScnhlLv4Zo+WisPGGfSJnH6vP+xjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cr1CiLPN8Njdras4Btqnv341rMINjlqlnS1idBt/fsGeA4aaKp/Ea7yaeCTLRW+OD SLPSIWQWQGJwKbXyYy0pIWVIzgViSpnkqTQGdGOGlErfpLRWbytg7pgdYGk+qx62Zh vYO75yHA7yY/Uy0nBoxrtxxpTUVILgIgN/WYcr56R6lmrJ6AHRlpmtU1yA6AtLKxrM ZMeWtHyXc0v0Y5TlxT1McUabePfZDEmVQfqH5OPEDQwG1SfJboJ8M8tXb85NcwNlTk yRFhOlgDBqiScu3LsYNIWwFXmfZDKp8obRgWw9/g6qXMgFBNCRXgedXGkmX7WEaQAO 2ahFkgooeohiw== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 04/26] MIPS: sgi-ip27: drop HAVE_ARCH_NODEDATA_EXTENSION Date: Thu, 1 Aug 2024 09:08:04 +0300 Message-ID: <20240801060826.559858-5-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 85E4E1C002D X-Stat-Signature: zm3ruqoohw6x8wbr5dnjtaaquuhjrp3g X-Rspam-User: X-HE-Tag: 1722492577-339730 X-HE-Meta: U2FsdGVkX18MJeZ4+g9G65LZd3dyjdjee9vK8hyfDTA9JBLRBQ5iy6GO+QkK0Au0pgGdzFfL/pHXZ7e12TJgIVVBgS4o/sDyrisBjUHAEYxblCu/y2NZO3/ed0WrMAAWiozxH1enK9/Dkx9v2tpY81dZLYPQ1HkPGH9asNv4xI2qEGyf6LU2kMDruGrb/NxioIaVxPKeGdxT2mtttG9I7BWzHaCb9i8NBh+ezuJJ/tobf3w7d+0qfJgQW6j8lLpRiCGFIdJCXo+9pNsIIQzbnhRaqrrYVSx9lCV8u8lRWbVoYSKLueujmojWHEod7aiK0tc7VxYSYKkCDz9WpkfMnqE762FcamIRXBIipWZjaUFo0NxdnsYKDmLI5sUzi9RYtmkleD/ApwV9gH0k375SjgBfDK+kIt0KEunA3w5vFlJlp1JPkWdJZnBRiC/3bkgB74vq3GgzzaULsyIa3HIctc21Ae/gYM3LWxAjjvJo5tpMbbHMOenjENLo450w7tWie0cSJcOy3bal+j8588qUKM0V8/RDgUDe7GuaO8ThB6pWnfQdtf2M+UDBezFClQDpBdXjoj5XpdvaAt3QAX+CyERZurpLJ5kJvObjG6VSb3v15MkG2GxnNL+Tz/GW1i4oyvooaggFOSc03vnQrXybjylTvR4dNpdFk9fSmSenf55rLSOlAreXi1ApnAOg6FaH+KiaP1N4HGVBQAut7aq3Ua4IW7PyD0h6sMvV4qArKnujtFY4MQQonVaYmo/Ok3k165dwUzQ1oWa/DnHdlJGT0PZXYkC2Ol4VSVOYr6nHFqj3vlxxZmZx83IKrEGQ4sAh9WNyLrkb3mvI636UL6ehrcGQYGBZ+X8deFQ6k7TKJ5ix3YbUaaqV05yuxjsdwH+AF5GCqxuu8oq/FjiUEhuGafBqG4/qXiYA+m/wTMBHRq0PYMGNyk1AzIIUb1ONNRDXt2qmTX9dBaGUrSK0+5M 6DpZ2KeI oov8UgAKswYpMTAYfN4KxYP4Z2L/0a9UqC2gNnu0LZFoq2B5OEUcjldd4MtRI6m7oysN6ZqH0wkzRXC15nVBXGk1Ubx5B/a6vYIClcqQFjzfSPhCo3kx/iRr0KPHMCmRsy8ilS1gVegAd2sjpBA/IvvyU2k/McT0l4nLLngZuok51HqmpS8dnXX+T1RPRE9uMixeB8HQE94iurKgVVsD3rCmb5RbV2pXJbArXUg+FqetSSCh8MLNLJhpuE0QzEvdswJ7Ea7kKNWngkxTxmTlIGWAO8Rf/CnZT5m04cFjfzEhTG2TEvAornvpVfOMOHvZ9mc3N 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: From: "Mike Rapoport (Microsoft)" Commit f8f9f21c7848 ("MIPS: Fix build error for loongson64 and sgi-ip27") added HAVE_ARCH_NODEDATA_EXTENSION to sgi-ip27 to silence a compilation error that happened because sgi-ip27 didn't define array of pg_data_t as node_data like most other architectures did. After addition of node_data array that matches other architectures and after ensuring that offline nodes do not appear on node_possible_map, it is safe to drop arch_alloc_nodedata() and HAVE_ARCH_NODEDATA_EXTENSION from sgi-ip27. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/mips/Kconfig | 1 - arch/mips/sgi-ip27/ip27-memory.c | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 60077e576935..ea5f3c3c31f6 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -735,7 +735,6 @@ config SGI_IP27 select WAR_R10000_LLSC select MIPS_L1_CACHE_SHIFT_7 select NUMA - select HAVE_ARCH_NODEDATA_EXTENSION help This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics workstations. To compile a Linux kernel that runs on these, say Y diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index c30ef6958b97..eb6d2fa41a8a 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c @@ -426,13 +426,3 @@ void __init mem_init(void) memblock_free_all(); setup_zero_pages(); /* This comes from node 0 */ } - -pg_data_t * __init arch_alloc_nodedata(int nid) -{ - return memblock_alloc(sizeof(pg_data_t), SMP_CACHE_BYTES); -} - -void arch_refresh_nodedata(int nid, pg_data_t *pgdat) -{ - __node_data[nid] = (struct node_data *)pgdat; -} From patchwork Thu Aug 1 06:08:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749634 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 39804C3DA64 for ; Thu, 1 Aug 2024 06:09:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDB916B0096; Thu, 1 Aug 2024 02:09:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8BD06B0098; Thu, 1 Aug 2024 02:09:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7ADA6B0099; Thu, 1 Aug 2024 02:09:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8A2E46B0096 for ; Thu, 1 Aug 2024 02:09:49 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0B9D41608E2 for ; Thu, 1 Aug 2024 06:09:49 +0000 (UTC) X-FDA: 82402650498.10.7E12C24 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id E14EB10001D for ; Thu, 1 Aug 2024 06:09:46 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fyJjwiWO; spf=pass (imf14.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492531; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IBy4/NLvmneL8TuA1RJhZHs8+disGE/q3myWSe7l0P4=; b=HIGqNSb/VwbAshvfwocNb+mlU7B/IFZQL+nCAp+6iBZXrWuJeGRvhU4oLm8NegKZipcKA6 ElMJLnftaS0CijYdrSrAzOqvXKByFOWBq+LLWf4AXED7fje5hCcUXvgx6/LnNaFr4yBoYS VLCG6Kh4NKMo2bw6Z4tMF3JBtC+oovw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492531; a=rsa-sha256; cv=none; b=BHX9YRd01/YWxQmVRAgo3H0GuqeVN2gd0LbJGJlvUkF/Zep5IE0J0j83KLXw7yuUnBWMcZ hJEzoNhnsfkq3lqyQPUDwK/FaK8zZi4Z+UZIHtjZ+ekT/jktTlKOcJWBO+ztzaUqkoKS+F dtP6hO2Z3IXK2S6O+Tzlmq4I6vxfH8g= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fyJjwiWO; spf=pass (imf14.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 237266263A; Thu, 1 Aug 2024 06:09:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 881CCC4AF0C; Thu, 1 Aug 2024 06:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492585; bh=jUiExhtxbXLJEeICWPE63efzW6eqLaOxDv+h7X1UR1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fyJjwiWO5WHG4X2BzzIkyEGTY5gXOCD+ocNhSqlvP1OilB9J7rnYOnJABy+hGNW7D xyTV54Pg3gqNh0EPbnqoG/ks9lFNNaRt68ghnwEBkGMQaZxTf+nA+LyP19RicBy5Mn oBAhzFwgqXTg+F2KNHfJxuZAc+N3bPm43YahnhzEpn1k2PvuuM8oXAE1AEsUYxJerR tX/VcdeduKO5ZFtg7MixgD6k3bqZICLB50wXo+SmGeSCjFOLiA5DXhtHAdrjSd6Fih OPSoIR83ckKg/rW0fTB91OmvxgfNNKKtMbwyRz9u7AFU5KUSVbJZsnfwxQI4xSQrNV +9nKM8amxI9NA== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 05/26] MIPS: loongson64: rename __node_data to node_data Date: Thu, 1 Aug 2024 09:08:05 +0300 Message-ID: <20240801060826.559858-6-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E14EB10001D X-Stat-Signature: xcc31ud6hzyfiq4ish9rp85eui9zcpbr X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722492586-370978 X-HE-Meta: U2FsdGVkX18Lmqj6sT7pTQqzsh6B0MsQHOKBuFYpFQ96O5dXN3kHRvOKXBNGuZtmJRmudldOdreBiqXbk4vHscR6faLpmnsdA5u7w7CPwQsmaD3DTf9eNE+L3Hjml+tjYDD3RA+gyTgaDUAW7ogSReCOp4Wc0OhX8NE2PBW7uWEhN7c0o069msQSlDi8NMSTGxBfonuAxARz+wAX99/2DPzgEMfjmI6GYZDgUg5LONH26hv7QK2Cj+BidRwqVQJq3lb0kYXdzhXrfCbI6ndeNh6NaIqvoTY5FD6CN5oUztHhfftuMJQ6lBebvwuZxZpxLcMC/OEdgvzd0tShRaV0TjNGqwJQRviox+PDtiyGgdg+u94VXqEthkUKhm2XwEtf/7ltQ2/G2uMpvzfKS8x+KCP04gc7rCmV+gP1YtX22v/Stva2nhgHIVsBtpg6AW80Nki8s3vDXIWBscn/5s7HWcDG3o9sPDwLU+fg3+FxjQt+o3Vhh0TBuJkpp5/LkViT6b+jyuF8N2pdoI4Dg5ILlxYqo7dCuahizFWcAINt9SYEBcM1K0wurwztMnijVpYGZEl+Rdzu9U3UPQqAHE5ZCBDI9Uqp+CkCS4zuELnsZApWiPCdi0c1h/hFT4nf0rpjcGLeg5P/fUzqBXJ33miFldqYphhYO/Sxvbc49YPC1nwnxpeqqVEtHoOIX+J4A8yx56931EbDSbrLnmuJ5+LJkBBzcJ6whAgQsEkBzvDSTJpSU9uVbhDaMejPEH0ZYgYdKLTyAGIzKDgrytx0SYAjqMixrro/hXdxs363ua+K/zIqAoGJ1XW+dIjhE6JN1sgU09E7UM8lWcJKcHkwqP39u+8BdTkoOEAfRV87/uaJ59xthsVRC68gnsBibvbmAx3fZPS+xa46eYXUX6bVhnI+CvauHuwOxZ1cgFG2ZlJQM8yRD9Fe+1CJ3FqTxuooH6SYoOK/WD3E+XqtEOhzfFX nrUX89oZ 0yYHKXbx+HMfqV/e1+bDzEopKjgwy8xHOC5hX1CSSydg1L96JSfKHZgpNplLhBbxoJOFwohP7KOkQKynT8GzHEyzD5Wcj7t0dDUcVa5xqYXdhEzxuDEkxYbjQYYQk4iVg0JkK8E2jCCVoS7GMZvNi7p+FneBJlig9+6lAdX5tgicznPD/K53oKF95U8gTDy50pfdsoaBK0kYxy7tXVYrJt558+fE5imzfHRuZzGWIhGhy9qopTQAVWcG8wYcfXRxwK69ttW0MUb83/I3wtimw7VHTLTWsat6zPffIfaQAPvAf9EbJNysPNq0VLuSxmjYrtu3IXVg+jj6ELhcGvrsyqi8CsDEeIafmuksyNgtTVuQ26SM0x2qyU6/pIprqXTC0TA1mpso/XXV/8ifI8ssKZXrG/jZ8M6LsbrIdfeQ0JTfeFsI8wa5oJTJD6Q== 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: From: "Mike Rapoport (Microsoft)" Make definition of node_data match other architectures. This will allow pulling declaration of node_data to the generic mm code in the following commit. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jiaxun Yang Reviewed-by: David Hildenbrand Reviewed-by: Jonathan Cameron --- arch/mips/include/asm/mach-loongson64/mmzone.h | 4 ++-- arch/mips/loongson64/numa.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/asm/mach-loongson64/mmzone.h b/arch/mips/include/asm/mach-loongson64/mmzone.h index a3d65d37b8b5..2effd5f8ed62 100644 --- a/arch/mips/include/asm/mach-loongson64/mmzone.h +++ b/arch/mips/include/asm/mach-loongson64/mmzone.h @@ -14,9 +14,9 @@ #define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT) #define nid_to_addrbase(nid) ((unsigned long)(nid) << NODE_ADDRSPACE_SHIFT) -extern struct pglist_data *__node_data[]; +extern struct pglist_data *node_data[]; -#define NODE_DATA(n) (__node_data[n]) +#define NODE_DATA(n) (node_data[n]) extern void __init prom_init_numa_memory(void); diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index 68dafd6d3e25..b50ce28d2741 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -29,8 +29,8 @@ unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; EXPORT_SYMBOL(__node_distances); -struct pglist_data *__node_data[MAX_NUMNODES]; -EXPORT_SYMBOL(__node_data); +struct pglist_data *node_data[MAX_NUMNODES]; +EXPORT_SYMBOL(node_data); cpumask_t __node_cpumask[MAX_NUMNODES]; EXPORT_SYMBOL(__node_cpumask); @@ -107,7 +107,7 @@ static void __init node_mem_init(unsigned int node) tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT); if (tnid != node) pr_info("NODE_DATA(%d) on node %d\n", node, tnid); - __node_data[node] = nd; + node_data[node] = nd; NODE_DATA(node)->node_start_pfn = start_pfn; NODE_DATA(node)->node_spanned_pages = end_pfn - start_pfn; @@ -206,5 +206,5 @@ pg_data_t * __init arch_alloc_nodedata(int nid) void arch_refresh_nodedata(int nid, pg_data_t *pgdat) { - __node_data[nid] = pgdat; + node_data[nid] = pgdat; } From patchwork Thu Aug 1 06:08:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749635 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 87245C3DA64 for ; Thu, 1 Aug 2024 06:10:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 091CE6B009B; Thu, 1 Aug 2024 02:10:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F35766B009C; Thu, 1 Aug 2024 02:10:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD6906B009D; Thu, 1 Aug 2024 02:10:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BD7AE6B009B for ; Thu, 1 Aug 2024 02:10:00 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 405F440919 for ; Thu, 1 Aug 2024 06:10:00 +0000 (UTC) X-FDA: 82402650960.12.CC0D13C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 8F0A7A001A for ; Thu, 1 Aug 2024 06:09:58 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jS8CwM2H; spf=pass (imf25.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492593; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9DrM5DUuGVujAWRmjGY06jnv+dUjbKD+GE6efAhbQHA=; b=sNvsdbej6THUrqcEwN0RGkbXm9ZEicawzGenBfkpaDUHaRB6ikfqV4yHHHXRc1cPEx14Fs 5DhuD/4Pqlbg5Sn2yTb0h2PW/L/3lpZ6lV8jarhTXCNOBXaZhf+fSj62tXEIOF3YLLn2cW jj6lj7G7+ThRROQxuD+NHfeL8jrwLwg= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jS8CwM2H; spf=pass (imf25.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492593; a=rsa-sha256; cv=none; b=RlU8eCeRMf52DtE6KtoRnQ/Jqr3wA4TtWR4RsSfCMmXxQfqo3GPndBAV23O8lV7rOYfXZc B0HxG03OEnyAsgkCQ1BPDuVX9hwfuuwze1L8C4dtgGEClsr8Sdt//iA8/ph/aycTaCaHxm E6gzT7AnuzqkvIhg1KItEDla7FwVgBk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A149B61B43; Thu, 1 Aug 2024 06:09:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55FA4C4AF0D; Thu, 1 Aug 2024 06:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492597; bh=r+zUcEDoxtqvT8BU/VmlycxtHktOTZUPU96MGvM/m8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jS8CwM2HVacHd88SFDPtwS0+oYW3iYC3FGtk8UqItF2w5da1ERg0blF0k9sJIq5gO j+49LhbnKA5MHqV4Fgt2ytbHPvmsT/0zZqHsz/HcWK7tqRzK7FnDQWR65QvIGxzpV6 IgOZkkRBg6DhUMfwbNJ/Kpf+yEo/Uq9WJtCbSDiQBMnlyq0A8Zzjp1qrR3NlDQfr++ AKmQzG7nVd2IbIbt/+lnbQ9V4sB35D21NuC4UdRz8suodH6nNMsYTL+jbG3gGXHsfj 1TulkgepHvXzaSOM7uuBbCwqnItrZwuJ2WR603WAEBN9R5dOB6tCA2yzZTE3wfWcrf jOWVtDodBbVmw== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 06/26] MIPS: loongson64: drop HAVE_ARCH_NODEDATA_EXTENSION Date: Thu, 1 Aug 2024 09:08:06 +0300 Message-ID: <20240801060826.559858-7-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: zqkcprfgmwssp1hxsz9w1w3kw3bpiy1q X-Rspamd-Queue-Id: 8F0A7A001A X-Rspamd-Server: rspam11 X-HE-Tag: 1722492598-286119 X-HE-Meta: U2FsdGVkX19WWU8c1vqvm5RpjfOEIOuRsrI25V+ic81brYGezaKQLp6uwiA9xN44/nINmYGDsvSItiHFdPh6UogsxL+joHGUMphtfnMwU0JBzX7j0HcbkJF3NzdT2rW+bUZsjH1SXaLYHh+qqEzI63Ka0Krrev7tkEPN+ac+fI+V4UFubUSz0k9NBtdKZIBq4Cb1FjcBriq0Tr9uJzvE9+6UdRpzPTqCFY9kN7lvtHZhh9/ukCQfDO71z1Jdrj/7wEU8ojEv0GIIsAqxdTGlRN2HjuT33qBrzpkwmCT1/R1eZfQ+PJVNWkA77Gd8Ckvxlcob9KPk/hB7hlmBh5m6G1ZS2KBEzAazPEU+E5qTv5+zInV4JQeL8hGcPXDhobhiXPaGVobPi3k7YieBcoaaohmJaZe82w7aYqFPoZUQl/Lyuu2222izyJYcjoWTpTiMZwEWAxThW2u/Px22mvpkhOB42ZhLa1cjmGCjX+WbTl/w1/S5ym5ZE66lwxHxT6zyO1uh13+iehflVQi+9FKrQwUoOfKiRTah9NNOFB9OTitD+uoteHq2k7/NKsot3N86QgDOerqlt/WMnDwNmjeWWN/AfaAWh9CAQI9FOJ/fz8zOF0ML0HvVPiP7nKM+RkKfyKvnD6Wrgow3oIaTPYi4T7nPfLpV0MzVGwdZaYBBG+0nobjc+WHnkrwlmGdgdHTofdKk7joYmlhM4XfKfWLek8r8p3n6KQp5q+BRX+r3g+zoZeqL1kwBu2dpx5SMkYSj6pS/5uhZYgw/FX3gQYIfkIBzzugLpD3A30QGo/UYw0mvQly3rURdGxeInNlGeLbuBzON1hOHZkz9FNEfBdZHcRlwoblo5koRvroHJza/rmW+1HPPuVBcd1I8AnEZBsHDaG0w6s0urtDRzTHurxq0ca/Jalc5YvWai4dStNauSQLJDBJtRxnsxdpzADYHCeTC4OsfLSBeUhkq5pZj2nh mv8ZxxKD DlHFiiOWwG/vPNheEqHUJwL/go8cuqkAwuYLADvzOcBgV5UCYs2iX4mB4AD2WmLq7ZDm0i0QCozVbU7aSnTiM5BIuAl2uoVt3sGNi1VQPMcsGt/WplEt4uHJ7uEYzDEqtFbFEoULfaIojrj/8U0HPZwzdnIiFJWLHDLRMTIleoUbz1z1bG2GaI0ZZ/KH73YAMpkvLwZU436YH3bx7Kt3A3SDkYdVi4fJLTIkmtrokM5B0/WJKfd2+kyyo/PtTrS9GuzSciKNfXRt0nc0j2V+ICB50GT8w+GS00ceoYVTJCicWL7PEgkEXVZyVzE0SBTWTknvz3qhwR1fvRMM= 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: From: "Mike Rapoport (Microsoft)" Commit f8f9f21c7848 ("MIPS: Fix build error for loongson64 and sgi-ip27") added HAVE_ARCH_NODEDATA_EXTENSION to loongson64 to silence a compilation error that happened because loongson64 didn't define array of pg_data_t as node_data like most other architectures did. After rename of __node_data to node_data arch_alloc_nodedata() and HAVE_ARCH_NODEDATA_EXTENSION can be dropped from loongson64. Since it was the only user of HAVE_ARCH_NODEDATA_EXTENSION config option also remove this option from arch/mips/Kconfig. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/mips/Kconfig | 4 ---- arch/mips/loongson64/numa.c | 10 ---------- 2 files changed, 14 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index ea5f3c3c31f6..43da6d596e2b 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -502,7 +502,6 @@ config MACH_LOONGSON64 select USE_OF select BUILTIN_DTB select PCI_HOST_GENERIC - select HAVE_ARCH_NODEDATA_EXTENSION if NUMA help This enables the support of Loongson-2/3 family of machines. @@ -2612,9 +2611,6 @@ config NUMA config SYS_SUPPORTS_NUMA bool -config HAVE_ARCH_NODEDATA_EXTENSION - bool - config RELOCATABLE bool "Relocatable kernel" depends on SYS_SUPPORTS_RELOCATABLE diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index b50ce28d2741..64fcfaa885b6 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -198,13 +198,3 @@ void __init prom_init_numa_memory(void) pr_info("CP0_PageGrain: CP0 5.1 (0x%x)\n", read_c0_pagegrain()); prom_meminit(); } - -pg_data_t * __init arch_alloc_nodedata(int nid) -{ - return memblock_alloc(sizeof(pg_data_t), SMP_CACHE_BYTES); -} - -void arch_refresh_nodedata(int nid, pg_data_t *pgdat) -{ - node_data[nid] = pgdat; -} From patchwork Thu Aug 1 06:08:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749636 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 F1C55C3DA64 for ; Thu, 1 Aug 2024 06:10:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D22E6B009D; Thu, 1 Aug 2024 02:10:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 683286B009E; Thu, 1 Aug 2024 02:10:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5242A6B009F; Thu, 1 Aug 2024 02:10:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 326B16B009D for ; Thu, 1 Aug 2024 02:10:12 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AB8ACA62FF for ; Thu, 1 Aug 2024 06:10:11 +0000 (UTC) X-FDA: 82402651422.09.5680B33 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 0736F80018 for ; Thu, 1 Aug 2024 06:10:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MFAG9F3f; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492547; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MIAL4gYUA8ep2WaW6qhFjT4s3xw+5vZW8BEUKSZrYK8=; b=lAVaeKfe0pWZNdizDba9JjTkDB2EdAQd5mEYW/IXxoADKFZfrer1bC5gRscxsNK8J8641W 2dKoTPnz+g3Vawzo3/l2gKOt6UBFe+C54dqb9hbPZc+tcj4NwdmNp6WQdCbxLXfLUDWHwK wnc2vaklxZEapvBgCbM6ESlAx33nlbA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492547; a=rsa-sha256; cv=none; b=GaxrV0L+2zUeDvD86xvkBUezoALjusiJshoEO8RUGOYXSP2eN/0oPiJkHtLTPeYmTpkbs2 KyS2MeXhWoCm3n1FZXGR2zkcD53l8VFVHSo3FEI8WA+nBWcUf4aSD0eAk8EamxEuI+o5UV GLbYyuQDH2sG/4gQubeo++QH/tactPc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MFAG9F3f; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf02.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 39F6E62502; Thu, 1 Aug 2024 06:10:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAB07C4AF11; Thu, 1 Aug 2024 06:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492608; bh=+b1cOkZzBkabktp5Vtr0BxOA2OwItOU3swcoPl+STrQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MFAG9F3fUnIEGckALXUsgPgJNDOGxKIktrZWhCPRrwe1l/PA4t95t0glD4Bw67Wwj 56IqcN7KC3zzeCXB3c8CrI5bl5iDUVSKZrsLqr43Ecm7gRjqRFCAR9bIDA59V6hoqm Xly5FwnM79IMgwgHQI+TPINCsSXXhleTBgnO0f80JBYd2cMfyLGz32VP93mcQrjqJA Ne73hzkU/Y8f6hDf1oBGnhpCmZoHktUlCUaZ+WLWYPT98uUNEZFkSQTU50QEbSbj1J 0OJkDgvPRbuCaVMusjazFYkXiGRxn2uK7gxV2/FyMUUmWwS+NFGAia450ymPPe8PXm gEBtBz7iXoOvw== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 07/26] mm: drop CONFIG_HAVE_ARCH_NODEDATA_EXTENSION Date: Thu, 1 Aug 2024 09:08:07 +0300 Message-ID: <20240801060826.559858-8-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0736F80018 X-Stat-Signature: f5cj3dbu8jijtc36hweub8is1t9kk3qi X-Rspam-User: X-HE-Tag: 1722492609-663148 X-HE-Meta: U2FsdGVkX18BTcXOos0xX3d8XFfVi/pppXNaZmBd8E4Bt925Ut5xbZT3ml4EFZMrHdBD60QNHLyVooBSR4MmUtyXi7Sdfr4NRCinhRJ4WEd2574QA5VhpRmRtT301G6k+OOz9yuwTCgUbuWRveSSRWPl1D63DijpWjKiZYhFZ7cVC6Vw/s7vVCIVaWFMHIoVKEePa1u6Zjai4JQz6b/sMymIpyKtnGoqSaiDC0gaIrvkqD1OzUgtZqleyhI+tyNcUtNlhtOttbXFUw7n7dvZSyng99PlB6ZQfOor1icpyUAVX4jRruc1KnDTW+GvGn+b7m5YjVlfkVXjI0gr1xIoG7kREKnS4duyniOciYuBMKVWYOrcpNF/LprqOYCo4m+TIR6uM/iK686Njh3XgMNbZxQdKQ1ZfjwFuGealSqg7ruhm8sSgqzPvM5O0zIYT0W3jDHwJfq2kbOKc+ztS5uWldQAk7C/QtBWF5Y8P7+V+Qb3P/1PApDAOY6vEEACHkBDadejqWsPyayigoLAQP+6N5iCLTrn5/vFk7X+U9iX+BdR5qOnFZBZAIELpWB8p+Z4o/3X0h3UBI6t6ClokbkPst6e2MTKxKgf1jymDaR+d6D3uUXnvBZsA0TLEKgk3IQJTLgN9Zk5PTRKTFJA0za6ETVF4eh+jsGiKvo37S5g+v8CAjnUtYArL96tV+jMp8aG8ecRoGMAn4udBSW0vWYb796W1fTrpdwVPZ20v1qrZOcZtui6qceV/fjUuPyhk2IXq/V7fESHbZvi9qgEcMnZcdZUo7w+vvI9MzaALY1fxiT5DirKtg7nAEhX2Db8PBXdkjzFDoIGa7kOGQ54ySDSTdQ7u5INfY7RFYcIgBsPToUdaA7llXy08wqv7bXfg3sRSSAxStuX6aJJMUfFesVr5TTAoS4SoIsFJa5bsOvtSzjmjkipSXFBsKAnjZw7kqGz9G+chxv1zA03mw8Y6na bYBLM0zF RGm3ttcwwl6jzXRMzTpGYPcptJ0ONr6ZHua+8EQ8t4S2NoO8hhEaOM7rCArPRllT9rqnfaRVsOhf21uw70J8FMjOAjJ5FaXIRbfbWbDlB/S8vBaAOjaXZj9No5DEiPHFlJ05aRCc6D0Xs1wbY6/G/7DlOwkIt8RCqTIIhKsATLBNfD12Ohv1LrUANYTp4fg+6hedKDRD8Ik8ZeevO9IIMmKdTSQmmMmt9uvIFUc+gnd7v8bkq8AICaamnRUNGgbv96LzRewegGk9kJxNKSG9jF3VO5nzb6p+AZwXQgMOtXzOC/5e7tddjPn+Ky9DuGM2mZmY3ycUN0CyAcpubh/3OUu1W5Lt6enMe46cQ 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: From: "Mike Rapoport (Microsoft)" There are no users of HAVE_ARCH_NODEDATA_EXTENSION left, so arch_alloc_nodedata() and arch_refresh_nodedata() are not needed anymore. Replace the call to arch_alloc_nodedata() in free_area_init() with memblock_alloc(), remove arch_refresh_nodedata() and cleanup include/linux/memory_hotplug.h from the associated ifdefery. Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 --- include/linux/memory_hotplug.h | 48 ---------------------------------- mm/mm_init.c | 3 +-- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index ebe876930e78..b27ddce5d324 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -16,54 +16,6 @@ struct resource; struct vmem_altmap; struct dev_pagemap; -#ifdef CONFIG_HAVE_ARCH_NODEDATA_EXTENSION -/* - * For supporting node-hotadd, we have to allocate a new pgdat. - * - * If an arch has generic style NODE_DATA(), - * node_data[nid] = kzalloc() works well. But it depends on the architecture. - * - * In general, generic_alloc_nodedata() is used. - * - */ -extern pg_data_t *arch_alloc_nodedata(int nid); -extern void arch_refresh_nodedata(int nid, pg_data_t *pgdat); - -#else /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */ - -#define arch_alloc_nodedata(nid) generic_alloc_nodedata(nid) - -#ifdef CONFIG_NUMA -/* - * XXX: node aware allocation can't work well to get new node's memory at this time. - * Because, pgdat for the new node is not allocated/initialized yet itself. - * To use new node's memory, more consideration will be necessary. - */ -#define generic_alloc_nodedata(nid) \ -({ \ - memblock_alloc(sizeof(*pgdat), SMP_CACHE_BYTES); \ -}) - -extern pg_data_t *node_data[]; -static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat) -{ - node_data[nid] = pgdat; -} - -#else /* !CONFIG_NUMA */ - -/* never called */ -static inline pg_data_t *generic_alloc_nodedata(int nid) -{ - BUG(); - return NULL; -} -static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat) -{ -} -#endif /* CONFIG_NUMA */ -#endif /* CONFIG_HAVE_ARCH_NODEDATA_EXTENSION */ - #ifdef CONFIG_MEMORY_HOTPLUG struct page *pfn_to_online_page(unsigned long pfn); diff --git a/mm/mm_init.c b/mm/mm_init.c index 75c3bd42799b..bcc2f2dd8021 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1838,11 +1838,10 @@ void __init free_area_init(unsigned long *max_zone_pfn) if (!node_online(nid)) { /* Allocator not initialized yet */ - pgdat = arch_alloc_nodedata(nid); + pgdat = memblock_alloc(sizeof(*pgdat), SMP_CACHE_BYTES); if (!pgdat) panic("Cannot allocate %zuB for node %d.\n", sizeof(*pgdat), nid); - arch_refresh_nodedata(nid, pgdat); } pgdat = NODE_DATA(nid); From patchwork Thu Aug 1 06:08:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749637 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 6E27EC3DA64 for ; Thu, 1 Aug 2024 06:10:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 091B46B009F; Thu, 1 Aug 2024 02:10:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 041B16B00A0; Thu, 1 Aug 2024 02:10:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFDE56B00A1; Thu, 1 Aug 2024 02:10:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BDABF6B009F for ; Thu, 1 Aug 2024 02:10:23 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7E79AA6056 for ; Thu, 1 Aug 2024 06:10:23 +0000 (UTC) X-FDA: 82402651926.11.F9056F3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id C16914001A for ; Thu, 1 Aug 2024 06:10:21 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bF6oHQum; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492565; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dMqfhcT8k9AKgjmf4IcLf7S5cAm3Z7O167wi/UoLvQ4=; b=Z6MAvkdf/sQejJBeZBw9IWjZBGPNkaOTAwkrl/ePtxGtyON9qULshK2OxKwyGkcEJyBect 7uQFkjKgaLJtIZtUN+efjY2OiN7snrjkTW13EpfoCZYlYAX9jmGJbc+qsIyU/d/oxZ+DRN ia7CYxuktIXTmaR6GZPJ/mslASRTT4o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492565; a=rsa-sha256; cv=none; b=8oeTlVZEXiELizJPPUz+C1/KuVjC571LrjL/sQR4kYIHbGaSyYPhbx0tzknCl5nzbdXK4X RfAIF3LmQBM0Et6KaPNoCItzj5Sq0h/apuDy55PdK5eAy9lRhSvxCXNa6DqyuPwWXmNyLn oZfAHMEl5+JBAFm96kvYnrijicIu0pk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bF6oHQum; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0892361B43; Thu, 1 Aug 2024 06:10:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 726F5C4AF12; Thu, 1 Aug 2024 06:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492620; bh=i9FwVB/OIJC4OjBwkifOabqxvP5ZkVav2JNrAfxyq04=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bF6oHQumlPHwmJ5fg4cQO32STg5rLkIAZvDB30W1mfB/NsF3mTyE9AO6KH+CpI9hr Xuu6xPnCXZ0nqNmWU9Etb0M4ki9kun9vSamjlxFSnt2n+ET9wemNEEhL82GmJdhB0J BxFTw/khrCqUqhOynUwtEB3h4IQuVOn8p6BvSgeLhjbVbBrnpMB/ypSrJPH8Q9YrTp DRWA5vRj75HWnnQC/+pwOEagPWmsHZ6fU4og4/kvJOS2MqpYR7b/V6XKehL1ZgSkDU 74P0/IxiNCaupflihtRptvk7GPkc2TMzoGqmIVU1NbpGE4eDttBJky2vc49JOMEkd7 g1Jg4xHFBz2kw== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 08/26] arch, mm: move definition of node_data to generic code Date: Thu, 1 Aug 2024 09:08:08 +0300 Message-ID: <20240801060826.559858-9-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C16914001A X-Stat-Signature: 54hykr8zd3b7a9cbnd4s5q7bcrpu99qp X-HE-Tag: 1722492621-661721 X-HE-Meta: U2FsdGVkX1/1MRtDpKIM8AM1NRDuygUCG6bxzIe2JMbDAQpr6zk2Vjs47/TARCpqjgZ18Bbi5XbUuWC/cOOaM3TqCRVuaJJRzcXaJxK48i290gQdvgMUFFW2Q/kFeekT3RfK/jX1AHKo9QSCFF8gYamuaHAv3ou6gfvVCOtKxVMxRxtOI6hyLsvokDgnEeDF2vYVyqvhoTWrc1qpoi1xeAEOBUten+PYKaaK7gEb4nZDgvWnyl1GtcOztYRs2ttKmGi/mVtwc9bbxyQrgHeMW36pQvk8gfmmqGD1pGqV5sAOB6mjJZAGbwNOuayDiv+f45r8WglpdE2L1Ea+FpdDAeWwKsNCSX6I5Rg2l4zGCqRLcQKXXjgPgsGPrSV4GnYA5bjZUikmpHjDUGBO1RgTbicav8yiKR3fG/oJftjYgObPBdX4MLIFkBikMGukSYvp8ZAWilUA7VkdwyViz00Dh+jnby2Vkx0gK0ihLduRiH/Hjq7nhkaOJqSUWBF1OFG0y6dcimW1PLn3X55xYOlb2gd3G12IKvC+9IfGxMwHgnUgnDqg5Hxn6ojNFh9kCsvG1cmOabgLuZd2MYj5W3/csZRkQWRjp2zq8/3QACM1/OcHM4a9slbeUMSSTrtWbCA2lxE+l4nGr6FvBEn1FkJ8aHIfey8mjCcleRNjoSFMt9DhL8PZ5doQltP734v0Knte8SMIxWktHuB0U8UW5+NT4PTYDXU+9Ftz+ZlgV5958itgSsDvNth0ebF12Ae73yHWT/17kmfpyjjLeL79NoPnOiNEUmirGFOrSrVmzDdKanUI8r5GaUilNwyWcvQlnK0xi4wCOzVo8qbG/SYdWx6HH+fQKZs6u0mfTyJ5+LuU1LZrntfIXGY0RUQ9A/P18xzuDsahgpK1DoVAlRocNoqUDb6CHwPLjA/7934h3AeA3V2nWKhKvU/WX1pnAcwCpEWNU5mUrcBRoTw5dFPhcA2 V1UMu6h6 bPCLBNhChy47RwBJmFjH9Dt0TwXhwPVPYB23+S4e+fTPwQ3PYnt5p2nMVoNjnw3l8aBtE+EIIY3Hi7gcgVNrHhLVrsZS8pNDfDPiWZn2I4vhMEV+EKA81yRAyIrbEUPISW8nvKPSZoWKOTkLtAPWKy6rM6xjTjeDOtVYHiwvGAhquz6ipkhAc10JrKpNR4NvNZuFZ+PnmHC3T+ONt0evQ/N7I7li32gtVXg/Y8WqlHi0vI9JtoDF8JRNJ90Xo0G21+BSUzpuY8H20kUoTkP28VP9DxFkpIMMIk2hHtqpqxXK3XcFZ+S/MbIKl4QECgivjQyWSlSuDQSJiyAhWKcHSD4sjyDy8e1LOxXKDFqtTJAwK1hPor+FWYq1sy1BUPXIypeNlN1Hoy/V7Ylpcp3wyOSepHAHcwDo0MPUeffoYqC85A1GjBj4E6Hne2u9vN/XJis2IQmoT94OEjuDnPzhF5ijZD9NVhfcXss3M 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: From: "Mike Rapoport (Microsoft)" Every architecture that supports NUMA defines node_data in the same way: struct pglist_data *node_data[MAX_NUMNODES]; No reason to keep multiple copies of this definition and its forward declarations, especially when such forward declaration is the only thing in include/asm/mmzone.h for many architectures. Add definition and declaration of node_data to generic code and drop architecture-specific versions. Signed-off-by: Mike Rapoport (Microsoft) Acked-by: David Hildenbrand Reviewed-by: Jonathan Cameron Acked-by: Davidlohr Bueso Tested-by: Zi Yan # for x86_64 and arm64 --- arch/arm64/include/asm/Kbuild | 1 + arch/arm64/include/asm/mmzone.h | 13 ------------- arch/arm64/include/asm/topology.h | 1 + arch/loongarch/include/asm/Kbuild | 1 + arch/loongarch/include/asm/mmzone.h | 16 ---------------- arch/loongarch/include/asm/topology.h | 1 + arch/loongarch/kernel/numa.c | 3 --- arch/mips/include/asm/mach-ip27/mmzone.h | 4 ---- arch/mips/include/asm/mach-loongson64/mmzone.h | 4 ---- arch/mips/loongson64/numa.c | 2 -- arch/mips/sgi-ip27/ip27-memory.c | 3 --- arch/powerpc/include/asm/mmzone.h | 6 ------ arch/powerpc/mm/numa.c | 2 -- arch/riscv/include/asm/Kbuild | 1 + arch/riscv/include/asm/mmzone.h | 13 ------------- arch/riscv/include/asm/topology.h | 4 ++++ arch/s390/include/asm/Kbuild | 1 + arch/s390/include/asm/mmzone.h | 17 ----------------- arch/s390/kernel/numa.c | 3 --- arch/sh/include/asm/mmzone.h | 3 --- arch/sh/mm/numa.c | 3 --- arch/sparc/include/asm/mmzone.h | 4 ---- arch/sparc/mm/init_64.c | 2 -- arch/x86/include/asm/Kbuild | 1 + arch/x86/include/asm/mmzone.h | 6 ------ arch/x86/include/asm/mmzone_32.h | 17 ----------------- arch/x86/include/asm/mmzone_64.h | 18 ------------------ arch/x86/mm/numa.c | 3 --- drivers/base/arch_numa.c | 2 -- include/asm-generic/mmzone.h | 5 +++++ include/linux/numa.h | 3 +++ mm/numa.c | 3 +++ 32 files changed, 22 insertions(+), 144 deletions(-) delete mode 100644 arch/arm64/include/asm/mmzone.h delete mode 100644 arch/loongarch/include/asm/mmzone.h delete mode 100644 arch/riscv/include/asm/mmzone.h delete mode 100644 arch/s390/include/asm/mmzone.h delete mode 100644 arch/x86/include/asm/mmzone.h delete mode 100644 arch/x86/include/asm/mmzone_32.h delete mode 100644 arch/x86/include/asm/mmzone_64.h create mode 100644 include/asm-generic/mmzone.h diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild index 7d7d97ad3cd5..4e350df9a02d 100644 --- a/arch/arm64/include/asm/Kbuild +++ b/arch/arm64/include/asm/Kbuild @@ -9,6 +9,7 @@ syscall-y += unistd_compat_32.h generic-y += early_ioremap.h generic-y += mcs_spinlock.h +generic-y += mmzone.h generic-y += qrwlock.h generic-y += qspinlock.h generic-y += parport.h diff --git a/arch/arm64/include/asm/mmzone.h b/arch/arm64/include/asm/mmzone.h deleted file mode 100644 index fa17e01d9ab2..000000000000 --- a/arch/arm64/include/asm/mmzone.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_MMZONE_H -#define __ASM_MMZONE_H - -#ifdef CONFIG_NUMA - -#include - -extern struct pglist_data *node_data[]; -#define NODE_DATA(nid) (node_data[(nid)]) - -#endif /* CONFIG_NUMA */ -#endif /* __ASM_MMZONE_H */ diff --git a/arch/arm64/include/asm/topology.h b/arch/arm64/include/asm/topology.h index 0f6ef432fb84..5fc3af9f8f29 100644 --- a/arch/arm64/include/asm/topology.h +++ b/arch/arm64/include/asm/topology.h @@ -5,6 +5,7 @@ #include #ifdef CONFIG_NUMA +#include struct pci_bus; int pcibus_to_node(struct pci_bus *bus); diff --git a/arch/loongarch/include/asm/Kbuild b/arch/loongarch/include/asm/Kbuild index 2bb3676429c0..8fa22cc52774 100644 --- a/arch/loongarch/include/asm/Kbuild +++ b/arch/loongarch/include/asm/Kbuild @@ -9,5 +9,6 @@ generic-y += qrwlock.h generic-y += qspinlock.h generic-y += user.h generic-y += ioctl.h +generic-y += mmzone.h generic-y += statfs.h generic-y += param.h diff --git a/arch/loongarch/include/asm/mmzone.h b/arch/loongarch/include/asm/mmzone.h deleted file mode 100644 index 2b9a90727e19..000000000000 --- a/arch/loongarch/include/asm/mmzone.h +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Author: Huacai Chen (chenhuacai@loongson.cn) - * Copyright (C) 2020-2022 Loongson Technology Corporation Limited - */ -#ifndef _ASM_MMZONE_H_ -#define _ASM_MMZONE_H_ - -#include -#include - -extern struct pglist_data *node_data[]; - -#define NODE_DATA(nid) (node_data[(nid)]) - -#endif /* _ASM_MMZONE_H_ */ diff --git a/arch/loongarch/include/asm/topology.h b/arch/loongarch/include/asm/topology.h index 66128dec0bf6..50273c9187d0 100644 --- a/arch/loongarch/include/asm/topology.h +++ b/arch/loongarch/include/asm/topology.h @@ -8,6 +8,7 @@ #include #ifdef CONFIG_NUMA +#include extern cpumask_t cpus_on_node[]; diff --git a/arch/loongarch/kernel/numa.c b/arch/loongarch/kernel/numa.c index 8fe21f868f72..acada671e020 100644 --- a/arch/loongarch/kernel/numa.c +++ b/arch/loongarch/kernel/numa.c @@ -27,10 +27,7 @@ #include int numa_off; -struct pglist_data *node_data[MAX_NUMNODES]; unsigned char node_distances[MAX_NUMNODES][MAX_NUMNODES]; - -EXPORT_SYMBOL(node_data); EXPORT_SYMBOL(node_distances); static struct numa_meminfo numa_meminfo; diff --git a/arch/mips/include/asm/mach-ip27/mmzone.h b/arch/mips/include/asm/mach-ip27/mmzone.h index 629c3f290203..56959eb9cb26 100644 --- a/arch/mips/include/asm/mach-ip27/mmzone.h +++ b/arch/mips/include/asm/mach-ip27/mmzone.h @@ -24,8 +24,4 @@ extern struct node_data *__node_data[]; #define hub_data(n) (&__node_data[(n)]->hub) -extern struct pglist_data *node_data[]; - -#define NODE_DATA(nid) (node_data[nid]) - #endif /* _ASM_MACH_MMZONE_H */ diff --git a/arch/mips/include/asm/mach-loongson64/mmzone.h b/arch/mips/include/asm/mach-loongson64/mmzone.h index 2effd5f8ed62..8fb70fd3c9c4 100644 --- a/arch/mips/include/asm/mach-loongson64/mmzone.h +++ b/arch/mips/include/asm/mach-loongson64/mmzone.h @@ -14,10 +14,6 @@ #define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT) #define nid_to_addrbase(nid) ((unsigned long)(nid) << NODE_ADDRSPACE_SHIFT) -extern struct pglist_data *node_data[]; - -#define NODE_DATA(n) (node_data[n]) - extern void __init prom_init_numa_memory(void); #endif /* _ASM_MACH_MMZONE_H */ diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index 64fcfaa885b6..d56238745744 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -29,8 +29,6 @@ unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; EXPORT_SYMBOL(__node_distances); -struct pglist_data *node_data[MAX_NUMNODES]; -EXPORT_SYMBOL(node_data); cpumask_t __node_cpumask[MAX_NUMNODES]; EXPORT_SYMBOL(__node_cpumask); diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c index eb6d2fa41a8a..1963313f55d8 100644 --- a/arch/mips/sgi-ip27/ip27-memory.c +++ b/arch/mips/sgi-ip27/ip27-memory.c @@ -34,9 +34,6 @@ #define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) #define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) -struct pglist_data *node_data[MAX_NUMNODES]; -EXPORT_SYMBOL(node_data); - struct node_data *__node_data[MAX_NUMNODES]; EXPORT_SYMBOL(__node_data); diff --git a/arch/powerpc/include/asm/mmzone.h b/arch/powerpc/include/asm/mmzone.h index da827d2d0866..d99863cd6cde 100644 --- a/arch/powerpc/include/asm/mmzone.h +++ b/arch/powerpc/include/asm/mmzone.h @@ -20,12 +20,6 @@ #ifdef CONFIG_NUMA -extern struct pglist_data *node_data[]; -/* - * Return a pointer to the node data for node n. - */ -#define NODE_DATA(nid) (node_data[nid]) - /* * Following are specific to this numa platform. */ diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index aa89899f0c1a..0744a9a2944b 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -43,11 +43,9 @@ static char *cmdline __initdata; int numa_cpu_lookup_table[NR_CPUS]; cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; -struct pglist_data *node_data[MAX_NUMNODES]; EXPORT_SYMBOL(numa_cpu_lookup_table); EXPORT_SYMBOL(node_to_cpumask_map); -EXPORT_SYMBOL(node_data); static int primary_domain_index; static int n_mem_addr_cells, n_mem_size_cells; diff --git a/arch/riscv/include/asm/Kbuild b/arch/riscv/include/asm/Kbuild index 5c589770f2a8..1461af12da6e 100644 --- a/arch/riscv/include/asm/Kbuild +++ b/arch/riscv/include/asm/Kbuild @@ -5,6 +5,7 @@ syscall-y += syscall_table_64.h generic-y += early_ioremap.h generic-y += flat.h generic-y += kvm_para.h +generic-y += mmzone.h generic-y += parport.h generic-y += spinlock.h generic-y += spinlock_types.h diff --git a/arch/riscv/include/asm/mmzone.h b/arch/riscv/include/asm/mmzone.h deleted file mode 100644 index fa17e01d9ab2..000000000000 --- a/arch/riscv/include/asm/mmzone.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __ASM_MMZONE_H -#define __ASM_MMZONE_H - -#ifdef CONFIG_NUMA - -#include - -extern struct pglist_data *node_data[]; -#define NODE_DATA(nid) (node_data[(nid)]) - -#endif /* CONFIG_NUMA */ -#endif /* __ASM_MMZONE_H */ diff --git a/arch/riscv/include/asm/topology.h b/arch/riscv/include/asm/topology.h index 61183688bdd5..fe1a8bf6902d 100644 --- a/arch/riscv/include/asm/topology.h +++ b/arch/riscv/include/asm/topology.h @@ -4,6 +4,10 @@ #include +#ifdef CONFIG_NUMA +#include +#endif + /* Replace task scheduler's default frequency-invariant accounting */ #define arch_scale_freq_tick topology_scale_freq_tick #define arch_set_freq_scale topology_set_freq_scale diff --git a/arch/s390/include/asm/Kbuild b/arch/s390/include/asm/Kbuild index 4b904110d27c..297bf7157968 100644 --- a/arch/s390/include/asm/Kbuild +++ b/arch/s390/include/asm/Kbuild @@ -7,3 +7,4 @@ generated-y += unistd_nr.h generic-y += asm-offsets.h generic-y += kvm_types.h generic-y += mcs_spinlock.h +generic-y += mmzone.h diff --git a/arch/s390/include/asm/mmzone.h b/arch/s390/include/asm/mmzone.h deleted file mode 100644 index 73e3e7c6976c..000000000000 --- a/arch/s390/include/asm/mmzone.h +++ /dev/null @@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * NUMA support for s390 - * - * Copyright IBM Corp. 2015 - */ - -#ifndef _ASM_S390_MMZONE_H -#define _ASM_S390_MMZONE_H - -#ifdef CONFIG_NUMA - -extern struct pglist_data *node_data[]; -#define NODE_DATA(nid) (node_data[nid]) - -#endif /* CONFIG_NUMA */ -#endif /* _ASM_S390_MMZONE_H */ diff --git a/arch/s390/kernel/numa.c b/arch/s390/kernel/numa.c index 23ab9f02f278..ddc1448ea2e1 100644 --- a/arch/s390/kernel/numa.c +++ b/arch/s390/kernel/numa.c @@ -14,9 +14,6 @@ #include #include -struct pglist_data *node_data[MAX_NUMNODES]; -EXPORT_SYMBOL(node_data); - void __init numa_setup(void) { int nid; diff --git a/arch/sh/include/asm/mmzone.h b/arch/sh/include/asm/mmzone.h index 7b8dead2723d..63f88b465e39 100644 --- a/arch/sh/include/asm/mmzone.h +++ b/arch/sh/include/asm/mmzone.h @@ -5,9 +5,6 @@ #ifdef CONFIG_NUMA #include -extern struct pglist_data *node_data[]; -#define NODE_DATA(nid) (node_data[nid]) - static inline int pfn_to_nid(unsigned long pfn) { int nid; diff --git a/arch/sh/mm/numa.c b/arch/sh/mm/numa.c index 50f0dc1744d0..9bc212b5e762 100644 --- a/arch/sh/mm/numa.c +++ b/arch/sh/mm/numa.c @@ -14,9 +14,6 @@ #include #include -struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; -EXPORT_SYMBOL_GPL(node_data); - /* * On SH machines the conventional approach is to stash system RAM * in node 0, and other memory blocks in to node 1 and up, ordered by diff --git a/arch/sparc/include/asm/mmzone.h b/arch/sparc/include/asm/mmzone.h index a236d8aa893a..74eb2c71d077 100644 --- a/arch/sparc/include/asm/mmzone.h +++ b/arch/sparc/include/asm/mmzone.h @@ -6,10 +6,6 @@ #include -extern struct pglist_data *node_data[]; - -#define NODE_DATA(nid) (node_data[nid]) - extern int numa_cpu_lookup_table[]; extern cpumask_t numa_cpumask_lookup_table[]; diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 53d7cb5bbffe..c6c7f43cb1e8 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -1115,11 +1115,9 @@ static void init_node_masks_nonnuma(void) } #ifdef CONFIG_NUMA -struct pglist_data *node_data[MAX_NUMNODES]; EXPORT_SYMBOL(numa_cpu_lookup_table); EXPORT_SYMBOL(numa_cpumask_lookup_table); -EXPORT_SYMBOL(node_data); static int scan_pio_for_cfg_handle(struct mdesc_handle *md, u64 pio, u32 cfg_handle) diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild index a192bdea69e2..6c23d1661b17 100644 --- a/arch/x86/include/asm/Kbuild +++ b/arch/x86/include/asm/Kbuild @@ -11,3 +11,4 @@ generated-y += xen-hypercalls.h generic-y += early_ioremap.h generic-y += mcs_spinlock.h +generic-y += mmzone.h diff --git a/arch/x86/include/asm/mmzone.h b/arch/x86/include/asm/mmzone.h deleted file mode 100644 index c41b41edd691..000000000000 --- a/arch/x86/include/asm/mmzone.h +++ /dev/null @@ -1,6 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifdef CONFIG_X86_32 -# include -#else -# include -#endif diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h deleted file mode 100644 index 2d4515e8b7df..000000000000 --- a/arch/x86/include/asm/mmzone_32.h +++ /dev/null @@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Written by Pat Gaughen (gone@us.ibm.com) Mar 2002 - * - */ - -#ifndef _ASM_X86_MMZONE_32_H -#define _ASM_X86_MMZONE_32_H - -#include - -#ifdef CONFIG_NUMA -extern struct pglist_data *node_data[]; -#define NODE_DATA(nid) (node_data[nid]) -#endif /* CONFIG_NUMA */ - -#endif /* _ASM_X86_MMZONE_32_H */ diff --git a/arch/x86/include/asm/mmzone_64.h b/arch/x86/include/asm/mmzone_64.h deleted file mode 100644 index 0c585046f744..000000000000 --- a/arch/x86/include/asm/mmzone_64.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* K8 NUMA support */ -/* Copyright 2002,2003 by Andi Kleen, SuSE Labs */ -/* 2.5 Version loosely based on the NUMAQ Code by Pat Gaughen. */ -#ifndef _ASM_X86_MMZONE_64_H -#define _ASM_X86_MMZONE_64_H - -#ifdef CONFIG_NUMA - -#include -#include - -extern struct pglist_data *node_data[]; - -#define NODE_DATA(nid) (node_data[nid]) - -#endif -#endif /* _ASM_X86_MMZONE_64_H */ diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 6ce10e3c6228..7de725d6bb05 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -24,9 +24,6 @@ int numa_off; nodemask_t numa_nodes_parsed __initdata; -struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; -EXPORT_SYMBOL(node_data); - static struct numa_meminfo numa_meminfo __initdata_or_meminfo; static struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index 555aee3ee8e7..ceac5b59bf2b 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -15,8 +15,6 @@ #include -struct pglist_data *node_data[MAX_NUMNODES] __read_mostly; -EXPORT_SYMBOL(node_data); nodemask_t numa_nodes_parsed __initdata; static int cpu_to_node_map[NR_CPUS] = { [0 ... NR_CPUS-1] = NUMA_NO_NODE }; diff --git a/include/asm-generic/mmzone.h b/include/asm-generic/mmzone.h new file mode 100644 index 000000000000..2ab5193e8394 --- /dev/null +++ b/include/asm-generic/mmzone.h @@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_MMZONE_H +#define _ASM_GENERIC_MMZONE_H + +#endif diff --git a/include/linux/numa.h b/include/linux/numa.h index eb19503604fe..e5841d4057ab 100644 --- a/include/linux/numa.h +++ b/include/linux/numa.h @@ -30,6 +30,9 @@ static inline bool numa_valid_node(int nid) #ifdef CONFIG_NUMA #include +extern struct pglist_data *node_data[]; +#define NODE_DATA(nid) (node_data[nid]) + /* Generic implementation available */ int numa_nearest_node(int node, unsigned int state); diff --git a/mm/numa.c b/mm/numa.c index 67ca6b8585c0..8c157d41c026 100644 --- a/mm/numa.c +++ b/mm/numa.c @@ -3,6 +3,9 @@ #include #include +struct pglist_data *node_data[MAX_NUMNODES]; +EXPORT_SYMBOL(node_data); + /* Stub functions: */ #ifndef memory_add_physaddr_to_nid From patchwork Thu Aug 1 06:08:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749638 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 8494DC3DA4A for ; Thu, 1 Aug 2024 06:10:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 107116B00A1; Thu, 1 Aug 2024 02:10:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B8E16B00A2; Thu, 1 Aug 2024 02:10:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E75326B00A3; Thu, 1 Aug 2024 02:10:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CB0296B00A1 for ; Thu, 1 Aug 2024 02:10:35 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4FD90A08C9 for ; Thu, 1 Aug 2024 06:10:35 +0000 (UTC) X-FDA: 82402652430.29.C80B075 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id A276140003 for ; Thu, 1 Aug 2024 06:10:33 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lobL3BnM; spf=pass (imf11.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492558; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3BWryMfEZo/KzQD2cwpXs2RdGDzCNUDXDq0IaVP7hD0=; b=JACBUlDCjPU0BQ65eah5tjIM58nwZfCx6FYNLJNl8RBENhKCxG+zaSGBQI4SHsAWBIFFik St316LFrJXNt2VhatuzVY68FLBoGeIb0O1xhOsREZZ8/LS5wuJ1aAHL0R1CC8SwRtSGClB 1G904wBC+e5fjTgroy1hSb8HKYu3i3c= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lobL3BnM; spf=pass (imf11.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492558; a=rsa-sha256; cv=none; b=VxZSBf/3Kqe8otVvBrxhkexEV9cQn1GjG7ggR/OGP7C443ghpsSGo47MMu5P2u3Qko352j +W9L0hImR4+A1zrVVHrONUwzaiv7cln0+mYFh8/BGG07BR0YqnK1Pc5zPOR4DYqYpggAzt bF/GeTqu53ipjTrp9F8xBwlkKsGnY00= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CB96A62502; Thu, 1 Aug 2024 06:10:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4287CC4AF0D; Thu, 1 Aug 2024 06:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492632; bh=M/jYHd7+70Yn3Ls9O55R+dDWEJ+Dj73xIHNTwCldMLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lobL3BnM6c0xUSDE/gmQjqGCSw8foPLZVeo/NqQGptvjCBs0CojEBbM5yOHo2j+aQ C280b1MW1QsteD4Ix5pl+2lhaQ+XLtVM08fbLP1K+hBhpRRq6swIJG6YHeNhAjdnms ch7cxpXn3X3djchL2x0KfD+Bf2Si42dLA9NqaBmFIs3VhvBo8ZVTa0kw/jUKs+fc8t rpigYlgV6IJUNN4UjhtvhLvSASsiID2KsgGPMx8bhBhSDRmJvfFpSKmsLkKRzZLNsu ZdaxIPHAXeoK8nW7bGDairHDEi/zUsyBohOU7c6IkMNBpuGosnlFSdRH4lwb/W2FNs wJ6HDjot6JSGA== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 09/26] arch, mm: pull out allocation of NODE_DATA to generic code Date: Thu, 1 Aug 2024 09:08:09 +0300 Message-ID: <20240801060826.559858-10-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A276140003 X-Stat-Signature: ex351bmw85w6d6te88gisjeziipttspd X-Rspam-User: X-HE-Tag: 1722492633-310455 X-HE-Meta: U2FsdGVkX18J9taBwbMpddIY+Sl21fF8ppXiAc0Pm00e2jH75KZKCNUjSQ6T8Ui8JKydNjIF27JjUQKlBTxOizGmud3rS9FPbBSYEhIDd7vo73WYNyeGrFA0fXHMCDjf4Dn8/mL6O82ZV9J5FVKCJ0F+lYY/xkYXm1vY4KbPIdJcBl95lshVJiKRnT0LY+nHkqjB3b3lZy9usIhcdBU/Msf4sMgZoEVwCHR/NJSeVfeSEkj2fTpVs2IxitbFOdd1eSlKIT3vEOBrPmFTwUiJUJcsdvIZJX8kqMJsEtPNh6DZx2bXppEeNmOiE6Ae+wA5BGAtC1cc6tKYcuF+DuP3qMGaTlpDgFhJAvyTgB58nBk7dkA4nVqvfJg837dNB3u3jLukI6nx/PFiehIABtF8WKsiuUFFh8Ia65deb+cAdvv169RgrMmsAazSDZslYHuoAl12Qr09EigIyi6H43kIgcHWzkvoCkhh7/5f3dbFru4ANavWmaDf6B2NV2bCfFMQZd4+esWUm2OzrSp5bBnemPCH3cQdnZfEEKxmktcZHFZYwuJ30d7zLaPJkgnopa9xtLNvPNtSNLy7surFL+a3WSPK4Cz+KCxfFhpeTvkXP4dlVSnx2OqP5K8CuKuAQey9UzoCb2Ap0fPQWWBkh9qIu7l5ie+oAPjgaADITIYjjmJGTAmlgbkcWWQreZVpwcMOmzKE1QmLoPe0o0SUU+52DD27b9anIQdL7EIp39Pyr6vD6LagX614KumuB/ZLvZt1my3a8kf364mBmImjF0TWxU56PJO0+KQB11OKWiQ6G22n1y01jBPn47314uWyCVIJk65EncuuAwXITnX/+BGivk05/O8evxFBwzOeCN9RM1pYm2vzYMLbJnNddf+g0Afh751ClRWERC+WP53jwryyru0TtJ9N/EIaip9G/d8GmW1Uk3RRFXp1Kp/EfFVbAkAcjuI6d5OStWU/A1UoRHV HYFSeLTc Iu3T+rhmKMCVV91FaNpQiBvm75irQf5Xhl2Y7EbqvR276t9fpFdBbJeUgBq16qYNFntrA0AKJCJIr3emhX1WHqRZSmhhi4e5D9sPy3Qu9wK5glcHDN6xQCpwOkBmfIhN+QYkym7vJtMDt67J6obU6nkey2Nghrk4QHra8As/45SBKFw0LbXfobYwX1lyBtUXo6trONww1rCqAJoXi9cEv8ICVQI5IP5kdJ/0rOTTBJEAwLXG1VFKS9MUz6LyuGlfQaNVlFFulA8nHaBKaHuH5yqf51aHtExuyfVujCTNJAQWoYNeDRVG8e++ClUfEH2GP7N2C23/55U2SuwzpYgGBUJfjWNuzP1M22hQIsvTdBG4KhJiNMPJ+5xmBSIaDERCbaEkX1eUkqCAihQw= 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: From: "Mike Rapoport (Microsoft)" Architectures that support NUMA duplicate the code that allocates NODE_DATA on the node-local memory with slight variations in reporting of the addresses where the memory was allocated. Use x86 version as the basis for the generic alloc_node_data() function and call this function in architecture specific numa initialization. Round up node data size to SMP_CACHE_BYTES rather than to PAGE_SIZE like x86 used to do since the bootmem era when allocation granularity was PAGE_SIZE anyway. Signed-off-by: Mike Rapoport (Microsoft) Acked-by: David Hildenbrand Reviewed-by: Jonathan Cameron Tested-by: Zi Yan # for x86_64 and arm64 --- arch/loongarch/kernel/numa.c | 18 ------------------ arch/mips/loongson64/numa.c | 16 ++-------------- arch/powerpc/mm/numa.c | 24 +++--------------------- arch/sh/mm/init.c | 7 +------ arch/sparc/mm/init_64.c | 9 ++------- arch/x86/mm/numa.c | 34 +--------------------------------- drivers/base/arch_numa.c | 21 +-------------------- include/linux/numa.h | 2 ++ mm/numa.c | 27 +++++++++++++++++++++++++++ 9 files changed, 39 insertions(+), 119 deletions(-) diff --git a/arch/loongarch/kernel/numa.c b/arch/loongarch/kernel/numa.c index acada671e020..84fe7f854820 100644 --- a/arch/loongarch/kernel/numa.c +++ b/arch/loongarch/kernel/numa.c @@ -187,24 +187,6 @@ int __init numa_add_memblk(int nid, u64 start, u64 end) return numa_add_memblk_to(nid, start, end, &numa_meminfo); } -static void __init alloc_node_data(int nid) -{ - void *nd; - unsigned long nd_pa; - size_t nd_sz = roundup(sizeof(pg_data_t), PAGE_SIZE); - - nd_pa = memblock_phys_alloc_try_nid(nd_sz, SMP_CACHE_BYTES, nid); - if (!nd_pa) { - pr_err("Cannot find %zu Byte for node_data (initial node: %d)\n", nd_sz, nid); - return; - } - - nd = __va(nd_pa); - - node_data[nid] = nd; - memset(nd, 0, sizeof(pg_data_t)); -} - static void __init node_mem_init(unsigned int node) { unsigned long start_pfn, end_pfn; diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index d56238745744..8388400d052f 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -81,12 +81,8 @@ static void __init init_topology_matrix(void) static void __init node_mem_init(unsigned int node) { - struct pglist_data *nd; unsigned long node_addrspace_offset; unsigned long start_pfn, end_pfn; - unsigned long nd_pa; - int tnid; - const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES); node_addrspace_offset = nid_to_addrbase(node); pr_info("Node%d's addrspace_offset is 0x%lx\n", @@ -96,16 +92,8 @@ static void __init node_mem_init(unsigned int node) pr_info("Node%d: start_pfn=0x%lx, end_pfn=0x%lx\n", node, start_pfn, end_pfn); - nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, node); - if (!nd_pa) - panic("Cannot allocate %zu bytes for node %d data\n", - nd_size, node); - nd = __va(nd_pa); - memset(nd, 0, sizeof(struct pglist_data)); - tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT); - if (tnid != node) - pr_info("NODE_DATA(%d) on node %d\n", node, tnid); - node_data[node] = nd; + alloc_node_data(node); + NODE_DATA(node)->node_start_pfn = start_pfn; NODE_DATA(node)->node_spanned_pages = end_pfn - start_pfn; diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 0744a9a2944b..3c1da08304d0 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -1093,27 +1093,9 @@ void __init dump_numa_cpu_topology(void) static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) { u64 spanned_pages = end_pfn - start_pfn; - const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES); - u64 nd_pa; - void *nd; - int tnid; - - nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); - if (!nd_pa) - panic("Cannot allocate %zu bytes for node %d data\n", - nd_size, nid); - - nd = __va(nd_pa); - - /* report and initialize */ - pr_info(" NODE_DATA [mem %#010Lx-%#010Lx]\n", - nd_pa, nd_pa + nd_size - 1); - tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT); - if (tnid != nid) - pr_info(" NODE_DATA(%d) on node %d\n", nid, tnid); - - node_data[nid] = nd; - memset(NODE_DATA(nid), 0, sizeof(pg_data_t)); + + alloc_node_data(nid); + NODE_DATA(nid)->node_id = nid; NODE_DATA(nid)->node_start_pfn = start_pfn; NODE_DATA(nid)->node_spanned_pages = spanned_pages; diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index d1fe90b2f5ff..2a88b0c9e70f 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -212,12 +212,7 @@ void __init allocate_pgdat(unsigned int nid) get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); #ifdef CONFIG_NUMA - NODE_DATA(nid) = memblock_alloc_try_nid( - sizeof(struct pglist_data), - SMP_CACHE_BYTES, MEMBLOCK_LOW_LIMIT, - MEMBLOCK_ALLOC_ACCESSIBLE, nid); - if (!NODE_DATA(nid)) - panic("Can't allocate pgdat for node %d\n", nid); + alloc_node_data(nid); #endif NODE_DATA(nid)->node_start_pfn = start_pfn; diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index c6c7f43cb1e8..21f8cbbd0581 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -1075,14 +1075,9 @@ static void __init allocate_node_data(int nid) { struct pglist_data *p; unsigned long start_pfn, end_pfn; -#ifdef CONFIG_NUMA - NODE_DATA(nid) = memblock_alloc_node(sizeof(struct pglist_data), - SMP_CACHE_BYTES, nid); - if (!NODE_DATA(nid)) { - prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid); - prom_halt(); - } +#ifdef CONFIG_NUMA + alloc_node_data(nid); NODE_DATA(nid)->node_id = nid; #endif diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 7de725d6bb05..5e1dde26674b 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -191,39 +191,6 @@ int __init numa_add_memblk(int nid, u64 start, u64 end) return numa_add_memblk_to(nid, start, end, &numa_meminfo); } -/* Allocate NODE_DATA for a node on the local memory */ -static void __init alloc_node_data(int nid) -{ - const size_t nd_size = roundup(sizeof(pg_data_t), PAGE_SIZE); - u64 nd_pa; - void *nd; - int tnid; - - /* - * Allocate node data. Try node-local memory and then any node. - * Never allocate in DMA zone. - */ - nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); - if (!nd_pa) { - pr_err("Cannot find %zu bytes in any node (initial node: %d)\n", - nd_size, nid); - return; - } - nd = __va(nd_pa); - - /* report and initialize */ - printk(KERN_INFO "NODE_DATA(%d) allocated [mem %#010Lx-%#010Lx]\n", nid, - nd_pa, nd_pa + nd_size - 1); - tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT); - if (tnid != nid) - printk(KERN_INFO " NODE_DATA(%d) on node %d\n", nid, tnid); - - node_data[nid] = nd; - memset(NODE_DATA(nid), 0, sizeof(pg_data_t)); - - node_set_online(nid); -} - /** * numa_cleanup_meminfo - Cleanup a numa_meminfo * @mi: numa_meminfo to clean up @@ -571,6 +538,7 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) continue; alloc_node_data(nid); + node_set_online(nid); } /* Dump memblock with node info and return. */ diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index ceac5b59bf2b..b6af7475ec44 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -216,30 +216,11 @@ int __init numa_add_memblk(int nid, u64 start, u64 end) */ static void __init setup_node_data(int nid, u64 start_pfn, u64 end_pfn) { - const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES); - u64 nd_pa; - void *nd; - int tnid; - if (start_pfn >= end_pfn) pr_info("Initmem setup node %d []\n", nid); - nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); - if (!nd_pa) - panic("Cannot allocate %zu bytes for node %d data\n", - nd_size, nid); - - nd = __va(nd_pa); - - /* report and initialize */ - pr_info("NODE_DATA [mem %#010Lx-%#010Lx]\n", - nd_pa, nd_pa + nd_size - 1); - tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT); - if (tnid != nid) - pr_info("NODE_DATA(%d) on node %d\n", nid, tnid); + alloc_node_data(nid); - node_data[nid] = nd; - memset(NODE_DATA(nid), 0, sizeof(pg_data_t)); NODE_DATA(nid)->node_id = nid; NODE_DATA(nid)->node_start_pfn = start_pfn; NODE_DATA(nid)->node_spanned_pages = end_pfn - start_pfn; diff --git a/include/linux/numa.h b/include/linux/numa.h index e5841d4057ab..3b12d8ca0afd 100644 --- a/include/linux/numa.h +++ b/include/linux/numa.h @@ -33,6 +33,8 @@ static inline bool numa_valid_node(int nid) extern struct pglist_data *node_data[]; #define NODE_DATA(nid) (node_data[nid]) +void __init alloc_node_data(int nid); + /* Generic implementation available */ int numa_nearest_node(int node, unsigned int state); diff --git a/mm/numa.c b/mm/numa.c index 8c157d41c026..67a0d7734a98 100644 --- a/mm/numa.c +++ b/mm/numa.c @@ -1,11 +1,38 @@ // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include struct pglist_data *node_data[MAX_NUMNODES]; EXPORT_SYMBOL(node_data); +/* Allocate NODE_DATA for a node on the local memory */ +void __init alloc_node_data(int nid) +{ + const size_t nd_size = roundup(sizeof(pg_data_t), SMP_CACHE_BYTES); + u64 nd_pa; + void *nd; + int tnid; + + /* Allocate node data. Try node-local memory and then any node. */ + nd_pa = memblock_phys_alloc_try_nid(nd_size, SMP_CACHE_BYTES, nid); + if (!nd_pa) + panic("Cannot allocate %zu bytes for node %d data\n", + nd_size, nid); + nd = __va(nd_pa); + + /* report and initialize */ + pr_info("NODE_DATA(%d) allocated [mem %#010Lx-%#010Lx]\n", nid, + nd_pa, nd_pa + nd_size - 1); + tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT); + if (tnid != nid) + pr_info(" NODE_DATA(%d) on node %d\n", nid, tnid); + + node_data[nid] = nd; + memset(NODE_DATA(nid), 0, sizeof(pg_data_t)); +} + /* Stub functions: */ #ifndef memory_add_physaddr_to_nid From patchwork Thu Aug 1 06:08:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749639 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 C5663C3DA64 for ; Thu, 1 Aug 2024 06:10:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C33D6B0088; Thu, 1 Aug 2024 02:10:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 571F86B00A3; Thu, 1 Aug 2024 02:10:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419936B00A4; Thu, 1 Aug 2024 02:10:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 201A86B00A3 for ; Thu, 1 Aug 2024 02:10:47 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CFA0480863 for ; Thu, 1 Aug 2024 06:10:46 +0000 (UTC) X-FDA: 82402652892.24.34A2E81 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 1F74E140017 for ; Thu, 1 Aug 2024 06:10:44 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BzrrpwSU; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492640; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wo3Ohr8dRmC2rHh5s+ch0FdI2+jtORG6cyKULaZqg3o=; b=BJQdp9xrTiyxpQtZCErlMQ6l8uWe5OnAeSLNCMiBtswl5npFDxVTYsO95MqSqD52k0wlxY V1BN2TA8RaUdd/ktRccMSRWZ4FmrDlDUoNTaEkeKQH9E1tSEW7iWXnFpSNJ9MvWOIVTPHk oC9SAqxYJi581mtZ2QBzkzGhohVecmo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BzrrpwSU; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492640; a=rsa-sha256; cv=none; b=bzJBBkPbHMWzTubAyAT9aPtVXNt8aYXeg0ik/a5JFGss88Qk7ucYw4EohvfxadirPtnnEy v9t+OXjRZ6WGxp1WLUTnJ3vG+D1M9K9KSqschOxAwQ/E0X3kvKm5S7+y+JmxRpLw1C058P 4i3uOPBo0sqGXRsj+0Y2bRFstfUvg60= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5CA8C61B43; Thu, 1 Aug 2024 06:10:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EE00C4AF0E; Thu, 1 Aug 2024 06:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492644; bh=ONCzrmemywG2vkX0T5B4JcZZcN6Oq4w/h9cKr2li05M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BzrrpwSUCZF+YtPmGe8wYoZtOINEkc03C0wjZ6L1V7Ke9yxnnMKhlxOvWTmr3xNKL RwwQ4qbUzVP72GFWRT0LGacckCL17mMefUkGOCL5lNJFKFcUO5MN1ZU5IcXIYSAsBa Ayk8ocLa9tikf+2dBzqD2xckHWAaWuGol/rUMIS3I0bensi+3b8VKqMhBWSQUxWvWz 7OosMhy+ydzopL682Cq/octMdJ4VWiYIdp8tVyjGqJJLE9jFcr4SQmDw2fW/hbasZw zsU4ENLhqEvLQCPXighzypwrPAnA2uGQICNKQ2ub5hIHuHOxXf35551P+mRG1wi1wA 3mCgasT1JPP8Q== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 10/26] x86/numa: simplify numa_distance allocation Date: Thu, 1 Aug 2024 09:08:10 +0300 Message-ID: <20240801060826.559858-11-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: koaqtu46ct7g488yko17cq65th9iujij X-Rspamd-Queue-Id: 1F74E140017 X-Rspamd-Server: rspam11 X-HE-Tag: 1722492644-254972 X-HE-Meta: U2FsdGVkX18ftl58OGYTqqHWTsAjcWHllTLzrB1Lo+Qhxbz+2ETmxDlmZFqXOecN2CCTm/Miz9uBmyGs6kmm95mDLbCvIV9vk5gFjXw+FdtV4+2ufVHvDJ44Lz6mzCSVH3dB3CL0WqE5z6RxwND2EM4Mz4A+kcEoObPxbmPpDnHN6BYIPSfJIRSGrHRCK4Yjzbavh4ZfIp17P4dbaku6rQgMs11bzwqGyWaFix/n5lzoHQchTIqqfqu69jeFGugABeMKZfLY/dM0UhVBV99nNo52gcAvtHddDpkuQYj8PoxlVCk1Bc1aDIjvQMinoqznDg8MFooQ5f7MapyjHUyw/6lKWUjHRoAIOC6D1vCnQJ8uZTTGFvhF9DqZetAyBELm3Aj2bwjAA00BzdKLKvC+1cj9FGhUC++Vuw4PVdjGX4yhvqEwXYYgQ2BV6RgZ702IJzl0WvEEmwE1bJsczylv8ERbdQ3AxVRNQY+Ljgz6w0ybDgbr6ZtfyWSkpZDkWCOWwCOS3mThe0KnJHlcKjiipH4xOoN24rj7BaX6sEBVpH1O/tVTIQWkiVDOHX0M4I7WTeAB3to2tKzzJTNPKMdZNl+pu+T6kcJic7Q/lhXfagrMkButfnSPvXl++XPxlPmA6KFrNWCSroBLf7vun/qH/HGgwNhi/k6gkY2yKPbF1w4Ol19gwFbiCyXX2JqNRYrh3+kW5w/fDbQEiriSaXMWy3eIZtdWCkOgzAP9kR5zUCey+mc3hN21Di4uiU58q3HFO2aPGIw9v21ZwqaYgAfEkBL7c4Ihfn1e+zcXpEjE6gfaq109I0r7b1aqIF9IHaIZ1mP/4hit0azJhzz5XoteJMHlpLAWGZRFACIb78XU5lq8JdblXxzv3e4hxZMmjDNUjiaFMdJWnfrbEtPCojqMJc7A0K30dRY59WiigOsmeGBM6fCLrdTFGUtB6zK5i0QtM0w8HYfk4BSTQWG3Wg4 dQ22euv+ feJxjEhYNaJxFRZJmnb2pI86355AiOmb4eijb0v4vNdzbPXnP4EyjW8p5GSRQ7ympBVDMBxUCUIVjflCa9LAW4pTJYOIpA7CXnp9mvg+a1Up/z1xD+6tP5HdnWzlCuSrd5XRi2CzK/xzQfEVqfEzMd9naO86LH5jOHDC0/hqyjyZxYjWVN5e5cZTJVssXG4RIF8XiZSwi6aJGoKoeZRYswu8wZYa0ypQAqDMHIdIJfvKIy6rr/U3md1tqx9kBmUTWH/d9AKxbzH2OSCsGDOdm53LFHkg5R3g1c7/0sebGijObnWmk1PMnmrHCnZ89+sinRqw1ddqhJWF2xmki7FdSgDuuI52FYITcIgN2 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: From: "Mike Rapoport (Microsoft)" Allocation of numa_distance uses memblock_phys_alloc_range() to limit allocation to be below the last mapped page. But NUMA initializaition runs after the direct map is populated and there is also code in setup_arch() that adjusts memblock limit to reflect how much memory is already mapped in the direct map. Simplify the allocation of numa_distance and use plain memblock_alloc(). Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/x86/mm/numa.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 5e1dde26674b..edfc38803779 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -331,7 +331,6 @@ static int __init numa_alloc_distance(void) nodemask_t nodes_parsed; size_t size; int i, j, cnt = 0; - u64 phys; /* size the new table and allocate it */ nodes_parsed = numa_nodes_parsed; @@ -342,16 +341,14 @@ static int __init numa_alloc_distance(void) cnt++; size = cnt * cnt * sizeof(numa_distance[0]); - phys = memblock_phys_alloc_range(size, PAGE_SIZE, 0, - PFN_PHYS(max_pfn_mapped)); - if (!phys) { + numa_distance = memblock_alloc(size, PAGE_SIZE); + if (!numa_distance) { pr_warn("Warning: can't allocate distance table!\n"); /* don't retry until explicitly reset */ numa_distance = (void *)1LU; return -ENOMEM; } - numa_distance = __va(phys); numa_distance_cnt = cnt; /* fill with the default distances */ From patchwork Thu Aug 1 06:08:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749640 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 42FE9C3DA64 for ; Thu, 1 Aug 2024 06:10:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D150F6B00A5; Thu, 1 Aug 2024 02:10:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC52B6B00A6; Thu, 1 Aug 2024 02:10:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB4006B00A7; Thu, 1 Aug 2024 02:10:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9CCCD6B00A5 for ; Thu, 1 Aug 2024 02:10:58 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 500A8808BD for ; Thu, 1 Aug 2024 06:10:58 +0000 (UTC) X-FDA: 82402653396.12.C3D3F00 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id AE86EC0004 for ; Thu, 1 Aug 2024 06:10:56 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bNC6SBuY; spf=pass (imf10.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492581; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yodlQ5GPZgxCEUDYWONn6pEc76uoISXos/NtCDyc9Oo=; b=8V3B33AHxMvrLbbSd7DyW/TGvcvp6vvY7zZQlT8Qe5Z7vT0OMfFy3ZsmwXb6hvqN8oRC0q AoKPXBDt9sffG11Zn6uuWD7QubdnjJ4jU8QBuBWVnvkH3iiMCMEIVBVCPV1sMkVHY9f0pX fV55lioobTc+V+Gjo4J3GBof1N0UMqY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bNC6SBuY; spf=pass (imf10.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492581; a=rsa-sha256; cv=none; b=HEwNZmDkyr99tsIPzEMS+RvKUlKQsWUGkG05+B24N3uAhP6qpR9BOqbQLyXAXSr9R7K/wl fpPZaZNsnYYjsbLtyZ20vQyMD6st7XKQXlZqnUNPD9QvKaAPZURkca4LuETy+mL3TQomQ+ B2iY9YJPkBDpfcqwbHhXdae7nAGOrno= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E93086140C; Thu, 1 Aug 2024 06:10:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 959F9C4AF09; Thu, 1 Aug 2024 06:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492655; bh=Rjf0iRc+VbNov1IXYA1f8/WuGCpuVfgjGuHB5zpeQrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNC6SBuY+2C9vgNv6AmEuNkLzbIiXAVs/wMzl1r36Gs0k8CLoQWb0q62HVoiTSgwA yQRxQAj2MPhJPq0x0p/VUMiIU9P2gj0sy8r4TrFGEl5cblhhm6dYAsyBqUDMFH+X+W +D8Q7EB3niaXdEH17S/n6XfMr5sBAkGSoqR2/AdaFEBFqO95ruILiTWlbyxMwoc2Ih gyipgDPNN380SXng7+cEQlO6DS0+22xe+S8kPgh/BsQ9oW27iWFyuyh5YutwywPGcT LFaiTvhOfihkxBHZNNKH6590ZbIZ1bzu/P7b+HwhiGgpJyPBVSvwX30a7PsrsgvCDJ El5tISvg50iFA== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 11/26] x86/numa: use get_pfn_range_for_nid to verify that node spans memory Date: Thu, 1 Aug 2024 09:08:11 +0300 Message-ID: <20240801060826.559858-12-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AE86EC0004 X-Stat-Signature: dode6445p41ryuq8mkdioq5de315jjwd X-Rspam-User: X-HE-Tag: 1722492656-691607 X-HE-Meta: U2FsdGVkX1+DZ3m9QqBJJkEdvYDF48K4Rdb1waVGFpzeZhVyKUGBrAghEuuIlDyB+bZGZBh7OWPPsQjsqIw8LppN+7UG67B3W8VVOGKbkMYXAT/fjZXd7I6lBFHIfcdSEA4aXYj38Q2fNOwR8hxWZdFJvs62GGX8f+HjogwSgYKazys+9YWqNeaMez8tIVThS875HV2nEmvbo3xAFXX+acuiD9KweRx4FPtYpu/3no21gseh1jzBjM192JHmm8BwmJDdG4jTsqv8vuWqHdqZO84yVwbA6XS/fhxHHsj3qA/oOsmsdJESRGX24Tkp+aJvmVTtLBoReSJlgJAJXZnsJmc+ZaX86I6lz26kEKHa7it2/e4h84FTwbxwrotjTfMOczFKLsX/w0Gv9n/dNjglRtOnGSLkkhxspm2/U4S+GbMQ05ubyWfKTdBze/CIqueI3G1a838LYHl+2YdFxaFY+vFRIgGhn5OsSXOTYvjeFLo2lRS3CK1aiSyX13ti5hoQOAiiRNhyKpFDFr43sSk9Isq4ed+tlP0wJ1ZS/QQRvAEfLwNE9bt6gpH3Mh8jd8fx6Jo1pRoWoc8OxiVDiUNACOVZqi23r+9C4W7RGmCcenZnkhvG2I4f75ZWkYXdzSyFVwW+rd5lbTvCWNm6WNopQ14F6l3sNks5r56c1H1JvtsNTgGwMbsFJX4DqjPaEaSZWrzLF940ahgWSVGb2po2QNWXocb/jgcTXM1NOHsel3WCBT58vQzMaUZiHjklbiH8hLEUUX7KDdMhKiHGf+1ZsGp8/hhyiJWONKZi1jwyS7NbyuRaQBMsXHrszScRPjOwwUCWcesv/3mXe6CHYQkCsDuEJgauxQj7WikLJyXvupyE0qcLYU5ST4FR3bxUm1ZXbwi0xKPRxmzPnHgBbABSS6nPTadNjt4IrUBf7/Kef8LjWpbwNNhqeVuXdDpRVlpMWbQKN0AbCZwYo/9Ncz8 mG+w4DNW cA+C/JPpcSQCStcL/YBKggIX887r1HoEu21x4rRs9d+J/ubKbFTAvUyyS8C574qHSgC+uSZDHSCPmpnoRTqVdcyjFitZbL7R2eV6UJsPY3b2zN48dX74lLki8GcHevf2WEVCsHL7vMG07aPyVNhNNO3S7csIgfo9rOT7Aka1h3TdQq7RJ8oXiPNb0XS1tSxIWKlmHytrGw3btLNEsSOeY1zIXIIXw8/M3VY3NlyeZgcFz1yUbo5kkrkaPyxcN40mru5QUjseZq8bYM0CfLg4VT90W2RMM53e3EJYS+VDyyIEUFDrXeyrzV5v5InsD6OUWGCOiNX/cY+Yf3VKPhTJXlTy7AzMMFqTePnmq 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: From: "Mike Rapoport (Microsoft)" Instead of looping over numa_meminfo array to detect node's start and end addresses use get_pfn_range_for_init(). This is shorter and make it easier to lift numa_memblks to generic code. Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/x86/mm/numa.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index edfc38803779..cfe7e5477cf8 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -521,17 +521,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) /* Finally register nodes. */ for_each_node_mask(nid, node_possible_map) { - u64 start = PFN_PHYS(max_pfn); - u64 end = 0; + unsigned long start_pfn, end_pfn; - for (i = 0; i < mi->nr_blks; i++) { - if (nid != mi->blk[i].nid) - continue; - start = min(mi->blk[i].start, start); - end = max(mi->blk[i].end, end); - } - - if (start >= end) + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); + if (start_pfn >= end_pfn) continue; alloc_node_data(nid); From patchwork Thu Aug 1 06:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749641 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 9FBDBC3DA64 for ; Thu, 1 Aug 2024 06:11:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A0786B00A6; Thu, 1 Aug 2024 02:11:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34FA16B00A8; Thu, 1 Aug 2024 02:11:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F1356B00A9; Thu, 1 Aug 2024 02:11:14 -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 F3A096B00A6 for ; Thu, 1 Aug 2024 02:11:13 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B0E81808BF for ; Thu, 1 Aug 2024 06:11:13 +0000 (UTC) X-FDA: 82402654026.06.D7ED697 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id 6FE78A0035 for ; Thu, 1 Aug 2024 06:11:11 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iwZjfAqj; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492626; a=rsa-sha256; cv=none; b=bB+RznFqKzc4k9/x4JxV9JeDQhamOimXR5sEonuWodkAxuoi+1Jy54Mev2SFqHk1g2QPb7 sM4xMM+n/ye/uLVus7p6rLz8BWlNCPA/jlbDEi8G658rEbnGCQX1GAtKYBRAA8Gzz9X8N+ 9ZLxs6tsx+t/d8FDSHx2J+IX5aKBkEI= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=iwZjfAqj; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492626; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FXTtpuhAk1W5RAY6zK1ECo7Ks/o7/Q//k+GQA+MwvtU=; b=RZMeKxfsYpqLEJYDD98X0ih5ODEIuCs3AyCDPzZ+Xm34njqzqAKIWfiSTj5C8mK4/fUMn6 5QM29LKOm3+KlL9UGTOFacXE+GV0Sm7GoiLX8eI5kDq17JSYmQiN5ADTzF0j6AYfLUwL/C /okjZyg5bwmOm9EDXaWQf3CsT/nnU9o= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 36A1ECE186A; Thu, 1 Aug 2024 06:11:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D0B8C4AF0D; Thu, 1 Aug 2024 06:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492667; bh=9xX4GW03Y9jnCjd61LosuHfHXAjDKwtO3hWmKCiBLr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iwZjfAqjYFuWiVOPXvynm6SGM1EFpAukZfMkt6R9F4SwhI5QT+Xp7QvTIEpuLE3KP FplaU//xDRQisqOHnlLu39H26TkCIv4PZzSU7MGzz+2/p27FJxqLasq83v+lxsZ6ea av9mDrJ0bQ/+h0XBKELeakt837vrywc0WgoES31rQbqguhIQv2Q9CYKxTRYKhvXSh8 TqOn+l7L0Cq4ZpG2bGce/4xmpyaLmDwwj54B+YZmwJPikT33fFp9LO1Kxo0BHwZAkT tXbllQKTbH1zDS3xF3bDHNztoODZx7SzsEmXyCACl4y9jaMcCs8hkhJ07v0t5vyk/L xXtMTp3EUhJaw== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 12/26] x86/numa: move FAKE_NODE_* defines to numa_emu Date: Thu, 1 Aug 2024 09:08:12 +0300 Message-ID: <20240801060826.559858-13-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6FE78A0035 X-Stat-Signature: aobjbntbbeuaetm961iyptm3o1d95oma X-Rspam-User: X-HE-Tag: 1722492671-686689 X-HE-Meta: U2FsdGVkX18gWQa5emVhX4Ou1sylvuY63x9E5nSgIwWjYi0MhrrHSGdNtjdAuoLH0z6tW9OnBHwtScg3f+fyeJd3MRxe8a0ccq0I0cQ2RYIWDdKSOCT7Qb5FwtkHJTBdTZO/O0WvjeW0WU3kDraAMbabIPw/qpMv3NXWMD2/MM8r21pQKbf7vj+6SBNO2bSrYvmJrNzTb4Se9ho6rA/NmBvWB8FtxJ+l+5OXoVovumWrfFv06GiWTAfB6O6XS7r64EAQkk9CUc13s8sV70Y83t3sojLAeJ/bcM4KHkbOc3VSsBDRY/eT8aKgH6Q641UxcC69fstxBle+XEfug21Wdt4yitU5PC7XzO68riYENhJxV4LhMnRA1ZCyyvwuRceoGSEUWrvCm75ZVFLIUuW/5VjN5U5pmgF3l2ECDb4JuyRBkkyphckOWkT8wpLQ27ItgZWD5RF+MyD0MfcPilxq2WdZnJ+oeY3m8vK7X91xeLHIyQgfln/y7WGffRja9gnIUx3S7n7OfcKe6G5PzTX8WeT6Iaw2kOEQbH7gpKiklRoSdvsb3leclacJIML0cIi2F6r9Hr6OHnILZpH1KQEESnm49v/7Yo9xU/YSxf46onVlVp5ml5OzObuNW5TaAIq4nNBb11oFX6VF9uUWgyvy9N0u3PVENgzQsXciXzq1bxEj84KhhzB/4b+NWxClNOWWfQdnmFlasR9LrY6ez8SK4We9H7nYIR9Fii+avCc0C3C+6Rocac8i75jt7k6anrpUARyse/aY9OzpJJTi4xbxM5oxh0+NmxS2kQUk7N25iQzRrwpRPLB9/9gQJtNCaBx5xG+kUlgTcG/afF2Soo/hjWI/soLrWgmtut7YSJxi0hoopllsiTb0s9V+uNJ2ah/PNIbG2lxi0HkmvuFCXJ3IsdnjQeraowULcFC7cPN+nujxGUFV3rN8/Ot7zEO486e6LYaXAa/pn5AVuvHNbDw dQ2sAI2c TE7AS6FbzoXtsUDfZJVBBzF9iC41C/5yoALDONvgaquJig3W+b9FNfBplrVyIH/yAZeHOIP+uIpuzwNlF511E5pyWB+nF20uMPUHORXqrD6J9ZdYacoKT6J0mtY7vdHZqjWNvqVCCVB30UxVvlzzqq/hA2NyS0LUtPhDtr2wUsqmMyqsS8HlH8hWvIEBdlzzOf10WPE5lRfuGNb/djcienqwy8d8cd/1EqCEonBAZhXyBsJKz0R0DgbygTSnw/MaLDr3q+CmCyKmmrBaSMUg/W0Cs4GATaTHKn258EIXGJPfjk9S742H7xQ0y5AjlaaWfY/O4l5JoYofraD1XLYT7BhwCtWvDmHRfYWow93VcBpV9QqXCfTQcaSYm4g== 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: From: "Mike Rapoport (Microsoft)" The definitions of FAKE_NODE_MIN_SIZE and FAKE_NODE_MIN_HASH_MASK are only used by numa emulation code, make them local to arch/x86/mm/numa_emulation.c Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Tested-by: Zi Yan # for x86_64 and arm64 Acked-by: David Hildenbrand --- arch/x86/include/asm/numa.h | 2 -- arch/x86/mm/numa_emulation.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index ef2844d69173..2dab1ada96cf 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -71,8 +71,6 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable); #endif #ifdef CONFIG_NUMA_EMU -#define FAKE_NODE_MIN_SIZE ((u64)32 << 20) -#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL)) int numa_emu_cmdline(char *str); #else /* CONFIG_NUMA_EMU */ static inline int numa_emu_cmdline(char *str) diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index 9a9305367fdd..1ce22e315b80 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -10,6 +10,9 @@ #include "numa_internal.h" +#define FAKE_NODE_MIN_SIZE ((u64)32 << 20) +#define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL)) + static int emu_nid_to_phys[MAX_NUMNODES]; static char *emu_cmdline __initdata; From patchwork Thu Aug 1 06:08:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749642 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 0C2CFC3DA4A for ; Thu, 1 Aug 2024 06:11:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FA206B00AA; Thu, 1 Aug 2024 02:11:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8598B6B00AC; Thu, 1 Aug 2024 02:11:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 637E76B00AD; Thu, 1 Aug 2024 02:11:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 393786B00AA for ; Thu, 1 Aug 2024 02:11:22 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E9100A08CD for ; Thu, 1 Aug 2024 06:11:21 +0000 (UTC) X-FDA: 82402654362.09.3B4AC26 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 468D8180018 for ; Thu, 1 Aug 2024 06:11:20 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QI4Ewjqh; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492634; a=rsa-sha256; cv=none; b=lCoWnbGzKS+1NFsUVG8Ze9jQqmjCVlWbnwBkx568X+MPFtqEb83myAsgX9X1/eB+5ntwSp inmUIQ833D1XKO8/SI0N3mIgnoLcBBIF1iWlrobYZ7K+O4T7fi+dyzRfIJqas6oVSwcnzq Gfc1Q4E1wATbePetOTs0gR00cPlvsDA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QI4Ewjqh; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf16.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492634; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nmzOpg0JTx1pCcKSTmmbgph0fZ/wgtHghU2Q/iaXZP4=; b=D+QVwt1fcHc5wk4BzkGL0Mcm5uKSwyPVfes+Ty66DSddR1mY9UUzy846Hvu7Jv3VNvaYNg 30Q5Wtk8YPeP08Qwu6NcMxGOnE1WN0tfqzMsKU7BRJnKL8eTRbuUXkkljAFH8nq/DRHgfU gMyvpawBOcc+puRhoKd1EjgFbXE9MA0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 620B162770; Thu, 1 Aug 2024 06:11:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE12DC4AF0A; Thu, 1 Aug 2024 06:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492679; bh=UKbRiZvva5pXaCAN24L+st+TlDsrE6ScVNjHbfzaMRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QI4EwjqhxFK7jXHI8z7S0O57azEU4hGOVevIE/YotTQq1td3MZ2supNz+Ar1UY/8p CqH0vm+HUdWwyyQtOmTJL8GxeHWgkoxA9rHrAqFDpO8QZvDQ0B7A/qtQd6XIYMmvCL yF+WVGjYTgkr8pTlPUXdfLQPO4+BiiuOVGnFri2SIJQj7s3JUdSLac9RwDt0im45/z KF+xkSA/StepsYoUsUx9dms3l08hn82DVtcw4Ebjuu7NI0IYntmyRLFRWCUSLJV2AM w6aVlRwary2DoahCBShwjZmokC0xXVajZA+CqgVwGuwUANLNZrZgdNx4T+e3NLqx7w MkJo6xLcQkn0w== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 13/26] x86/numa_emu: simplify allocation of phys_dist Date: Thu, 1 Aug 2024 09:08:13 +0300 Message-ID: <20240801060826.559858-14-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 468D8180018 X-Stat-Signature: 61wocwg33jispo1sux9nyei36uf94qts X-Rspam-User: X-HE-Tag: 1722492680-41885 X-HE-Meta: U2FsdGVkX1/jBRnlJXAGS8p1FlJjoukWFepYV+b7ORogfdt7FblZjQkWIuRRm4/7r7jjUcBtk8Ne0YV4kW/mvmuoWLLXxEvRHI2QEUtbdGIFRW3XC64v82naSQxpRnq2+Z4SrgiB84TBm1sjS0UIJfmRyjXTbf8gThET/dzs13h+aXVv0p/iLaXy7em5eObG6Lv5vvVv/M0wzBAnnmAlFKvgTQYiupu9V69/mWlON3kJhabClaSSkLGj13pwuVAAbRqLSLhJq1t4jD0fx4OdqKqaOWGc/JQ9FjOk+WJmAFoaiJWLrge+5DeE9oX4/QJEDke9Zx831LN7JXnvoW6t0ZfJr4lJA5ZE9nYWL5qCwD70k/CFI7iRfhiPVbZXzTSOxrPZ811LKy3fv6FB8wlTu9ANLgeC5TtS0uR86Jd7hlSizOKN8QblhtjFsB+fq+cE1PNnz6pBLYgWVvTCDBBGXYjS+FdZZ7OUXCXDdPX8zifroLKPXrVbglSIPy6TSk3UvH7IOI8f9CGQOjfV1r8WJXjA3C8JfJUavz7cN5+Aei7f468kkjwKHhHSoL31vWL8RNvtGPH73xaU/k1UR1TQv8QjfaGD868cWZMiXnt5bvIx5prVWjWrJGtjHH79G0RN00o8/46OZ44TsFqCAFutlQUEsvScfdVL2V3JRn4zC9shv9ggQyvfsKBjwaaBrzT2hPuJM5Tx3BCf2PFDHbnUUK0jFQZE5cP8m+Y4draulekCsbIHljOLLdHU8OOmVhUO9EPY32b5QP1roAh0PuEfAY4FMf+Fqi0J0wiEl2Ohp2h8THWdwib5GHkZ/8z8PwsfWnJtlVrWOQeWuBJ6yV2bcKgy+38UGzf0u+T0fiAxslrrhxigXO2Thnxr82oAzv29bAglHUMwrKJvjTCEqgRbkV9O6ReZCKrQTBVjRLmsCegdffr33/OXwhctgDS++jRI4ytQ4F6wcjA8I2IfLBB DDCW6u+4 +dT3QSzLu5lBUfFpWuUHz9YQnOW3yl/fXwkx3CyIh1zBSeglVusK+GR8khwNanKaQnm0sTTZY9bQS1cecG7Y7Ihr6GtjVyccLuD1R7zIPqs9+p3xFnf9zfn6x0nJffPKkRoUfFNXW88j5ltiD740LyfzuUeGsw31XPvUSna5ophJE/nzoxPK4+Z540l9qDxFpauDWPene9jIyoSEOG5KpwbkR2Xs/X3v8dzOCJOCbamYU1d8OuFZZrNIN4EYOYsJGdOwq5BzmAkwh1NIpu3PP5oggt19/LqKc4nZDrIZvBALI3HZn7CkKgvVjrMf47dm/eMqw1cZCikPtxLM2xZSi/in42tFrrqrvYL5RYwomzlNpiJb4Ail9Bws77A== 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: From: "Mike Rapoport (Microsoft)" By the time numa_emulation() is called, all physical memory is already mapped in the direct map and there is no need to define limits for memblock allocation. Replace memblock_phys_alloc_range() with memblock_alloc(). Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Tested-by: Zi Yan # for x86_64 and arm64 Acked-by: David Hildenbrand --- arch/x86/mm/numa_emulation.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index 1ce22e315b80..439804e21962 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -448,15 +448,11 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt) /* copy the physical distance table */ if (numa_dist_cnt) { - u64 phys; - - phys = memblock_phys_alloc_range(phys_size, PAGE_SIZE, 0, - PFN_PHYS(max_pfn_mapped)); - if (!phys) { + phys_dist = memblock_alloc(phys_size, PAGE_SIZE); + if (!phys_dist) { pr_warn("NUMA: Warning: can't allocate copy of distance table, disabling emulation\n"); goto no_emu; } - phys_dist = __va(phys); for (i = 0; i < numa_dist_cnt; i++) for (j = 0; j < numa_dist_cnt; j++) From patchwork Thu Aug 1 06:08:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749747 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 B1841C49EA1 for ; Thu, 1 Aug 2024 06:11:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DDB06B00AC; Thu, 1 Aug 2024 02:11:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2673C6B00AE; Thu, 1 Aug 2024 02:11:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B9666B00AF; Thu, 1 Aug 2024 02:11:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DD6696B00AC for ; Thu, 1 Aug 2024 02:11:33 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A491E1608E2 for ; Thu, 1 Aug 2024 06:11:33 +0000 (UTC) X-FDA: 82402654866.26.8CA518E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 0A646180014 for ; Thu, 1 Aug 2024 06:11:31 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sggkX9UX; spf=pass (imf06.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492647; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bG6M5e3j+jSHyqtWx4rOIEyZl256PwLpGT2BLqjHCxw=; b=H4o5CzSRQe9+e29lZAh690kozcyZalzahWMvkJ6rm/SniqsR66Io9P57xKWLuTZXlA2kdw 2639E9plCpTdtEAo55f89jbQgMMhJ+slBAIJR+1zvPinCzcIybgVXjZy9eyA63UldfwGhw 8N61i1ycVDF3FWNzX/MMgNAExvYk+Bw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sggkX9UX; spf=pass (imf06.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492647; a=rsa-sha256; cv=none; b=B+rXGhVaA8wvr2wE0Wsn5aZWT1k399URx/MLsdpgSNTi1F2Ql+Zol0UfKPC2KrivvEnTiP xIpRLW7/+0pkrao7zf9wMcBLOigkkZnZmnJOeSAKz/Tz+A8iw2/MOAfpi3zupQFNHaylnn OXiIprUs7aQ6RFm5ZDO3pzDyUsGVnsQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4A73A6140C; Thu, 1 Aug 2024 06:11:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7173C4AF0C; Thu, 1 Aug 2024 06:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492691; bh=Hwkl2fYIk7TOliTb70qL/9b9HRfQD7yZz25kkbJxzwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sggkX9UXhxZlNsIU8Cl5aBh0kTbihmyOr+rKh8PUi6HpNbM0T6FIQKsN6mrcRHsf+ /SHE74zS057DN4assx4nJNhHkYwGmMqA+89c3GAN3GWW1EkySpM/jKp7djIHsHmlQ5 J+Rv/xUy1WL2p4zN9YP1XUUreurEUzXm4yz/xIU+P7O+cVStnX8B/b0U7trY1kXI3V hD82NTGJiywRlimIOVt1MLB+ZyReKPZdsG0bD+xetL7gw2D1t4eztwZAnWKJPPnk54 vnKaRI5ocC0Nw9z/8HV7kFU7UWYinD8YhScEarF8oyOHxHwNgCdMiLoia/TVqvYCnm Y30JzCKYd6e+A== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 14/26] x86/numa_emu: split __apicid_to_node update to a helper function Date: Thu, 1 Aug 2024 09:08:14 +0300 Message-ID: <20240801060826.559858-15-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 5yzc6oo8t5y5nnimr3zc57aem6s1a5do X-Rspam-User: X-Rspamd-Queue-Id: 0A646180014 X-Rspamd-Server: rspam02 X-HE-Tag: 1722492691-343066 X-HE-Meta: U2FsdGVkX1/0fKT5sNuw80F8o0se5RDsd1OE/qmBKEM8koxaoXIXHiNWs61IiDjllVldZGGQ+uaPwIIj2/L3RDxqsZ4hOmksGcygC8ca4qj7OTji7ZtYOqbdWD+I2/taU3EdpJP8n0gBMEKrVLCrz0rIVASiSBY7i6JNOHYIZd8+D/5yiBI/vPJvpKXU3Uh1ex7jZ0KaKthZIvqFv+boF0O9NQv+mdRm/vo0TLatKFwMkIbrWoJuyLu23muAr6roTp6LexPgjKJfwJBiY99qwLf8OdlCmkWdONI35/HSfHUUfgxbIIEEMYC47HmqnjZmz+p+odbh9GN1nVkuhTdguHk/M6P5EhVu67SPcZCFc/7TVV8ZOaiVhBfgixJ8687MeeipAlFT32ir1CxOBwijiCbWHQBmK5g0x7XAuP6ykRwnK92+XT/YeGdcgql2Ep11GecPB+hqmyvREDVTjBh5z0x+0hcYBQT4pgzIOnM783f73HfQgWe5T00szMcM+4CSTImDSGcpqSq5dJiVUJsOKfYRMBamdG/EiwkeO2ShoDXxsGXzLFCWcKgwW+4IyDjonTECxSojRhgp6y7jT8wEftqgKd/0Y+gwnH6EQ+bm3VRteKK00l+BoX6dJWovd99IhFfPXjNwX8JIqA0nMsaR2F5fXSCjhZgvEskiZWgwILOd/jpeBzOBMEk7QDkONwS/deHS+WbhZkCCV5ZxXYf3AcjWCMrUqwHqSC+boL5vq4SeVMyhAsOMpTWLFLottyg7Ee6JOMEcAFRffkWdOWc84Ft7Sw2jdqQHEPLCMHX3861f1CTnJe+bPOL0bKBSeNFNvGaJ0ztBPiS9UsTuY/y/ArkL9qbXCtpj/7h+2sn8EiWkWrUhc8tf/KWywkSEYrJ9V1mwimEylw2dHPnglI7Lw9Ky/6dKkxKyiKldXng8kVX1odF97p9r4fyANxFyHwep5+yPnnvJZXc9FlNLLzg 7250qL4Y Nm2dbFjwXRa9cwMOD/utBg3Ji7/j7g757x4i7CafunIDui8hcVRDYnY1faR8cFOJcRLf0vbc4DZ5M1oWUYikcMwuO6D0wyNGXNzPDD1X31YBXZ26qkN+8nNogqucHJTqGVA8p2CYtRjNPpyXRL6qpIhoUAqKkbI5aao97++E7TkSnKBkhd6i73aq29AWL7jeizsGQtoMiGcU4xpe33SSVz3zMVeGxhkn0QzY5afk+JvYg9NzzOuBd76Zbklf1Ajg4dHXVuin6nk1nJS6KH8rLQRro8yDVNfDkUcTD0u0V5zEzud1XQMUJoSdyFCN3vb9Cgj3d53k0fk8WmBuBIF4R7rJa+/qTZd8aSh9FKhvWy/948vtY2j8AlzSvBA== 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: From: "Mike Rapoport (Microsoft)" This is required to make numa emulation code architecture independent so that it can be moved to generic code in following commits. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Tested-by: Zi Yan # for x86_64 and arm64 Acked-by: David Hildenbrand --- arch/x86/include/asm/numa.h | 2 ++ arch/x86/mm/numa.c | 22 ++++++++++++++++++++++ arch/x86/mm/numa_emulation.c | 14 +------------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 2dab1ada96cf..7017d540894a 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -72,6 +72,8 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable); #ifdef CONFIG_NUMA_EMU int numa_emu_cmdline(char *str); +void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, + unsigned int nr_emu_nids); #else /* CONFIG_NUMA_EMU */ static inline int numa_emu_cmdline(char *str) { diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index cfe7e5477cf8..9180d524cfe4 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -848,6 +848,28 @@ EXPORT_SYMBOL(cpumask_of_node); #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */ +#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 + * reverse-mapping phys_nid. The maps should always exist but fall + * back to zero just in case. + */ + for (i = 0; i < ARRAY_SIZE(__apicid_to_node); i++) { + if (__apicid_to_node[i] == NUMA_NO_NODE) + continue; + for (j = 0; j < nr_emu_nids; j++) + if (__apicid_to_node[i] == emu_nid_to_phys[j]) + break; + __apicid_to_node[i] = j < nr_emu_nids ? j : 0; + } +} +#endif /* CONFIG_NUMA_EMU */ + #ifdef CONFIG_NUMA_KEEP_MEMINFO static int meminfo_to_nid(struct numa_meminfo *mi, u64 start) { diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index 439804e21962..f2746e52ab93 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -476,19 +476,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt) ei.blk[i].nid != NUMA_NO_NODE) node_set(ei.blk[i].nid, numa_nodes_parsed); - /* - * Transform __apicid_to_node table to use emulated nids by - * reverse-mapping phys_nid. The maps should always exist but fall - * back to zero just in case. - */ - for (i = 0; i < ARRAY_SIZE(__apicid_to_node); i++) { - if (__apicid_to_node[i] == NUMA_NO_NODE) - continue; - for (j = 0; j < ARRAY_SIZE(emu_nid_to_phys); j++) - if (__apicid_to_node[i] == emu_nid_to_phys[j]) - break; - __apicid_to_node[i] = j < ARRAY_SIZE(emu_nid_to_phys) ? j : 0; - } + numa_emu_update_cpu_to_node(emu_nid_to_phys, ARRAY_SIZE(emu_nid_to_phys)); /* make sure all emulated nodes are mapped to a physical node */ for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++) From patchwork Thu Aug 1 06:08:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749748 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 892BAC3DA4A for ; Thu, 1 Aug 2024 06:11:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CC6F6B00AE; Thu, 1 Aug 2024 02:11:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1558B6B00B0; Thu, 1 Aug 2024 02:11:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EEB7F6B00B1; Thu, 1 Aug 2024 02:11:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C9F956B00AE for ; Thu, 1 Aug 2024 02:11:45 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8BA9E1C3192 for ; Thu, 1 Aug 2024 06:11:45 +0000 (UTC) X-FDA: 82402655370.14.EB26CB6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id D8F7B1C0005 for ; Thu, 1 Aug 2024 06:11:43 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cc4WvpYS; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492675; a=rsa-sha256; cv=none; b=Fm4mqvKCZU3fztYNn3SH+y7/G56o1znqJSXDxZNMXos84lKJaL3sZqPv0LJBOEeNZEiB66 r/Rk6Yf/LK9yoP7qjX/yS5pjrea3KgzCXiURlJ7oB5s8VIoewbAerMoW1vrjsscmjieCkm JWJSl73GpkPMuwxi6xLYgtKby0LBCW0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cc4WvpYS; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492675; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ldvHts8Cfvhr+UDdgvxO/yzMODWtjFIQBYUtdNuGiEw=; b=bCquCG4B73IH75Tli2CQVw4ueyCgBXBZYZ6ez+1ZD8eW574lTTXtijKryfShc2kcRlwIh6 i/pxIsBamUrk5m1YFdPhMasMu9Rg6dThSKs1tGm7c7HWzOnP9hvoJxXULcyITNcR9bl8A3 nceCSaeZIZb/QAInkRIvkUCj+9ZPjCc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 18C616263A; Thu, 1 Aug 2024 06:11:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83720C4AF09; Thu, 1 Aug 2024 06:11:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492702; bh=a5wWvXp5sZfTjfQzLNJ+a5bJ5ZJPXICMVCqsCnclVEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cc4WvpYSk2IgT7M8f19PtLCANZs9ejYsgNz/cO/n9jZN8qc0EaFo0hFRtACL2ndu9 6mQNevH4Cv97QgSeWny58SoJTelXG7+q/yupDHNjypMc9KfJSvH9dJkMYoPTVHXTFt qOV8qLNBVKP+KQ0TDEb4IxRQJnulZa3OTDwTCKv2ZaDrPMf/7n9eMwLrQ+9DBTKaQ2 CscX8zJ0BsTHTjThMBHjRi6ejLjZ0Khv97xgxfXs5HKaUT5vo9NA59YW7rniE33hCD LqVJKeLyrOjDdwbfYs2UANWDOREYQ7kpVO/8B3QyCKE+mrBu4NqR3hacT/uObjnyRS Fd/de2lMyOA4Q== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 15/26] x86/numa_emu: use a helper function to get MAX_DMA32_PFN Date: Thu, 1 Aug 2024 09:08:15 +0300 Message-ID: <20240801060826.559858-16-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 5x4g9f7d1jaadhencqakw3iwn7ywkgb6 X-Rspamd-Queue-Id: D8F7B1C0005 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722492703-910976 X-HE-Meta: U2FsdGVkX1/weeAL/GsJnXCsxKqz8rxPWVQbxnoDUkdWZD95FAtdZVfU+XywlWNbeFxqwhUqOO9wtWBcLZ5AgOLnTDUJT5tUXS71DBMruV0lh3vg7MNtlBxZTHiEdcMpju34RTEB1bRsajtCOu/0J4rdsxn3B0rih6jGN9tMZY7/+dfrg6Kxc4oFyonJRBjm6ik01yPoM0zx3CKUTTeSJMOFqgpWFdeQXsABR41JYAGXF26pDI9heC6DVZsOMHUkPL33ITinj5Lp4G4z4RSr+IU1jiJPby/6oPDTWrMdhLFx9jaH5xhwrHkqpnr40bmtsmaMiUytGVzeJXKCx0X/QwZWVSa9Ot8aNkCL7u+XmZe3+D2QWNCzKMLDqsz0500e5FJcE4jTaJsPOykF0WqKvXiJQeneTpRcnGJGj+KYL+3zDTlxN/ARCvkPCOuCGjkOu34icqgn2oPdSYnwldjvb72TQnQ7WBiwFNWxIzA5Qw64gntnQJ9KXEoUbS+WR8B2OJw3UFcgFe2nAhHbNgMmqz6R066GKwnvZTdPBXGqvNAM3c9uXYGkJVkbhHi3GUK20Z54vH1y2lwg0qf0Edxlo8b1Tb3mdDMF0OaAys/nu0mdivUcjbYkcTDvi50GNar3jSUlUnmjZ9NnhSubldKfSGWqCBqFRYA8AgKtvlOTIrPTWGo/fgrrmQNJuyCkJ4hiESwdJDkLY7xJ8BtdxEIjAzcVqGGWznK0iW9IuavXTWU4Rn5C/LHlJ18iuJcBDUXPiqRElY3rYaqStlqLfzdrXrrAo867jjgLdlSTCJ3UUlFhX4IdhvGb8V52wxCKMYa8jnZHrEu2m0EDr8aUlGKsEk2bcu872UhkKcpjqzkB9W54+Mt6u7KN9EKKrJls+v9v0vZeX6xZiHThjTbwI/gPKYeWbI8ILxmj7dofXT0ANQySfcMTsgrnIHDVCvLxa2I5PIQplDzs48AL+sRUUCI A0iAytQi JBEMOsGWXKkDAf0sOp9AZoSzehSpoAJGUjy8MYzZoADiQo88M3FleCkg+ZxCI6onnThL6J2K42gNoiaN2i/39R0CCd6DdWUTYXcA1ogiqtdZ3FxboHjg+I+QC87lDqkaJ/NtT5QHr7ZrGDQSZCu1lcbCQVwr63wqTnNWf6GARx3qJ7KesGB2Jz50j7H0pGF70zMz2E4xQ6InCvnYSr6XqdM7k4H7uB1EeU9GOlRmN7Xks3fDcVpFVulioHW0RM3PsIFWqiP5GfMhyLbhx3UFJw4YsIq+9OWNQLVWdkTfkEcy1AgZcLceihjMJTGaNmlfbLr8UsC06R1jbuJZ+rxOdxjbKd73IZe/LI284IQ/JTVbHoskLpR1F6DIT8g== 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: From: "Mike Rapoport (Microsoft)" This is required to make numa emulation code architecture independent so that it can be moved to generic code in following commits. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Tested-by: Zi Yan # for x86_64 and arm64 Acked-by: David Hildenbrand --- arch/x86/include/asm/numa.h | 1 + arch/x86/mm/numa.c | 5 +++++ arch/x86/mm/numa_emulation.c | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 7017d540894a..b22c85c1ef18 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -74,6 +74,7 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable); int numa_emu_cmdline(char *str); void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, unsigned int nr_emu_nids); +u64 __init numa_emu_dma_end(void); #else /* CONFIG_NUMA_EMU */ static inline int numa_emu_cmdline(char *str) { diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 9180d524cfe4..8b7c6580d268 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -868,6 +868,11 @@ void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, __apicid_to_node[i] = j < nr_emu_nids ? j : 0; } } + +u64 __init numa_emu_dma_end(void) +{ + return PFN_PHYS(MAX_DMA32_PFN); +} #endif /* CONFIG_NUMA_EMU */ #ifdef CONFIG_NUMA_KEEP_MEMINFO diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index f2746e52ab93..fb4814497446 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -128,7 +128,7 @@ static int __init split_nodes_interleave(struct numa_meminfo *ei, */ while (!nodes_empty(physnode_mask)) { for_each_node_mask(i, physnode_mask) { - u64 dma32_end = PFN_PHYS(MAX_DMA32_PFN); + u64 dma32_end = numa_emu_dma_end(); u64 start, limit, end; int phys_blk; @@ -275,7 +275,7 @@ static int __init split_nodes_size_interleave_uniform(struct numa_meminfo *ei, */ while (!nodes_empty(physnode_mask)) { for_each_node_mask(i, physnode_mask) { - u64 dma32_end = PFN_PHYS(MAX_DMA32_PFN); + u64 dma32_end = numa_emu_dma_end(); u64 start, limit, end; int phys_blk; From patchwork Thu Aug 1 06:08:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749749 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 8B847C3DA4A for ; Thu, 1 Aug 2024 06:12:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CCE66B00B0; Thu, 1 Aug 2024 02:12:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 155C96B00B2; Thu, 1 Aug 2024 02:12:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE9A86B00B3; Thu, 1 Aug 2024 02:12:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CDCEB6B00B0 for ; Thu, 1 Aug 2024 02:12:00 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 87249A6301 for ; Thu, 1 Aug 2024 06:12:00 +0000 (UTC) X-FDA: 82402656000.14.D56FBD7 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf28.hostedemail.com (Postfix) with ESMTP id 41C72C001A for ; Thu, 1 Aug 2024 06:11:57 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GkLWQm1Q; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492714; a=rsa-sha256; cv=none; b=axiy2DNUN4yfJSVzor2asprhBI+MBKJ5Eq2k3fhCq28IvJvEhCCGOrpK3w6tfXWR87f0tG 6Vqs/aiNDCCbVQdfHyfRHHeN5H7C8oCth73d5qSsqB5aw78w7u0jlwSaY7Ek2O0DVpCyfj bKfiqwIcsmeAZJrLFs+CM7j5z6KdfNI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GkLWQm1Q; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492714; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dIK4Q55zcs4jtLMV2QXL3Lds7wZWhrcM7lXH2HGTcWc=; b=z/gg1k6KGV0yJxYEV2m0si/xhszxZ8b2M2cySvXLof11Sh1c5oz1yCIK7e4pXV6f3XtbtZ DpwZjIvveECL/kLV49vzvujJTtA9Zvy8br4/BQBwNOL4Qf8j82O9ng9ooYLMt1tiqHowjI 7UFTI/SNvVXsdCdlNLVj/oOms36gyy0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 46118CE1802; Thu, 1 Aug 2024 06:11:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 529C4C4AF09; Thu, 1 Aug 2024 06:11:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492714; bh=tUveSvpmOKw9bqMG5RQ6nMnK0ZuTV9etYelIhziTeKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GkLWQm1Q39ABfZyuhL6Q3SBO4x8iIO1aOYcDhmjxdECKBtds6RIO3AsP0dLgQUStG QtW9mrfuZenyPBlVOdTI6i/S7REgDYRiKN1CA/IZhqIQyTIcJ90XkexFNG60he+YcW nwrOGB28RY2W+r/fDE7isGmLMQjlQEUqNl+lxkKeFvYHRXETpNfOonPK6ZTeFWShkT jzJ1lBRW55/u4dxl3cz/0+RXH32Yt5toq8GS93/M5oq7C7KyDwt05M6VQW3pWbSuRL AZSqAJyclCGUpW1mJRDt2v/lV8TLLPtVR/5UoF3gKYIFZwKuaKKOEqL3YLG7fkgpyx /3cmatQc1Tbwg== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 16/26] x86/numa: numa_{add,remove}_cpu: make cpu parameter unsigned Date: Thu, 1 Aug 2024 09:08:16 +0300 Message-ID: <20240801060826.559858-17-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 41C72C001A X-Rspamd-Server: rspam01 X-Stat-Signature: piw9uytybo3rkkf13jgrf4to3uyqfjg4 X-HE-Tag: 1722492717-222208 X-HE-Meta: U2FsdGVkX1/v0WQZESbAif+434pxuv3DiWlKGtlgxvM5hLMIkwitf+mMhuWwG6sixIvGod/p/DABKb9EjDZFT8CDDRs6WoU8E1lmcmiU8N4VnH0UfrUeHjbf+raY/RL0sKlH5lFU5i22kauMSHPO1Lz9eliSFhg6c9SsQwD4nSchJA7BFajXIj03HOdUnXz7O+fCMBAVkS0D7v89UdMpoW4RtkwY0GV5pZFEEKnmpuqSorJ/SsU0QIXx3ZwidWPxI+6Cq9Hkr36q04QVXS6DkinC3AsNOgQQHcAt9sorXEvJt+oYS6XgmpQN5KnU+OOURjlIUPHXaXag91LOtm7wCd2ZNY4YC6QB4iUU/kyUcwoxRWqSNhxavGEc/EVe9PmkcbaO5ZIOOOb/b6/jm8ieXxs6Qn6cKY+KSvf6r2wqnIZMzZgZR+bjC6fltILja9QVbzOGOxxYcygVnHUkJMlbTa5jYus2dNMKh5zqHD86dxupLVMpNvxFk8ugOxOnkhRdhlVHocwq/JL6Z6RH9Agshzn54b656xKJFxadtBfAoocigVEP8H/xBtdQzjOw+Cict1wyaJTMbreffPdGnq1gGtqRAvFD1zfsVCTNz1PmJNfCruVu8zACFLYYTs2qI2T23zelr7ZBhcanhLCJwYad7Bo2FQShe8duIliKDDtVIy1upCWOzCmCmGRgeuLPKwNvFpEYITjM/fS9Kb0otU0l/R/HkDPjJK+8oQ/uGJ9XA8qzceNq4aMoIwxpQCt4YJp7uKkjZBTy1S7zi5qvFADiQBX2NTxg1Qz8O8rnBRbBHhyjsUpGJ8lO2n0f0hUnuYOFqnnqeiwGiUBXJLiPDUhGfEjY9OAlTsRtgTH0dEXWT7+fGvZIR5tywYjdkkGp3e7c9MTo3mu1jSCsBzkDWxh4mSR/zuia+zjSIbVqJINkZ8ydndjeeQS2WItmsHdZkPAjOjV/Vzd9eOiLtfA3H6l C1vY0siz A0Fe4v57nKtCrkc2s3Oidwe3ZaVjyLItVYTU+MR3WYocSL6bQrQ6NhC7eUOAOIyOeDzJoRB6EO5oq4qBM2UVVFq706DA1I56Mg0swlxmRQ07Utj4hvMvL9Mm9lcjm/6B2ocGHMFcmc2xqAXb888IfiH+eHhsIOP9vCDDiz1Wx5WkJjpkFfODN8WL3GxgFiwt9H3oOxpwjKsFpbdRAKEICqJBDA3Ghv4YdFnzAEo23L2o3sLyR6y146cKcT823VqgFqZd11Z72EzdonEhtSCfjhBN+fadMVfgWunHOiIpb680ukL+lStVBIn64kCjO5AwjxMe+65S9xaO7nyZGVt1jc+PPKxfubvytKWvASYy68XRj/oF9gAuuhGIyyA== 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: From: "Mike Rapoport (Microsoft)" CPU id cannot be negative. Making it unsigned also aligns with declarations in include/asm-generic/numa.h used by arm64 and riscv and allows sharing numa emulation code with these architectures. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Tested-by: Zi Yan # for x86_64 and arm64 Acked-by: David Hildenbrand --- arch/x86/include/asm/numa.h | 10 +++++----- arch/x86/mm/numa.c | 10 +++++----- arch/x86/mm/numa_emulation.c | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index b22c85c1ef18..6fa5ea925aac 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -54,20 +54,20 @@ static inline int numa_cpu_node(int cpu) extern void numa_set_node(int cpu, int node); extern void numa_clear_node(int cpu); extern void __init init_cpu_to_node(void); -extern void numa_add_cpu(int cpu); -extern void numa_remove_cpu(int cpu); +extern void numa_add_cpu(unsigned int cpu); +extern void numa_remove_cpu(unsigned int cpu); extern void init_gi_nodes(void); #else /* CONFIG_NUMA */ static inline void numa_set_node(int cpu, int node) { } static inline void numa_clear_node(int cpu) { } static inline void init_cpu_to_node(void) { } -static inline void numa_add_cpu(int cpu) { } -static inline void numa_remove_cpu(int cpu) { } +static inline void numa_add_cpu(unsigned int cpu) { } +static inline void numa_remove_cpu(unsigned int cpu) { } static inline void init_gi_nodes(void) { } #endif /* CONFIG_NUMA */ #ifdef CONFIG_DEBUG_PER_CPU_MAPS -void debug_cpumask_set_cpu(int cpu, int node, bool enable); +void debug_cpumask_set_cpu(unsigned int cpu, int node, bool enable); #endif #ifdef CONFIG_NUMA_EMU diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 8b7c6580d268..cf7b95125d2a 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -737,12 +737,12 @@ void __init init_cpu_to_node(void) #ifndef CONFIG_DEBUG_PER_CPU_MAPS # ifndef CONFIG_NUMA_EMU -void numa_add_cpu(int cpu) +void numa_add_cpu(unsigned int cpu) { cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); } -void numa_remove_cpu(int cpu) +void numa_remove_cpu(unsigned int cpu) { cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); } @@ -780,7 +780,7 @@ int early_cpu_to_node(int cpu) return per_cpu(x86_cpu_to_node_map, cpu); } -void debug_cpumask_set_cpu(int cpu, int node, bool enable) +void debug_cpumask_set_cpu(unsigned int cpu, int node, bool enable) { struct cpumask *mask; @@ -812,12 +812,12 @@ static void numa_set_cpumask(int cpu, bool enable) debug_cpumask_set_cpu(cpu, early_cpu_to_node(cpu), enable); } -void numa_add_cpu(int cpu) +void numa_add_cpu(unsigned int cpu) { numa_set_cpumask(cpu, true); } -void numa_remove_cpu(int cpu) +void numa_remove_cpu(unsigned int cpu) { numa_set_cpumask(cpu, false); } diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index fb4814497446..235f8a4eb2fa 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -514,7 +514,7 @@ void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt) } #ifndef CONFIG_DEBUG_PER_CPU_MAPS -void numa_add_cpu(int cpu) +void numa_add_cpu(unsigned int cpu) { int physnid, nid; @@ -532,7 +532,7 @@ void numa_add_cpu(int cpu) cpumask_set_cpu(cpu, node_to_cpumask_map[nid]); } -void numa_remove_cpu(int cpu) +void numa_remove_cpu(unsigned int cpu) { int i; @@ -540,7 +540,7 @@ void numa_remove_cpu(int cpu) cpumask_clear_cpu(cpu, node_to_cpumask_map[i]); } #else /* !CONFIG_DEBUG_PER_CPU_MAPS */ -static void numa_set_cpumask(int cpu, bool enable) +static void numa_set_cpumask(unsigned int cpu, bool enable) { int nid, physnid; @@ -560,12 +560,12 @@ static void numa_set_cpumask(int cpu, bool enable) } } -void numa_add_cpu(int cpu) +void numa_add_cpu(unsigned int cpu) { numa_set_cpumask(cpu, true); } -void numa_remove_cpu(int cpu) +void numa_remove_cpu(unsigned int cpu) { numa_set_cpumask(cpu, false); } From patchwork Thu Aug 1 06:08:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749750 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 85BD6C3DA4A for ; Thu, 1 Aug 2024 06:12:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1B7C6B00B3; Thu, 1 Aug 2024 02:12:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA11A6B00B4; Thu, 1 Aug 2024 02:12:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA4B06B00B5; Thu, 1 Aug 2024 02:12:09 -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 839DF6B00B3 for ; Thu, 1 Aug 2024 02:12:09 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 493761C3199 for ; Thu, 1 Aug 2024 06:12:09 +0000 (UTC) X-FDA: 82402656378.03.BCC5D80 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id 8441114000A for ; Thu, 1 Aug 2024 06:12:07 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SI9kX9ww; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492685; a=rsa-sha256; cv=none; b=eLzgOYld3UhE9AHQLv+hzv91vBhdXjLcR+VDgkMRIQ/it2CDoHmoESM4brGj1JU58Ipeu7 INPNub8eflQMoy37Xg/drxOVzcHguzLr4Mz1V8n/rXv3Cr4kH0jSbt++dEblWGRHtpr5ij Om01xpHEutWMfZrj8TNNAZ92DCe3FaM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SI9kX9ww; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492685; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DwhVIhsj30jxTiJBTD/ve2HIHgTiMN0iMWIu6o4ttCM=; b=PRHsUcsME4x9hDBY6zQc4UDksNl+A99druYWagLjNntpOl70peD9pc0hFV0R4AWsUci6wS DrFx8xfMA4sY7wWLe9UCDZhkGSekws2iFhXb2AGGgfmcGVBF4AEWsHC6ICgnO4/ph6KsSN i8uuHJWyGLNlXfHKvYRBLo/kyGCy7AU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A746162502; Thu, 1 Aug 2024 06:12:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20746C4AF0C; Thu, 1 Aug 2024 06:11:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492726; bh=6yxZcYgtZmyUA4flgnzIUhC/8Scw4RmDOThwQk0RqyM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SI9kX9ww0Pd+ldiMaD3Tdo5w9355sGDZxPVvxohDrndc7RuFygmkAkCad16JAHlJq KAD0yYuZgpiNMasM+dElYCZP3kw/X2ytjIRIm0XOBkEGnlr39K9CO1SQPFVewxee23 HXGGR0bXmzDLK3VGnqwkfTDNNJ/8scgdzhPrX9cbEhxrbt52tH2Wk8UNhJWYLlAfle 9U/97G5vAg+5H3q24IY2FTgKQV8gqAB0SMYbWmu6KmXHULsZNN92KkWXlgL4RjO6qx o3+oo2mraQU+BHdj+LdOii1LvcdAOh0qGr7V2YES0Vn3Z7HtiWJSIhDXKLMMbFjeIQ 4BlVapp6spXsA== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 17/26] mm: introduce numa_memblks Date: Thu, 1 Aug 2024 09:08:17 +0300 Message-ID: <20240801060826.559858-18-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8441114000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5z1ftqeqppjuhku483s88nnuuaq8m6o6 X-HE-Tag: 1722492727-927025 X-HE-Meta: U2FsdGVkX1/Vfnfd9QDsmnaw9aHg0j/B5lzQ+esePRg9x9McvGt+aHVexrNiMOr0nfq5TpqAMhFgmkGkJZMxX1GznUvOOBLEJtzgqwCSaG5P8QUdNeYhmMuxFf+yyF4r5XIA88tWkPzkBUac+g4sxiG4ETG61HVU65mBRHN5j/u3L8fv+PA8oG7F5ZPqn5wIzWG8/DqPcdXubhSo73ZyZqgjoIvuGNX/5WMWWSzNfJLuFF2uhQ8GL64w8b4rJEWZ1sB0qO8Zo/HW4llFX40pT2ZDACZMCcd19x9GSy9K6slJznYmvC/vCShcjs8N0SaoBmBgER8Cu3zNy0SR6Om/0RVGauisAGrvsaMygpx4KeLjEWtbVZRooJ49dXNzH+nfFqHKbrgojZOjzzEyFxbrL4LO1XxI3UXwaDl3P+wd9wOzutbwvEkFdlYkW0mbkl9gzp6OoyJpsBXdVxd7BnbErbTIU+g/Qy4Yw8QvxxXfjkkr1RCUJOnzPKINBAmqrneNh2nguyTzrFlNz3+0pGrzZCwjSdX2Cki3ct98DZJnpEfn7BZ8POptMF8Op6IaRzgijScuce9rkuHEffeNMRlnPJTgplIANEN5je0qj+xF7eYGxZ5QHOMsyMfb1S4rA6hUgY9g0q65yLnbyJk0F9OxC6zcpsiVBZlZB/zEqFMqjXOcU3ygB4MzexhquuedM4PLszKukqbcixwvKvOhokSWQcnEOPt2K74ww60Yc9Gxk1tjEroqlUezQBWLPmGWHvoFJv3f0pmXyymrdGs+LEdOW63CiqqlliWqsvxIkpY6YHPHXcE5C138f3HAu8FyAzSulBprsH2ePZDEUKpm/wc0YBrEECuDHfQbFI2d82zmEas7luB0tgLK15Kn0NvGJdQfZV9JRz3gjcdwq3QGeiOSZTWZF82dEeMQQuomDSoiqzwXyuFpSi5z1OFOylLHYrLfRg4m4mP48EX1OchFFdI 4HYzpUxP mojpdt6jKot11MSzfZRou1ClsKqpgc/F84c1HulrGMu+RlsF1M+FYbmAHMF0gpy2qSzkBpLyDTOM+CdgpPN5nC7Lhm6ltM7I1aUha+RTraAFHvQOTGJeIlcp8Bc9uAnTzjLeEI6H1j+3t8UbmKhI7JCKMz8Vr3QxhsqMdJKj8/PzJQffggYK59QXjf8NYKNUq+Id7ULytgtdxCF0S+IHpNm324axhtpdUzxjTD0uIniAuet0zBa5oKtvZ5Y/nIIlPqoB6ScMDrlbhtEiHYBGsTPFtF9ykuoN9MpZbMLT3Rs09KMV91BuagY7uYG0Dhd9L8b62swWL3N3MySdMgWnKyonmxfFFqFpUWPDe+5Bb0khjOVTJVqOHQ7cCRgYpaIvrLBil 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: From: "Mike Rapoport (Microsoft)" Move code dealing with numa_memblks from arch/x86 to mm/ and add Kconfig options to let x86 select it in its Kconfig. This code will be later reused by arch_numa. No functional changes. Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/x86/Kconfig | 1 + arch/x86/include/asm/numa.h | 3 - arch/x86/mm/amdtopology.c | 1 + arch/x86/mm/numa.c | 372 +-------------------------------- arch/x86/mm/numa_emulation.c | 1 + arch/x86/mm/numa_internal.h | 15 +- drivers/acpi/numa/srat.c | 1 + drivers/of/of_numa.c | 1 + include/linux/numa_memblks.h | 35 ++++ mm/Kconfig | 3 + mm/Makefile | 1 + mm/numa_memblks.c | 385 +++++++++++++++++++++++++++++++++++ 12 files changed, 436 insertions(+), 383 deletions(-) create mode 100644 include/linux/numa_memblks.h create mode 100644 mm/numa_memblks.c diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 007bab9f2a0e..74afb59c6603 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -296,6 +296,7 @@ config X86 select NEED_PER_CPU_EMBED_FIRST_CHUNK select NEED_PER_CPU_PAGE_FIRST_CHUNK select NEED_SG_DMA_LENGTH + select NUMA_MEMBLKS if NUMA select PCI_DOMAINS if PCI select PCI_LOCKLESS_CONFIG if PCI select PERF_EVENTS diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 6fa5ea925aac..6e9a50bf03d4 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -10,8 +10,6 @@ #ifdef CONFIG_NUMA -#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) - extern int numa_off; /* @@ -25,7 +23,6 @@ extern int numa_off; extern s16 __apicid_to_node[MAX_LOCAL_APIC]; extern nodemask_t numa_nodes_parsed __initdata; -extern int __init numa_add_memblk(int nodeid, u64 start, u64 end); extern void __init numa_set_distance(int from, int to, int distance); static inline void set_apicid_to_node(int apicid, s16 node) diff --git a/arch/x86/mm/amdtopology.c b/arch/x86/mm/amdtopology.c index 9332b36a1091..628833afee37 100644 --- a/arch/x86/mm/amdtopology.c +++ b/arch/x86/mm/amdtopology.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index cf7b95125d2a..6874d5650b4d 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -22,10 +23,6 @@ #include "numa_internal.h" int numa_off; -nodemask_t numa_nodes_parsed __initdata; - -static struct numa_meminfo numa_meminfo __initdata_or_meminfo; -static struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; static int numa_distance_cnt; static u8 *numa_distance; @@ -121,194 +118,6 @@ void __init setup_node_to_cpumask_map(void) pr_debug("Node to cpumask map for %u nodes\n", nr_node_ids); } -static int __init numa_add_memblk_to(int nid, u64 start, u64 end, - struct numa_meminfo *mi) -{ - /* ignore zero length blks */ - if (start == end) - return 0; - - /* whine about and ignore invalid blks */ - if (start > end || nid < 0 || nid >= MAX_NUMNODES) { - pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n", - nid, start, end - 1); - return 0; - } - - if (mi->nr_blks >= NR_NODE_MEMBLKS) { - pr_err("too many memblk ranges\n"); - return -EINVAL; - } - - mi->blk[mi->nr_blks].start = start; - mi->blk[mi->nr_blks].end = end; - mi->blk[mi->nr_blks].nid = nid; - mi->nr_blks++; - return 0; -} - -/** - * numa_remove_memblk_from - Remove one numa_memblk from a numa_meminfo - * @idx: Index of memblk to remove - * @mi: numa_meminfo to remove memblk from - * - * Remove @idx'th numa_memblk from @mi by shifting @mi->blk[] and - * decrementing @mi->nr_blks. - */ -void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi) -{ - mi->nr_blks--; - memmove(&mi->blk[idx], &mi->blk[idx + 1], - (mi->nr_blks - idx) * sizeof(mi->blk[0])); -} - -/** - * numa_move_tail_memblk - Move a numa_memblk from one numa_meminfo to another - * @dst: numa_meminfo to append block to - * @idx: Index of memblk to remove - * @src: numa_meminfo to remove memblk from - */ -static void __init numa_move_tail_memblk(struct numa_meminfo *dst, int idx, - struct numa_meminfo *src) -{ - dst->blk[dst->nr_blks++] = src->blk[idx]; - numa_remove_memblk_from(idx, src); -} - -/** - * numa_add_memblk - Add one numa_memblk to numa_meminfo - * @nid: NUMA node ID of the new memblk - * @start: Start address of the new memblk - * @end: End address of the new memblk - * - * Add a new memblk to the default numa_meminfo. - * - * RETURNS: - * 0 on success, -errno on failure. - */ -int __init numa_add_memblk(int nid, u64 start, u64 end) -{ - return numa_add_memblk_to(nid, start, end, &numa_meminfo); -} - -/** - * numa_cleanup_meminfo - Cleanup a numa_meminfo - * @mi: numa_meminfo to clean up - * - * Sanitize @mi by merging and removing unnecessary memblks. Also check for - * conflicts and clear unused memblks. - * - * RETURNS: - * 0 on success, -errno on failure. - */ -int __init numa_cleanup_meminfo(struct numa_meminfo *mi) -{ - const u64 low = 0; - const u64 high = PFN_PHYS(max_pfn); - int i, j, k; - - /* first, trim all entries */ - for (i = 0; i < mi->nr_blks; i++) { - struct numa_memblk *bi = &mi->blk[i]; - - /* move / save reserved memory ranges */ - if (!memblock_overlaps_region(&memblock.memory, - bi->start, bi->end - bi->start)) { - numa_move_tail_memblk(&numa_reserved_meminfo, i--, mi); - continue; - } - - /* make sure all non-reserved blocks are inside the limits */ - bi->start = max(bi->start, low); - - /* preserve info for non-RAM areas above 'max_pfn': */ - if (bi->end > high) { - numa_add_memblk_to(bi->nid, high, bi->end, - &numa_reserved_meminfo); - bi->end = high; - } - - /* and there's no empty block */ - if (bi->start >= bi->end) - numa_remove_memblk_from(i--, mi); - } - - /* merge neighboring / overlapping entries */ - for (i = 0; i < mi->nr_blks; i++) { - struct numa_memblk *bi = &mi->blk[i]; - - for (j = i + 1; j < mi->nr_blks; j++) { - struct numa_memblk *bj = &mi->blk[j]; - u64 start, end; - - /* - * See whether there are overlapping blocks. Whine - * about but allow overlaps of the same nid. They - * will be merged below. - */ - if (bi->end > bj->start && bi->start < bj->end) { - if (bi->nid != bj->nid) { - pr_err("node %d [mem %#010Lx-%#010Lx] overlaps with node %d [mem %#010Lx-%#010Lx]\n", - bi->nid, bi->start, bi->end - 1, - bj->nid, bj->start, bj->end - 1); - return -EINVAL; - } - pr_warn("Warning: node %d [mem %#010Lx-%#010Lx] overlaps with itself [mem %#010Lx-%#010Lx]\n", - bi->nid, bi->start, bi->end - 1, - bj->start, bj->end - 1); - } - - /* - * Join together blocks on the same node, holes - * between which don't overlap with memory on other - * nodes. - */ - if (bi->nid != bj->nid) - continue; - start = min(bi->start, bj->start); - end = max(bi->end, bj->end); - for (k = 0; k < mi->nr_blks; k++) { - struct numa_memblk *bk = &mi->blk[k]; - - if (bi->nid == bk->nid) - continue; - if (start < bk->end && end > bk->start) - break; - } - if (k < mi->nr_blks) - continue; - printk(KERN_INFO "NUMA: Node %d [mem %#010Lx-%#010Lx] + [mem %#010Lx-%#010Lx] -> [mem %#010Lx-%#010Lx]\n", - bi->nid, bi->start, bi->end - 1, bj->start, - bj->end - 1, start, end - 1); - bi->start = start; - bi->end = end; - numa_remove_memblk_from(j--, mi); - } - } - - /* clear unused ones */ - for (i = mi->nr_blks; i < ARRAY_SIZE(mi->blk); i++) { - mi->blk[i].start = mi->blk[i].end = 0; - mi->blk[i].nid = NUMA_NO_NODE; - } - - return 0; -} - -/* - * Set nodes, which have memory in @mi, in *@nodemask. - */ -static void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, - const struct numa_meminfo *mi) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(mi->blk); i++) - if (mi->blk[i].start != mi->blk[i].end && - mi->blk[i].nid != NUMA_NO_NODE) - node_set(mi->blk[i].nid, *nodemask); -} - /** * numa_reset_distance - Reset NUMA distance table * @@ -410,111 +219,13 @@ int __node_distance(int from, int to) } EXPORT_SYMBOL(__node_distance); -/* - * Mark all currently memblock-reserved physical memory (which covers the - * kernel's own memory ranges) as hot-unswappable. - */ -static void __init numa_clear_kernel_node_hotplug(void) -{ - nodemask_t reserved_nodemask = NODE_MASK_NONE; - struct memblock_region *mb_region; - int i; - - /* - * We have to do some preprocessing of memblock regions, to - * make them suitable for reservation. - * - * At this time, all memory regions reserved by memblock are - * used by the kernel, but those regions are not split up - * along node boundaries yet, and don't necessarily have their - * node ID set yet either. - * - * So iterate over all memory known to the x86 architecture, - * and use those ranges to set the nid in memblock.reserved. - * This will split up the memblock regions along node - * boundaries and will set the node IDs as well. - */ - for (i = 0; i < numa_meminfo.nr_blks; i++) { - struct numa_memblk *mb = numa_meminfo.blk + i; - int ret; - - ret = memblock_set_node(mb->start, mb->end - mb->start, &memblock.reserved, mb->nid); - WARN_ON_ONCE(ret); - } - - /* - * Now go over all reserved memblock regions, to construct a - * node mask of all kernel reserved memory areas. - * - * [ Note, when booting with mem=nn[kMG] or in a kdump kernel, - * numa_meminfo might not include all memblock.reserved - * memory ranges, because quirks such as trim_snb_memory() - * reserve specific pages for Sandy Bridge graphics. ] - */ - for_each_reserved_mem_region(mb_region) { - int nid = memblock_get_region_node(mb_region); - - if (nid != NUMA_NO_NODE) - node_set(nid, reserved_nodemask); - } - - /* - * Finally, clear the MEMBLOCK_HOTPLUG flag for all memory - * belonging to the reserved node mask. - * - * Note that this will include memory regions that reside - * on nodes that contain kernel memory - entire nodes - * become hot-unpluggable: - */ - for (i = 0; i < numa_meminfo.nr_blks; i++) { - struct numa_memblk *mb = numa_meminfo.blk + i; - - if (!node_isset(mb->nid, reserved_nodemask)) - continue; - - memblock_clear_hotplug(mb->start, mb->end - mb->start); - } -} - static int __init numa_register_memblks(struct numa_meminfo *mi) { - int i, nid; + int nid, err; - /* Account for nodes with cpus and no memory */ - node_possible_map = numa_nodes_parsed; - numa_nodemask_from_meminfo(&node_possible_map, mi); - if (WARN_ON(nodes_empty(node_possible_map))) - return -EINVAL; - - for (i = 0; i < mi->nr_blks; i++) { - struct numa_memblk *mb = &mi->blk[i]; - memblock_set_node(mb->start, mb->end - mb->start, - &memblock.memory, mb->nid); - } - - /* - * At very early time, the kernel have to use some memory such as - * loading the kernel image. We cannot prevent this anyway. So any - * node the kernel resides in should be un-hotpluggable. - * - * And when we come here, alloc node data won't fail. - */ - numa_clear_kernel_node_hotplug(); - - /* - * If sections array is gonna be used for pfn -> nid mapping, check - * whether its granularity is fine enough. - */ - if (IS_ENABLED(NODE_NOT_IN_PAGE_FLAGS)) { - unsigned long pfn_align = node_map_pfn_alignment(); - - if (pfn_align && pfn_align < PAGES_PER_SECTION) { - pr_warn("Node alignment %LuMB < min %LuMB, rejecting NUMA config\n", - PFN_PHYS(pfn_align) >> 20, - PFN_PHYS(PAGES_PER_SECTION) >> 20); - return -EINVAL; - } - } + err = numa_register_meminfo(mi); + if (err) + return err; if (!memblock_validate_numa_coverage(SZ_1M)) return -EINVAL; @@ -912,76 +623,3 @@ int memory_add_physaddr_to_nid(u64 start) EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); #endif - -static int __init cmp_memblk(const void *a, const void *b) -{ - const struct numa_memblk *ma = *(const struct numa_memblk **)a; - const struct numa_memblk *mb = *(const struct numa_memblk **)b; - - return (ma->start > mb->start) - (ma->start < mb->start); -} - -static struct numa_memblk *numa_memblk_list[NR_NODE_MEMBLKS] __initdata; - -/** - * numa_fill_memblks - Fill gaps in numa_meminfo memblks - * @start: address to begin fill - * @end: address to end fill - * - * Find and extend numa_meminfo memblks to cover the physical - * address range @start-@end - * - * RETURNS: - * 0 : Success - * NUMA_NO_MEMBLK : No memblks exist in address range @start-@end - */ - -int __init numa_fill_memblks(u64 start, u64 end) -{ - struct numa_memblk **blk = &numa_memblk_list[0]; - struct numa_meminfo *mi = &numa_meminfo; - int count = 0; - u64 prev_end; - - /* - * Create a list of pointers to numa_meminfo memblks that - * overlap start, end. The list is used to make in-place - * changes that fill out the numa_meminfo memblks. - */ - for (int i = 0; i < mi->nr_blks; i++) { - struct numa_memblk *bi = &mi->blk[i]; - - if (memblock_addrs_overlap(start, end - start, bi->start, - bi->end - bi->start)) { - blk[count] = &mi->blk[i]; - count++; - } - } - if (!count) - return NUMA_NO_MEMBLK; - - /* Sort the list of pointers in memblk->start order */ - sort(&blk[0], count, sizeof(blk[0]), cmp_memblk, NULL); - - /* Make sure the first/last memblks include start/end */ - blk[0]->start = min(blk[0]->start, start); - blk[count - 1]->end = max(blk[count - 1]->end, end); - - /* - * Fill any gaps by tracking the previous memblks - * end address and backfilling to it if needed. - */ - prev_end = blk[0]->end; - for (int i = 1; i < count; i++) { - struct numa_memblk *curr = blk[i]; - - if (prev_end >= curr->start) { - if (prev_end < curr->end) - prev_end = curr->end; - } else { - curr->start = prev_end; - prev_end = curr->end; - } - } - return 0; -} diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c index 235f8a4eb2fa..33610026b7a3 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/arch/x86/mm/numa_emulation.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "numa_internal.h" diff --git a/arch/x86/mm/numa_internal.h b/arch/x86/mm/numa_internal.h index 86860f279662..a51229a2f5af 100644 --- a/arch/x86/mm/numa_internal.h +++ b/arch/x86/mm/numa_internal.h @@ -5,23 +5,12 @@ #include #include -struct numa_memblk { - u64 start; - u64 end; - int nid; -}; - -struct numa_meminfo { - int nr_blks; - struct numa_memblk blk[NR_NODE_MEMBLKS]; -}; - -void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi); -int __init numa_cleanup_meminfo(struct numa_meminfo *mi); void __init numa_reset_distance(void); void __init x86_numa_init(void); +struct numa_meminfo; + #ifdef CONFIG_NUMA_EMU void __init numa_emulation(struct numa_meminfo *numa_meminfo, int numa_dist_cnt); diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c index 44f91f2c6c5d..bec0dcd1f9c3 100644 --- a/drivers/acpi/numa/srat.c +++ b/drivers/acpi/numa/srat.c @@ -17,6 +17,7 @@ #include #include #include +#include static nodemask_t nodes_found_map = NODE_MASK_NONE; diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c index 5949829a1b00..838747e319a2 100644 --- a/drivers/of/of_numa.c +++ b/drivers/of/of_numa.c @@ -10,6 +10,7 @@ #include #include #include +#include #include diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h new file mode 100644 index 000000000000..6981cf97d2c9 --- /dev/null +++ b/include/linux/numa_memblks.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NUMA_MEMBLKS_H +#define __NUMA_MEMBLKS_H + +#ifdef CONFIG_NUMA_MEMBLKS +#include + +#define NR_NODE_MEMBLKS (MAX_NUMNODES * 2) + +struct numa_memblk { + u64 start; + u64 end; + int nid; +}; + +struct numa_meminfo { + int nr_blks; + struct numa_memblk blk[NR_NODE_MEMBLKS]; +}; + +extern struct numa_meminfo numa_meminfo __initdata_or_meminfo; +extern struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; + +int __init numa_add_memblk(int nodeid, u64 start, u64 end); +void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi); + +int __init numa_cleanup_meminfo(struct numa_meminfo *mi); +int __init numa_register_meminfo(struct numa_meminfo *mi); + +void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, + const struct numa_meminfo *mi); + +#endif /* CONFIG_NUMA_MEMBLKS */ + +#endif /* __NUMA_MEMBLKS_H */ diff --git a/mm/Kconfig b/mm/Kconfig index b72e7d040f78..dc5912d29ed5 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1263,6 +1263,9 @@ config IOMMU_MM_DATA config EXECMEM bool +config NUMA_MEMBLKS + bool + source "mm/damon/Kconfig" endmenu diff --git a/mm/Makefile b/mm/Makefile index 4e668be85f0b..e3fac7efd880 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -142,3 +142,4 @@ obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o obj-$(CONFIG_EXECMEM) += execmem.o obj-$(CONFIG_NUMA) += numa.o +obj-$(CONFIG_NUMA_MEMBLKS) += numa_memblks.o diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c new file mode 100644 index 000000000000..72f191a94c66 --- /dev/null +++ b/mm/numa_memblks.c @@ -0,0 +1,385 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include +#include +#include + +nodemask_t numa_nodes_parsed __initdata; + +struct numa_meminfo numa_meminfo __initdata_or_meminfo; +struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; + +static int __init numa_add_memblk_to(int nid, u64 start, u64 end, + struct numa_meminfo *mi) +{ + /* ignore zero length blks */ + if (start == end) + return 0; + + /* whine about and ignore invalid blks */ + if (start > end || nid < 0 || nid >= MAX_NUMNODES) { + pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n", + nid, start, end - 1); + return 0; + } + + if (mi->nr_blks >= NR_NODE_MEMBLKS) { + pr_err("too many memblk ranges\n"); + return -EINVAL; + } + + mi->blk[mi->nr_blks].start = start; + mi->blk[mi->nr_blks].end = end; + mi->blk[mi->nr_blks].nid = nid; + mi->nr_blks++; + return 0; +} + +/** + * numa_remove_memblk_from - Remove one numa_memblk from a numa_meminfo + * @idx: Index of memblk to remove + * @mi: numa_meminfo to remove memblk from + * + * Remove @idx'th numa_memblk from @mi by shifting @mi->blk[] and + * decrementing @mi->nr_blks. + */ +void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi) +{ + mi->nr_blks--; + memmove(&mi->blk[idx], &mi->blk[idx + 1], + (mi->nr_blks - idx) * sizeof(mi->blk[0])); +} + +/** + * numa_move_tail_memblk - Move a numa_memblk from one numa_meminfo to another + * @dst: numa_meminfo to append block to + * @idx: Index of memblk to remove + * @src: numa_meminfo to remove memblk from + */ +static void __init numa_move_tail_memblk(struct numa_meminfo *dst, int idx, + struct numa_meminfo *src) +{ + dst->blk[dst->nr_blks++] = src->blk[idx]; + numa_remove_memblk_from(idx, src); +} + +/** + * numa_add_memblk - Add one numa_memblk to numa_meminfo + * @nid: NUMA node ID of the new memblk + * @start: Start address of the new memblk + * @end: End address of the new memblk + * + * Add a new memblk to the default numa_meminfo. + * + * RETURNS: + * 0 on success, -errno on failure. + */ +int __init numa_add_memblk(int nid, u64 start, u64 end) +{ + return numa_add_memblk_to(nid, start, end, &numa_meminfo); +} + +/** + * numa_cleanup_meminfo - Cleanup a numa_meminfo + * @mi: numa_meminfo to clean up + * + * Sanitize @mi by merging and removing unnecessary memblks. Also check for + * conflicts and clear unused memblks. + * + * RETURNS: + * 0 on success, -errno on failure. + */ +int __init numa_cleanup_meminfo(struct numa_meminfo *mi) +{ + const u64 low = 0; + const u64 high = PFN_PHYS(max_pfn); + int i, j, k; + + /* first, trim all entries */ + for (i = 0; i < mi->nr_blks; i++) { + struct numa_memblk *bi = &mi->blk[i]; + + /* move / save reserved memory ranges */ + if (!memblock_overlaps_region(&memblock.memory, + bi->start, bi->end - bi->start)) { + numa_move_tail_memblk(&numa_reserved_meminfo, i--, mi); + continue; + } + + /* make sure all non-reserved blocks are inside the limits */ + bi->start = max(bi->start, low); + + /* preserve info for non-RAM areas above 'max_pfn': */ + if (bi->end > high) { + numa_add_memblk_to(bi->nid, high, bi->end, + &numa_reserved_meminfo); + bi->end = high; + } + + /* and there's no empty block */ + if (bi->start >= bi->end) + numa_remove_memblk_from(i--, mi); + } + + /* merge neighboring / overlapping entries */ + for (i = 0; i < mi->nr_blks; i++) { + struct numa_memblk *bi = &mi->blk[i]; + + for (j = i + 1; j < mi->nr_blks; j++) { + struct numa_memblk *bj = &mi->blk[j]; + u64 start, end; + + /* + * See whether there are overlapping blocks. Whine + * about but allow overlaps of the same nid. They + * will be merged below. + */ + if (bi->end > bj->start && bi->start < bj->end) { + if (bi->nid != bj->nid) { + pr_err("node %d [mem %#010Lx-%#010Lx] overlaps with node %d [mem %#010Lx-%#010Lx]\n", + bi->nid, bi->start, bi->end - 1, + bj->nid, bj->start, bj->end - 1); + return -EINVAL; + } + pr_warn("Warning: node %d [mem %#010Lx-%#010Lx] overlaps with itself [mem %#010Lx-%#010Lx]\n", + bi->nid, bi->start, bi->end - 1, + bj->start, bj->end - 1); + } + + /* + * Join together blocks on the same node, holes + * between which don't overlap with memory on other + * nodes. + */ + if (bi->nid != bj->nid) + continue; + start = min(bi->start, bj->start); + end = max(bi->end, bj->end); + for (k = 0; k < mi->nr_blks; k++) { + struct numa_memblk *bk = &mi->blk[k]; + + if (bi->nid == bk->nid) + continue; + if (start < bk->end && end > bk->start) + break; + } + if (k < mi->nr_blks) + continue; + pr_info("NUMA: Node %d [mem %#010Lx-%#010Lx] + [mem %#010Lx-%#010Lx] -> [mem %#010Lx-%#010Lx]\n", + bi->nid, bi->start, bi->end - 1, bj->start, + bj->end - 1, start, end - 1); + bi->start = start; + bi->end = end; + numa_remove_memblk_from(j--, mi); + } + } + + /* clear unused ones */ + for (i = mi->nr_blks; i < ARRAY_SIZE(mi->blk); i++) { + mi->blk[i].start = mi->blk[i].end = 0; + mi->blk[i].nid = NUMA_NO_NODE; + } + + return 0; +} + +/* + * Set nodes, which have memory in @mi, in *@nodemask. + */ +void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, + const struct numa_meminfo *mi) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(mi->blk); i++) + if (mi->blk[i].start != mi->blk[i].end && + mi->blk[i].nid != NUMA_NO_NODE) + node_set(mi->blk[i].nid, *nodemask); +} + +/* + * Mark all currently memblock-reserved physical memory (which covers the + * kernel's own memory ranges) as hot-unswappable. + */ +static void __init numa_clear_kernel_node_hotplug(void) +{ + nodemask_t reserved_nodemask = NODE_MASK_NONE; + struct memblock_region *mb_region; + int i; + + /* + * We have to do some preprocessing of memblock regions, to + * make them suitable for reservation. + * + * At this time, all memory regions reserved by memblock are + * used by the kernel, but those regions are not split up + * along node boundaries yet, and don't necessarily have their + * node ID set yet either. + * + * So iterate over all parsed memory blocks and use those ranges to + * set the nid in memblock.reserved. This will split up the + * memblock regions along node boundaries and will set the node IDs + * as well. + */ + for (i = 0; i < numa_meminfo.nr_blks; i++) { + struct numa_memblk *mb = numa_meminfo.blk + i; + int ret; + + ret = memblock_set_node(mb->start, mb->end - mb->start, + &memblock.reserved, mb->nid); + WARN_ON_ONCE(ret); + } + + /* + * Now go over all reserved memblock regions, to construct a + * node mask of all kernel reserved memory areas. + * + * [ Note, when booting with mem=nn[kMG] or in a kdump kernel, + * numa_meminfo might not include all memblock.reserved + * memory ranges, because quirks such as trim_snb_memory() + * reserve specific pages for Sandy Bridge graphics. ] + */ + for_each_reserved_mem_region(mb_region) { + int nid = memblock_get_region_node(mb_region); + + if (nid != MAX_NUMNODES) + node_set(nid, reserved_nodemask); + } + + /* + * Finally, clear the MEMBLOCK_HOTPLUG flag for all memory + * belonging to the reserved node mask. + * + * Note that this will include memory regions that reside + * on nodes that contain kernel memory - entire nodes + * become hot-unpluggable: + */ + for (i = 0; i < numa_meminfo.nr_blks; i++) { + struct numa_memblk *mb = numa_meminfo.blk + i; + + if (!node_isset(mb->nid, reserved_nodemask)) + continue; + + memblock_clear_hotplug(mb->start, mb->end - mb->start); + } +} + +int __init numa_register_meminfo(struct numa_meminfo *mi) +{ + int i; + + /* Account for nodes with cpus and no memory */ + node_possible_map = numa_nodes_parsed; + numa_nodemask_from_meminfo(&node_possible_map, mi); + if (WARN_ON(nodes_empty(node_possible_map))) + return -EINVAL; + + for (i = 0; i < mi->nr_blks; i++) { + struct numa_memblk *mb = &mi->blk[i]; + + memblock_set_node(mb->start, mb->end - mb->start, + &memblock.memory, mb->nid); + } + + /* + * At very early time, the kernel have to use some memory such as + * loading the kernel image. We cannot prevent this anyway. So any + * node the kernel resides in should be un-hotpluggable. + * + * And when we come here, alloc node data won't fail. + */ + numa_clear_kernel_node_hotplug(); + + /* + * If sections array is gonna be used for pfn -> nid mapping, check + * whether its granularity is fine enough. + */ + if (IS_ENABLED(NODE_NOT_IN_PAGE_FLAGS)) { + unsigned long pfn_align = node_map_pfn_alignment(); + + if (pfn_align && pfn_align < PAGES_PER_SECTION) { + pr_warn("Node alignment %LuMB < min %LuMB, rejecting NUMA config\n", + PFN_PHYS(pfn_align) >> 20, + PFN_PHYS(PAGES_PER_SECTION) >> 20); + return -EINVAL; + } + } + + return 0; +} + +static int __init cmp_memblk(const void *a, const void *b) +{ + const struct numa_memblk *ma = *(const struct numa_memblk **)a; + const struct numa_memblk *mb = *(const struct numa_memblk **)b; + + return (ma->start > mb->start) - (ma->start < mb->start); +} + +static struct numa_memblk *numa_memblk_list[NR_NODE_MEMBLKS] __initdata; + +/** + * numa_fill_memblks - Fill gaps in numa_meminfo memblks + * @start: address to begin fill + * @end: address to end fill + * + * Find and extend numa_meminfo memblks to cover the physical + * address range @start-@end + * + * RETURNS: + * 0 : Success + * NUMA_NO_MEMBLK : No memblks exist in address range @start-@end + */ + +int __init numa_fill_memblks(u64 start, u64 end) +{ + struct numa_memblk **blk = &numa_memblk_list[0]; + struct numa_meminfo *mi = &numa_meminfo; + int count = 0; + u64 prev_end; + + /* + * Create a list of pointers to numa_meminfo memblks that + * overlap start, end. The list is used to make in-place + * changes that fill out the numa_meminfo memblks. + */ + for (int i = 0; i < mi->nr_blks; i++) { + struct numa_memblk *bi = &mi->blk[i]; + + if (memblock_addrs_overlap(start, end - start, bi->start, + bi->end - bi->start)) { + blk[count] = &mi->blk[i]; + count++; + } + } + if (!count) + return NUMA_NO_MEMBLK; + + /* Sort the list of pointers in memblk->start order */ + sort(&blk[0], count, sizeof(blk[0]), cmp_memblk, NULL); + + /* Make sure the first/last memblks include start/end */ + blk[0]->start = min(blk[0]->start, start); + blk[count - 1]->end = max(blk[count - 1]->end, end); + + /* + * Fill any gaps by tracking the previous memblks + * end address and backfilling to it if needed. + */ + prev_end = blk[0]->end; + for (int i = 1; i < count; i++) { + struct numa_memblk *curr = blk[i]; + + if (prev_end >= curr->start) { + if (prev_end < curr->end) + prev_end = curr->end; + } else { + curr->start = prev_end; + prev_end = curr->end; + } + } + return 0; +} From patchwork Thu Aug 1 06:08:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749751 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 35BE4C3DA64 for ; Thu, 1 Aug 2024 06:12:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7AF46B00B5; Thu, 1 Aug 2024 02:12:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C06BF6B00B6; Thu, 1 Aug 2024 02:12:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A569D6B00B7; Thu, 1 Aug 2024 02:12:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 83A736B00B5 for ; Thu, 1 Aug 2024 02:12:34 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 40CA71408C3 for ; Thu, 1 Aug 2024 06:12:34 +0000 (UTC) X-FDA: 82402657428.21.4FFF938 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf19.hostedemail.com (Postfix) with ESMTP id EEEF81A0015 for ; Thu, 1 Aug 2024 06:12:31 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hc6uVGpe; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492710; a=rsa-sha256; cv=none; b=regRppU/N5uzZ17zkkFrJWs0ExdW8xlCNWBtBJGkVfinuUt6c2D86szMnRlyLR8CNk4twq SIeJ8qRhm/sIYVnxAHaXz5N5p8VkIsPQv0+pct4EWUnRaQ0eCyWvOBlJvsIytkSKLu5ij4 lWv3UObPlRVxeVlayp/PcWr+rHgS180= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hc6uVGpe; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492710; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H9Z9sILq7XZ+U8gu+54pE7hQAG486x2DjNUJMHhbWN8=; b=hgMkyIhfD+UG96rPJU5RzlaL2qx0zdEUQrVkxPntDno1fweM5kgkq8JRBPmJGNaFKlgWWS q5iH78MISUDTFT9btBP3fFTQGNA47h5sgPqJhEojjP1gsRnuthzGKBca7So0t2RbPh6oK0 3Clsp0FEKSV76Aecu3Y5xED+h7HbAO0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 6731CCE1805; Thu, 1 Aug 2024 06:12:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFFDBC4AF0E; Thu, 1 Aug 2024 06:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492737; bh=6A0wIF55cySeIy8NiLF4qmp7wlH9rgdcaWMh1AJbYRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hc6uVGpecAI1zFcYZyBHCN2s/v1sSFhd1thfLQmuesBa3xOXeuBfexTBcgntspCRH dXB1SchKNuC8bKQlbAwfjDcR/i/R9FYc5TJ5kLWs9fy5hJuglptCZXHz4KfwCqVMn/ D3z5FascdFszO7vt9JCmOzaNHDE9uQHhAt2CzNYc06cq0vf5j/lF1yhV/JfQo9cJa5 snhcqRtI22STgHPejW0r2nk5E2leCyeVNpvm4LKvCrY9mJm5mDm1kOwSvp/LHnuPQB MnCCd+ENB07aC4pEeiqaTkovNCpkidgZsG8teItIZxO7yw7vhFSvMA+BXQz9dveoyT 3yq60hFkjkr8A== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 18/26] mm: move numa_distance and related code from x86 to numa_memblks Date: Thu, 1 Aug 2024 09:08:18 +0300 Message-ID: <20240801060826.559858-19-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: EEEF81A0015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: chfdd6na3ij9y6rr9u49x8f3pgou3p9t X-HE-Tag: 1722492751-203628 X-HE-Meta: U2FsdGVkX1/xjxxGsyPsTt9IstCSrT7BrCjY7wCsurkWLnwRyK26zmCxLXjv7dzD5nCRPkCqYxpnEiLUZq3Q13fdtJZI4tOOsm/H8ylgtHObhKPvG5wz+txyy0JWm7s3dJSWxNuxluD1G13Snsu6Y0aDRA0M15uUm0U5ILDhncBxH7GURal1x4z05kEDMUTilHVTf39M21/aZrZjJIF8CWSFOClXVazKYgs8eNbeu0ajVmIxJLuPp5UEiCfUoQDxo1lnTKvB40EVVLu98u5yFBw1SvHT8FZuljKtGnYBD1lNwNAXhVK6UPHJQJijbEyK+7G5ypKJSnIiMv0yMemek30Q7edCs9EaFOt6y2BeRUrPpst9ZNLFP2evCt6bPDylqyTewpMWWbrq9pL/JU0J7VAn838vNrmHzVqlaDUrDgc/VUrAC8FW0zYmp7ICM7+y/njNZOKyDru70hq7LF4VZGuhGaRCmO+P3mSGankeb1jdu6LNnRwzx8z87nXGts0g68XY5vv17UtxFw1gywY5zawkDPjYMFGTfHymCoK+Evhcbo13OpVhq2k3SHqpz6Ufesd/6Ot1PVojMpXPSn5H+yxGCCv+Ky7qU6Pj/xSErrwQnipzQzIt5+mAdew7V9kVCymthOOq824ojXPqj3OY8OYYaKXrAgVMjO8mp/mzIIhLgntuq2rxUoTv9Q0ATpEQMHslORtwbzot31CHBW8tgAJYQaqzYWHWniBHKHu3jrR6mAMyFJv+xMZSPYM1Z5B9lNbmP7ZE5rvsyBI12EsdZtYTfA4R7XfMnFLK3M+dfhnWnwvsmbDdaT9UmMP9ZOi8AesEdoSEzWN9axn5Rt28p54JgwnwqOttmv0rRddsXspHbxVXS8kblJlsLBA1L9A1aY8MnSjVa0GsPj28jbWQbgFLbaemQMoP+2qziKc5twIahrrQLYjAXnP7Vn7v/pSB8G0RsbiXdIOLIIdwkNN czsjKwn/ PW4mf5k6oTX+YQE7HPe/P5qIeK6WAx/akCG1mtVcrI5JMxZoNfajVebLH6MuONP7bANGKxUMZatyeacPZl2mCy1nRTmP42QaY9/aNXwVdCVVQP9CLyQtJBE8huo6dW6oreDp0q3cYkD4TVidSOFDV4539voGaH83EkQiVS0u24284OwvULz2aHWSz7QD6Pac9yOzdc+ERodO52RyF6e8DhrBzL6hkFG6Z19XIYis85v74G7btGFCA76P4kIYVZ+Rn0gwOpiqfSDcEnz31E5Jr57YRKNRPbzWnFSfDL/Ebzldjsd5jK9yZat9tCjlLKmNLwya7QTGJWPepK19/Rnm7FO/w+D2fPxBzTHdk 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: From: "Mike Rapoport (Microsoft)" Move code dealing with numa_distance array from arch/x86 to mm/numa_memblks.c This code will be later reused by arch_numa. No functional changes. Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/x86/include/asm/numa.h | 2 - arch/x86/mm/numa.c | 104 ----------------------------------- arch/x86/mm/numa_internal.h | 2 - include/linux/numa_memblks.h | 4 ++ mm/numa_memblks.c | 104 +++++++++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+), 108 deletions(-) diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 6e9a50bf03d4..203100500f24 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -23,8 +23,6 @@ extern int numa_off; extern s16 __apicid_to_node[MAX_LOCAL_APIC]; extern nodemask_t numa_nodes_parsed __initdata; -extern void __init numa_set_distance(int from, int to, int distance); - static inline void set_apicid_to_node(int apicid, s16 node) { __apicid_to_node[apicid] = node; diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 6874d5650b4d..8eb15578625e 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -24,9 +24,6 @@ int numa_off; -static int numa_distance_cnt; -static u8 *numa_distance; - static __init int numa_setup(char *opt) { if (!opt) @@ -118,107 +115,6 @@ void __init setup_node_to_cpumask_map(void) pr_debug("Node to cpumask map for %u nodes\n", nr_node_ids); } -/** - * numa_reset_distance - Reset NUMA distance table - * - * The current table is freed. The next numa_set_distance() call will - * create a new one. - */ -void __init numa_reset_distance(void) -{ - size_t size = numa_distance_cnt * numa_distance_cnt * sizeof(numa_distance[0]); - - /* numa_distance could be 1LU marking allocation failure, test cnt */ - if (numa_distance_cnt) - memblock_free(numa_distance, size); - numa_distance_cnt = 0; - numa_distance = NULL; /* enable table creation */ -} - -static int __init numa_alloc_distance(void) -{ - nodemask_t nodes_parsed; - size_t size; - int i, j, cnt = 0; - - /* size the new table and allocate it */ - nodes_parsed = numa_nodes_parsed; - numa_nodemask_from_meminfo(&nodes_parsed, &numa_meminfo); - - for_each_node_mask(i, nodes_parsed) - cnt = i; - cnt++; - size = cnt * cnt * sizeof(numa_distance[0]); - - numa_distance = memblock_alloc(size, PAGE_SIZE); - if (!numa_distance) { - pr_warn("Warning: can't allocate distance table!\n"); - /* don't retry until explicitly reset */ - numa_distance = (void *)1LU; - return -ENOMEM; - } - - numa_distance_cnt = cnt; - - /* fill with the default distances */ - for (i = 0; i < cnt; i++) - for (j = 0; j < cnt; j++) - numa_distance[i * cnt + j] = i == j ? - LOCAL_DISTANCE : REMOTE_DISTANCE; - printk(KERN_DEBUG "NUMA: Initialized distance table, cnt=%d\n", cnt); - - return 0; -} - -/** - * numa_set_distance - Set NUMA distance from one NUMA to another - * @from: the 'from' node to set distance - * @to: the 'to' node to set distance - * @distance: NUMA distance - * - * Set the distance from node @from to @to to @distance. If distance table - * doesn't exist, one which is large enough to accommodate all the currently - * known nodes will be created. - * - * If such table cannot be allocated, a warning is printed and further - * calls are ignored until the distance table is reset with - * numa_reset_distance(). - * - * If @from or @to is higher than the highest known node or lower than zero - * at the time of table creation or @distance doesn't make sense, the call - * is ignored. - * This is to allow simplification of specific NUMA config implementations. - */ -void __init numa_set_distance(int from, int to, int distance) -{ - if (!numa_distance && numa_alloc_distance() < 0) - return; - - if (from >= numa_distance_cnt || to >= numa_distance_cnt || - from < 0 || to < 0) { - pr_warn_once("Warning: node ids are out of bound, from=%d to=%d distance=%d\n", - from, to, distance); - return; - } - - if ((u8)distance != distance || - (from == to && distance != LOCAL_DISTANCE)) { - pr_warn_once("Warning: invalid distance parameter, from=%d to=%d distance=%d\n", - from, to, distance); - return; - } - - numa_distance[from * numa_distance_cnt + to] = distance; -} - -int __node_distance(int from, int to) -{ - if (from >= numa_distance_cnt || to >= numa_distance_cnt) - return from == to ? LOCAL_DISTANCE : REMOTE_DISTANCE; - return numa_distance[from * numa_distance_cnt + to]; -} -EXPORT_SYMBOL(__node_distance); - static int __init numa_register_memblks(struct numa_meminfo *mi) { int nid, err; diff --git a/arch/x86/mm/numa_internal.h b/arch/x86/mm/numa_internal.h index a51229a2f5af..249e3aaeadce 100644 --- a/arch/x86/mm/numa_internal.h +++ b/arch/x86/mm/numa_internal.h @@ -5,8 +5,6 @@ #include #include -void __init numa_reset_distance(void); - void __init x86_numa_init(void); struct numa_meminfo; diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h index 6981cf97d2c9..968a590535ac 100644 --- a/include/linux/numa_memblks.h +++ b/include/linux/numa_memblks.h @@ -7,6 +7,10 @@ #define NR_NODE_MEMBLKS (MAX_NUMNODES * 2) +extern int numa_distance_cnt; +void __init numa_set_distance(int from, int to, int distance); +void __init numa_reset_distance(void); + struct numa_memblk { u64 start; u64 end; diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index 72f191a94c66..e3c3519725d4 100644 --- a/mm/numa_memblks.c +++ b/mm/numa_memblks.c @@ -7,11 +7,115 @@ #include #include +int numa_distance_cnt; +static u8 *numa_distance; + nodemask_t numa_nodes_parsed __initdata; struct numa_meminfo numa_meminfo __initdata_or_meminfo; struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; +/** + * numa_reset_distance - Reset NUMA distance table + * + * The current table is freed. The next numa_set_distance() call will + * create a new one. + */ +void __init numa_reset_distance(void) +{ + size_t size = numa_distance_cnt * numa_distance_cnt * sizeof(numa_distance[0]); + + /* numa_distance could be 1LU marking allocation failure, test cnt */ + if (numa_distance_cnt) + memblock_free(numa_distance, size); + numa_distance_cnt = 0; + numa_distance = NULL; /* enable table creation */ +} + +static int __init numa_alloc_distance(void) +{ + nodemask_t nodes_parsed; + size_t size; + int i, j, cnt = 0; + + /* size the new table and allocate it */ + nodes_parsed = numa_nodes_parsed; + numa_nodemask_from_meminfo(&nodes_parsed, &numa_meminfo); + + for_each_node_mask(i, nodes_parsed) + cnt = i; + cnt++; + size = cnt * cnt * sizeof(numa_distance[0]); + + numa_distance = memblock_alloc(size, PAGE_SIZE); + if (!numa_distance) { + pr_warn("Warning: can't allocate distance table!\n"); + /* don't retry until explicitly reset */ + numa_distance = (void *)1LU; + return -ENOMEM; + } + + numa_distance_cnt = cnt; + + /* fill with the default distances */ + for (i = 0; i < cnt; i++) + for (j = 0; j < cnt; j++) + numa_distance[i * cnt + j] = i == j ? + LOCAL_DISTANCE : REMOTE_DISTANCE; + printk(KERN_DEBUG "NUMA: Initialized distance table, cnt=%d\n", cnt); + + return 0; +} + +/** + * numa_set_distance - Set NUMA distance from one NUMA to another + * @from: the 'from' node to set distance + * @to: the 'to' node to set distance + * @distance: NUMA distance + * + * Set the distance from node @from to @to to @distance. If distance table + * doesn't exist, one which is large enough to accommodate all the currently + * known nodes will be created. + * + * If such table cannot be allocated, a warning is printed and further + * calls are ignored until the distance table is reset with + * numa_reset_distance(). + * + * If @from or @to is higher than the highest known node or lower than zero + * at the time of table creation or @distance doesn't make sense, the call + * is ignored. + * This is to allow simplification of specific NUMA config implementations. + */ +void __init numa_set_distance(int from, int to, int distance) +{ + if (!numa_distance && numa_alloc_distance() < 0) + return; + + if (from >= numa_distance_cnt || to >= numa_distance_cnt || + from < 0 || to < 0) { + pr_warn_once("Warning: node ids are out of bound, from=%d to=%d distance=%d\n", + from, to, distance); + return; + } + + if ((u8)distance != distance || + (from == to && distance != LOCAL_DISTANCE)) { + pr_warn_once("Warning: invalid distance parameter, from=%d to=%d distance=%d\n", + from, to, distance); + return; + } + + numa_distance[from * numa_distance_cnt + to] = distance; +} + +int __node_distance(int from, int to) +{ + if (from >= numa_distance_cnt || to >= numa_distance_cnt) + return from == to ? LOCAL_DISTANCE : REMOTE_DISTANCE; + return numa_distance[from * numa_distance_cnt + to]; +} +EXPORT_SYMBOL(__node_distance); + static int __init numa_add_memblk_to(int nid, u64 start, u64 end, struct numa_meminfo *mi) { From patchwork Thu Aug 1 06:08:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749752 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 D8D03C49EA1 for ; Thu, 1 Aug 2024 06:12:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6AF016B00B6; Thu, 1 Aug 2024 02:12:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 644B36B00B7; Thu, 1 Aug 2024 02:12:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43C646B00B8; Thu, 1 Aug 2024 02:12:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 22DBF6B00B6 for ; Thu, 1 Aug 2024 02:12:36 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D770F80863 for ; Thu, 1 Aug 2024 06:12:35 +0000 (UTC) X-FDA: 82402657470.09.370BEEA Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 86AA2100008 for ; Thu, 1 Aug 2024 06:12:33 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=L+wJRNZM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492708; a=rsa-sha256; cv=none; b=C9/gK+S/3IIpwOGhsw1BEa+AZA1au+Tl2KP2amDc2FfPBBG41Nn5TQimkiMnYql3s4Pyym HDDDnWayauUoY6LFlRoFCZn8scxc1B6m8TN7yvYPBhyRBZKUdfIz/mLyTC4YB9eS5YXvUq eQQediiIv6KMUTUP0zZy7hfOqjbpiRE= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=L+wJRNZM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492708; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PBp2eyBMsHignpkyh5YGSOOOlVrJz/eDYNb9FoWPJ8E=; b=W0dmUcOeeK1uXqkWNmkub1wWgqaiLZekuFvRanVY9RKe/z2EbUDEZ+h4ggmjnt/ESvopsM t8ynH3tG5g4Zc91dvk/ZWkeOANapvtQYvcXIlrzh61lc5DtIskmxJ02tIdGNHQCkARxakr siSad+8WqRe2jEKKs70jQwUu+CSGQ0Q= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 6A92BCE1849; Thu, 1 Aug 2024 06:12:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76C5BC4AF0D; Thu, 1 Aug 2024 06:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492749; bh=nydmRjvUm2d1wafFnDPFYAA7CHVPdBf8ubFwxDVp0cs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+wJRNZMTgJr6I6+BoItXEqAuy+SLsAdRKGs6NjGUx4Qt4YJ1R0Lys5OD7cYUzvSO BOO0+AD+yKoq9/KU270Kleyml66/HiOyGPrjMzH9rllhP3WUyWkAPYYXB21YVdnJwT W5DKUVCmky0YMaTD9mZbhN0Yf2Pfp2PA6aiLhCA6EZNdBZ8pI/XFxWsKAtCbKw0pzC xykfAOcMCZwkqv9qvRJo44kWT5Acm5eTeHUbBiGS0S69GTh1zFhk6Dkh4reMVC+WQ2 0IQD6wa3uxShl0BUnXgFG1VYvj6HG3CyO3plcyprTh8TyPqlgAMs25SQRyUM0D7fbU eDYxJPB98EVSQ== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 19/26] mm: introduce numa_emulation Date: Thu, 1 Aug 2024 09:08:19 +0300 Message-ID: <20240801060826.559858-20-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 86AA2100008 X-Stat-Signature: ha4t59dx44adthyu3xzogf6ktx3ctkuo X-Rspam-User: X-HE-Tag: 1722492753-858123 X-HE-Meta: U2FsdGVkX1/DtDUkui0Dnu9i03IsNwRFWXF8s6qFoise58dBBTuZxI2916Zp6auNslm5/7w1gR5R5IapemvAXpTY8aldXl3k7PHreh8Y5KkBSue65F5IEwrOKZvlFOFaogWQgS+AljLEa9vcSue779CozHqkHFuf9R5LhKLXbPTii7btu7upWfweTIc1zt89lpFUE0GvJZ9lJFzPFTNKGA0AvnVVlWLEzHVTPB/eHyO3wUfoyL8ISdiIeAAsGAt15skbR53Rn2MXwEAL9hwEXTFDztCefPXGR4OG3Kyk/Cmsv7xU4U134sg+XXvCbC9myOgcgTgM2k5sL/knCtcqWgP1J3tibZ2qP2Dn04Tf0jgXd701SLm4R5l95P2Js8IW3NnCy1Lay132iF6OqsJUBjKlDsrRkozHd+nAGbY2BZUNQDZb85WLh0JO5AJsTC85gfjX/fDHPLkYSHAY4fd8vr5eYWxwWCcC2EmaDhzjXuftT8iPC8YUvIkh5gIDcwdBwfrtprT+p4uo0GSdWR0mUVtqqLFl0xFJ6Yw9f3GUpUlsgbQHnbhA4q0kmXh82d2OtXJau6gLr2A82lcCrFDUjC4ICiRjZiGAtJOSbE//uxbcX3pgWIPpsfWiSY4293H5/TSSeFnIRLEq8U//pubW+i14BQP5CG1xlwjYSlkJFM2/IEmkZ5+fBBrCTe4V+o5d8ruawKFSPELh+SGAS6gc6k7BWEinqPkmv5G5EUnIyD8ld7pI5vorIb/QRA313m6kHdaaHPJN2kBHLyF/jLXDC7PMzAgWnt8oAEUf3zS+H6nAOVO9cberqN9GnWO2jpP8oo+IYXei4nYK5gh5phs5tLiJXSoBgKocn3OOCnnq/1vfgmiMstN9blgZ6Zko58tp47K93lJWk1BinN8KpeB9WDy3Oom10JZbdTssRQw6ixjnOMLtiKpZYLT1xfqVpUCFKyAz85T69inFiJU2aLM LaiPLRVF sMr2jPlZLGx+F63S0fQKjavMjf6AxcdxnLfntlK/2+r/S0rRQUMvvSMuFYLcHAGTRpk4HfrKW699Sjx9Yq2qCyaA53Za2JfyOXQ2+jkgmNJp0bvvzgrjIsUN7MifnqgQkBWv9/ACfoSyGL7a4R5M+pk60poXjdOyEf59ZdUDMIlbIprF3zej8sHs4xg5YBUojovwzy642xI4hX5cOd4/YNWIRNREeppptAjSFoq3SQwKxltHuAu63SVZvafVxC/OIIjYvXWNhxEEZL2SAOdda6U0zlHmkirPR+yu24ojgLjeWls/M337Jl3ZpcFIf1Hz9Rte7CWILqd6FmdI5JDXg36UnRtF7eT6ERXsM 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: From: "Mike Rapoport (Microsoft)" Move numa_emulation codfrom arch/x86 to mm/numa_emulation.c This code will be later reused by arch_numa. No functional changes. Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Tested-by: Jonathan Cameron --- arch/x86/Kconfig | 8 -------- arch/x86/include/asm/numa.h | 12 ------------ arch/x86/mm/Makefile | 1 - arch/x86/mm/numa_internal.h | 11 ----------- include/linux/numa_memblks.h | 17 +++++++++++++++++ mm/Kconfig | 8 ++++++++ mm/Makefile | 1 + {arch/x86/mm => mm}/numa_emulation.c | 4 +--- 8 files changed, 27 insertions(+), 35 deletions(-) rename {arch/x86/mm => mm}/numa_emulation.c (99%) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 74afb59c6603..acd9745bf2ae 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1600,14 +1600,6 @@ config X86_64_ACPI_NUMA help Enable ACPI SRAT based node topology detection. -config NUMA_EMU - bool "NUMA emulation" - depends on NUMA - help - Enable NUMA emulation. A flat machine will be split - into virtual nodes when booted with "numa=fake=N", where N is the - number of nodes. This is only useful for debugging. - config NODES_SHIFT int "Maximum NUMA Nodes (as a power of 2)" if !MAXSMP range 1 10 diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 203100500f24..5469d7a7c40f 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -65,16 +65,4 @@ static inline void init_gi_nodes(void) { } void debug_cpumask_set_cpu(unsigned int cpu, int node, bool enable); #endif -#ifdef CONFIG_NUMA_EMU -int numa_emu_cmdline(char *str); -void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, - unsigned int nr_emu_nids); -u64 __init numa_emu_dma_end(void); -#else /* CONFIG_NUMA_EMU */ -static inline int numa_emu_cmdline(char *str) -{ - return -EINVAL; -} -#endif /* CONFIG_NUMA_EMU */ - #endif /* _ASM_X86_NUMA_H */ diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index 8d3a00e5c528..690fbf48e853 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile @@ -57,7 +57,6 @@ obj-$(CONFIG_MMIOTRACE_TEST) += testmmiotrace.o obj-$(CONFIG_NUMA) += numa.o numa_$(BITS).o obj-$(CONFIG_AMD_NUMA) += amdtopology.o obj-$(CONFIG_ACPI_NUMA) += srat.o -obj-$(CONFIG_NUMA_EMU) += numa_emulation.o obj-$(CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS) += pkeys.o obj-$(CONFIG_RANDOMIZE_MEMORY) += kaslr.o diff --git a/arch/x86/mm/numa_internal.h b/arch/x86/mm/numa_internal.h index 249e3aaeadce..11e1ff370c10 100644 --- a/arch/x86/mm/numa_internal.h +++ b/arch/x86/mm/numa_internal.h @@ -7,15 +7,4 @@ void __init x86_numa_init(void); -struct numa_meminfo; - -#ifdef CONFIG_NUMA_EMU -void __init numa_emulation(struct numa_meminfo *numa_meminfo, - int numa_dist_cnt); -#else -static inline void numa_emulation(struct numa_meminfo *numa_meminfo, - int numa_dist_cnt) -{ } -#endif - #endif /* __X86_MM_NUMA_INTERNAL_H */ diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h index 968a590535ac..f81f98678074 100644 --- a/include/linux/numa_memblks.h +++ b/include/linux/numa_memblks.h @@ -34,6 +34,23 @@ int __init numa_register_meminfo(struct numa_meminfo *mi); void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, const struct numa_meminfo *mi); +#ifdef CONFIG_NUMA_EMU +int numa_emu_cmdline(char *str); +void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, + unsigned int nr_emu_nids); +u64 __init numa_emu_dma_end(void); +void __init numa_emulation(struct numa_meminfo *numa_meminfo, + int numa_dist_cnt); +#else +static inline void numa_emulation(struct numa_meminfo *numa_meminfo, + int numa_dist_cnt) +{ } +static inline int numa_emu_cmdline(char *str) +{ + return -EINVAL; +} +#endif /* CONFIG_NUMA_EMU */ + #endif /* CONFIG_NUMA_MEMBLKS */ #endif /* __NUMA_MEMBLKS_H */ diff --git a/mm/Kconfig b/mm/Kconfig index dc5912d29ed5..3b466df1d9e2 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1266,6 +1266,14 @@ config EXECMEM config NUMA_MEMBLKS bool +config NUMA_EMU + bool "NUMA emulation" + depends on NUMA_MEMBLKS + help + Enable NUMA emulation. A flat machine will be split + into virtual nodes when booted with "numa=fake=N", where N is the + number of nodes. This is only useful for debugging. + source "mm/damon/Kconfig" endmenu diff --git a/mm/Makefile b/mm/Makefile index e3fac7efd880..75a189cc67ef 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -143,3 +143,4 @@ obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o obj-$(CONFIG_EXECMEM) += execmem.o obj-$(CONFIG_NUMA) += numa.o obj-$(CONFIG_NUMA_MEMBLKS) += numa_memblks.o +obj-$(CONFIG_NUMA_EMU) += numa_emulation.o diff --git a/arch/x86/mm/numa_emulation.c b/mm/numa_emulation.c similarity index 99% rename from arch/x86/mm/numa_emulation.c rename to mm/numa_emulation.c index 33610026b7a3..031fb9961bf7 100644 --- a/arch/x86/mm/numa_emulation.c +++ b/mm/numa_emulation.c @@ -7,9 +7,7 @@ #include #include #include -#include - -#include "numa_internal.h" +#include #define FAKE_NODE_MIN_SIZE ((u64)32 << 20) #define FAKE_NODE_MIN_HASH_MASK (~(FAKE_NODE_MIN_SIZE - 1UL)) From patchwork Thu Aug 1 06:08:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749753 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 AE4A3C3DA64 for ; Thu, 1 Aug 2024 06:12:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F09E6B008A; Thu, 1 Aug 2024 02:12:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3519C6B00A3; Thu, 1 Aug 2024 02:12:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AEB66B00A7; Thu, 1 Aug 2024 02:12:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E45506B008A for ; Thu, 1 Aug 2024 02:12:47 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A20BC1A086E for ; Thu, 1 Aug 2024 06:12:47 +0000 (UTC) X-FDA: 82402657974.30.3BEF294 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 47FDF4001F for ; Thu, 1 Aug 2024 06:12:44 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cM+9PrKx; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492721; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6L11AkWXzvzFvLqi5aeDLEwHRjun9uu1ZDZpDd9A4CM=; b=yyxHiJQIw8kb0JxDZOUQg7H6KCH1hXfdR/eSWQtSCAtxJ0fmAheg012mBIzTYarG5FqOP5 4EnZRNwZR8sPZFGsjLpLtVs58KokYMsdwEGZa8tJJCV/63PvcMmJqCGRtBvKPsu3BnpIa0 EhMv7GPMj/Z7hB+pi42n9heyH3o2aio= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cM+9PrKx; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492721; a=rsa-sha256; cv=none; b=B9zm3hi4FgtH29vNp+l/+5TgT4UALySkiqAFm1Ph0do+NR2LbhT4o7seh+bVzbg10crH9O 9MLhn2Z/14JXY3QH1LGRme2w2728+7TRIMVNhpMfjLILj4J2JluxVQa1FXY355MRRmuZPD fD0ftCpmkHR+7lzd3nyBNSrcFTwDPrs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id EC673CE1802; Thu, 1 Aug 2024 06:12:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AED7C4AF09; Thu, 1 Aug 2024 06:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492761; bh=B9e+Vd7n2gq8wb2Fh7KBYHmuFxFa1foqgAS054Jbgm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cM+9PrKx9YzehJ5LjHBDoW2YtM/B15bwu3McVI62IfdyXscxPeo0HrtLEBaWMjQ5p HIQOodTGXKYIB4eQ5R1NoHMMvwzOP97BZTThg3CMbUj5vQ6cFIyj6EMGhDUFNgOvKu oTOZqCnfajcH/aPpC10wLy4Qc6v2xhpsLDiB3lXsjiVPx9njslGver0boDogOuHWWm d2AaXAMfINeqUYABkdOTthBNZpsQWO6gprMUXNlIQQf/YDvcT8CsvZITx/LyC+F6Xy umjL3iUOG1zg+qLbCCc9lk1wpSl6KSHpF3ZosnJOIR8SqsgJuRBIPE4+tl8qB4n0pc EfT3heZmT2ucg== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 20/26] mm: numa_memblks: introduce numa_memblks_init Date: Thu, 1 Aug 2024 09:08:20 +0300 Message-ID: <20240801060826.559858-21-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: acwcpey4jhcstmfubdriop7mfgxd5sta X-Rspam-User: X-Rspamd-Queue-Id: 47FDF4001F X-Rspamd-Server: rspam02 X-HE-Tag: 1722492764-5291 X-HE-Meta: U2FsdGVkX1+6l3CwDWHbPs2oYYdSYWXGKUhDr9boQHwrBd3UnjfBaJNVHU+LBM6ptETe7LgwkrvdBkknLsswNQD8n7lVuS0OSd+4XaoddUjE3YS2aeyeeqrocWMKxG8sKCI5kakckY2rQtd+9H5gqW82UtjluQgA38tQeaKmgbSfayJK8HQcz2XL/v7yHbUadk81Rv9dLR5XgVMeYWCdmCe09bkJsRIp9NVVOJGTcD274Vzo2q9Im/x54kSr8S+FqUVI7wW5VzVP7lCNd2dxx5PczoaCdLvzfp7CnBcWmrKvI2U0hyWehZFndWByY9DPaND4nKMaPAoBdzXG8adHnHuWMmKIeKxJ43UbtaWxeIu6PgdBwPR/amKpCL7FsxtP5wy5PYqbl4CeL/xqiyUOpLgXhEod0YfyPZyfeb+Eae0YQTy5hjzoYl9fTxaTwXE2xeoit17FBP/Og0TGb5m6+/0i4Oxu2hGMgftVDnVy2ICeclsr84odf1z8LVoKVBTtCIJUI2VmiMsvj4DjwF2OuRAtg+NO2bogVqzYXcGYoaRUZxBcVfWAu2H6aWdCO1+a37W7rA4yc9pOv3uG7OmYCkylTZoVq+vmUDXQndzDDrtLJyX6zccQgCud6NRoARVp5FcqnXB2eFM/EgWMhTFLrzf7YyG/eYwte34UQjnEU135OlaDimHpjm+lOCvkCFN7T3JXVX5SUcsRNR0SlZOyjhIW9AmA7d9bFDk3RePsH8F+QnMCY1GiM+KvrsB3BokenMK+LulSqaoC8DomGJfwif40jN037j2Yu+YPAksVYOLZXHJwkckjujXSTzDUc6r0LN3q87NU+WiLtSZuMwpCfdGzpbzdWb7YueybxGANm9i3fBXFuCoA5iii5pvG3GjrGQJiR7rWbDB0QS+Q0gFV0D8ZNAkNh8Q+ole9m2tFYgLe3RNiUyClOZCFqK5W7VryA5vXaHlzSU4RNfyJWoB hl99O4JH gTqwejuuU2VoaXxouzSMhBlPrqXcZZ+h8nmliXorPxE1L2rFV94XdL+sOr+Zx5XUZw5eHcJSv3foXmOINpEQQPysYQdFD/mw/fIZwdPj4OMVIck5BROIULojR5M1avAelo6mOsti/ln4arcvZQsT8D6tIroUfBtdFADkGSaqabFl8XVf8VINQDnZNZ1+DrpxHAYx0WhPWfGKweM22JjmciSUQU9sezpW/MU5G0icobCTD1EGcGfp+ipEeHDSVKusM2+vAu0a5MrZ+M44O3wKMkuMAweeuvNm0yXVmmxq5w4LOhnIz3Wl+muDVqyoIFP3HVBxQ7Aet1YSClbzxOoNlD8rzU13K2hC/nJvc 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: From: "Mike Rapoport (Microsoft)" Move most of x86::numa_init() to numa_memblks so that the latter will be more self-contained. With this numa_memblk data structures should not be exposed to the architecture specific code. Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/x86/mm/numa.c | 40 ++++------------------------------- include/linux/numa_memblks.h | 3 +++ mm/numa_memblks.c | 41 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 8eb15578625e..16bc703c9272 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -115,13 +115,9 @@ void __init setup_node_to_cpumask_map(void) pr_debug("Node to cpumask map for %u nodes\n", nr_node_ids); } -static int __init numa_register_memblks(struct numa_meminfo *mi) +static int __init numa_register_nodes(void) { - int nid, err; - - err = numa_register_meminfo(mi); - if (err) - return err; + int nid; if (!memblock_validate_numa_coverage(SZ_1M)) return -EINVAL; @@ -171,39 +167,11 @@ static int __init numa_init(int (*init_func)(void)) for (i = 0; i < MAX_LOCAL_APIC; i++) set_apicid_to_node(i, NUMA_NO_NODE); - nodes_clear(numa_nodes_parsed); - nodes_clear(node_possible_map); - nodes_clear(node_online_map); - memset(&numa_meminfo, 0, sizeof(numa_meminfo)); - WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.memory, - NUMA_NO_NODE)); - WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.reserved, - NUMA_NO_NODE)); - /* In case that parsing SRAT failed. */ - WARN_ON(memblock_clear_hotplug(0, ULLONG_MAX)); - numa_reset_distance(); - - ret = init_func(); + ret = numa_memblks_init(init_func, /* memblock_force_top_down */ true); if (ret < 0) return ret; - /* - * We reset memblock back to the top-down direction - * here because if we configured ACPI_NUMA, we have - * parsed SRAT in init_func(). It is ok to have the - * reset here even if we did't configure ACPI_NUMA - * or acpi numa init fails and fallbacks to dummy - * numa init. - */ - memblock_set_bottom_up(false); - - ret = numa_cleanup_meminfo(&numa_meminfo); - if (ret < 0) - return ret; - - numa_emulation(&numa_meminfo, numa_distance_cnt); - - ret = numa_register_memblks(&numa_meminfo); + ret = numa_register_nodes(); if (ret < 0) return ret; diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h index f81f98678074..07381320848f 100644 --- a/include/linux/numa_memblks.h +++ b/include/linux/numa_memblks.h @@ -34,6 +34,9 @@ int __init numa_register_meminfo(struct numa_meminfo *mi); void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, const struct numa_meminfo *mi); +int __init numa_memblks_init(int (*init_func)(void), + bool memblock_force_top_down); + #ifdef CONFIG_NUMA_EMU int numa_emu_cmdline(char *str); void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index e3c3519725d4..7749b6f6b250 100644 --- a/mm/numa_memblks.c +++ b/mm/numa_memblks.c @@ -415,6 +415,47 @@ int __init numa_register_meminfo(struct numa_meminfo *mi) return 0; } +int __init numa_memblks_init(int (*init_func)(void), + bool memblock_force_top_down) +{ + int ret; + + nodes_clear(numa_nodes_parsed); + nodes_clear(node_possible_map); + nodes_clear(node_online_map); + memset(&numa_meminfo, 0, sizeof(numa_meminfo)); + WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.memory, + NUMA_NO_NODE)); + WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.reserved, + NUMA_NO_NODE)); + /* In case that parsing SRAT failed. */ + WARN_ON(memblock_clear_hotplug(0, ULLONG_MAX)); + numa_reset_distance(); + + ret = init_func(); + if (ret < 0) + return ret; + + /* + * We reset memblock back to the top-down direction + * here because if we configured ACPI_NUMA, we have + * parsed SRAT in init_func(). It is ok to have the + * reset here even if we did't configure ACPI_NUMA + * or acpi numa init fails and fallbacks to dummy + * numa init. + */ + if (memblock_force_top_down) + memblock_set_bottom_up(false); + + ret = numa_cleanup_meminfo(&numa_meminfo); + if (ret < 0) + return ret; + + numa_emulation(&numa_meminfo, numa_distance_cnt); + + return numa_register_meminfo(&numa_meminfo); +} + static int __init cmp_memblk(const void *a, const void *b) { const struct numa_memblk *ma = *(const struct numa_memblk **)a; From patchwork Thu Aug 1 06:08:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749754 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 67E2DC3DA64 for ; Thu, 1 Aug 2024 06:12:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D18946B00AF; Thu, 1 Aug 2024 02:12:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA19D6B00BB; Thu, 1 Aug 2024 02:12:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF2DF6B00BC; Thu, 1 Aug 2024 02:12:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8B6346B00AF for ; Thu, 1 Aug 2024 02:12:55 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 42CF2408D8 for ; Thu, 1 Aug 2024 06:12:55 +0000 (UTC) X-FDA: 82402658310.24.C653234 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 9AAAB40018 for ; Thu, 1 Aug 2024 06:12:53 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="QHe/KHJa"; spf=pass (imf12.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492718; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=z4Xdi1PMf/vF/SAAM+e1Mcw/Wz7lRvNDJld1jWKVp1o=; b=NX0d9lLHkPf136o/qmzaYtuZAbzPRYZ91QRZqD3EYXpg/jdgqdCcUe4mcwOuiwzAWSM7EP n1Hwh1dSl4XOelNT0IeODVt7Vf7vlhhtQU6RnppZBZRnYp59+GjLQPbnVLiEMiWdpbB24i zbHFTrz00Qn1laEFHvq0Nu+elM3U9d8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492718; a=rsa-sha256; cv=none; b=a1Qjk1gfArDKpX8tCXTBH/A5581O1fAGfSWluPywuga7hD1eCL9hlJQzeejVMu9GeoDWjB LP5hxwFk+bCAsary7o+S+j7l3BE1Gm++d/gyEk122mKxrir5y4NbMJgWKH/D26aVEz5zVj bWeBeMePaDe817F++bFyRKbX849QktY= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="QHe/KHJa"; spf=pass (imf12.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DCF196140C; Thu, 1 Aug 2024 06:12:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 927C8C4AF12; Thu, 1 Aug 2024 06:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492772; bh=Kiw+lzJCjsSsbhtIZxwLgv2SD/DXB55tpwh9QzdUDmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QHe/KHJazM0v/nplwG5s3+ZVp/L2jgEbi1dAA7kI36bQHQxVX67pLYADN6L10kJez yB/53N0Q6hEdBC2SFahsylWI7nBaESLR3DQq2JsYEHiBImr934xtOyvm4Z+SfO8iQG LCkv8QIpMxgOYCqnzXm2hQ+RmGiMgU9Fy/sfAbU/d8mtdH0DJnmOPORi9XAhK9MrE4 lmeVablRXPU4gYsaPkvkeWWr/GbW4Dcgn54JwPrphIWIvmniKt3v3q5RtSdrip1m1m FhwTi4fe9PMGKjpCUukzkntyFCkMvHWoPk0cZQKJm2g1mBaf93NkCaLD4VAP1UMVr4 iTlOfkJLht9Zw== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 21/26] mm: numa_memblks: make several functions and variables static Date: Thu, 1 Aug 2024 09:08:21 +0300 Message-ID: <20240801060826.559858-22-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9AAAB40018 X-Stat-Signature: 9enqxip468h61cmoaayotmzjnrgdamp1 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722492773-251242 X-HE-Meta: U2FsdGVkX1/NgTCq5rwwPJOYgo2igoZy7v2uMvQOwUxco4RH6SMVeCfvA9quuBCXpFZTbSzSbzhRH/H2ELNh2FfIFyOQ5FoQdsRRL7ic41a+qVW4m9vLEvdrcO6eyP0NdO/EkSrM/RfOChtc0a+aRMbKA96qJQHnx9NA26nyeM0UPbdmka5vp2XbFI0bhC+oaFk8f4Ia0koL51djyVVJaYrw6FfH0DWYJwA7iIQenPfsJi+KLwlSgRa87UQ6oWfi3CGc/cMnCpG0Uw6W6492m5abX6iSjYSIVHijzzarYuGYc3APZh00nGgSJLe0YD9RimVOe3filHeCPbCGGySOMFuEIW8wCzUpXadG3NNgxWi/HebHuzPdkqh7Hmrw5qi71AESDPxo3Eq3y4pQQ98VDdO6AOnp0yEN1FKbMKQjhk9w9eh4VsOab54F1NsRTqhJBF0mrYBiOtCwLnU0/ZBBax9LotWPpHC8+mHYM6tayH7hQnW+bJ4VBWjsO5pEnJxBGLmh/xpwXJIM73hYrIcXvKm1biRae9hFiiHnhRUiM4D8CfQvHX9bVfVwX/HvvwbEhdCq0njOkNpUGvgNSY3LeYCkoRMz3e6Q283xYVZkz9nvUGX/XgLpnTHPULbbG6cZsIzXUcavY/+vPwaZNpfTF5pIOurlPKlDy+qCny8hESixfWWi9UF6d39glmymxfHkDayfB5c5nGSlmL8o2DxXLqTgPPT4ySHUnv8ESSvrKX0pekEL4VquLtqTW40AKN5jQ8S6YlAaeHn7juvB6CaAOeqHZZL6ps0pEH5aoJtTFD1mnU2TTviZC0yzkslIf0Ixaq5lZfdZZyK1BJe3an8LVj/eB5s3DSyTZwYYbaLDhDioW/Cv9ScRA8yW8WMm+8gnBVNWobmDjC6Ou2v45MePgiEb1bGxWzztNjGDeL91PGTLIGePdOe/i+MbtXbuahvPLrV0n7FuvbFlGrmJedz HwnfY1JY Smlq5cDyl11DXz227mCBA9yPLs6gLnAStEnvp0UuJacgh1iMs8ASOENFD51FkIUXxn99d5C1QTzr8jEYNZ4FvNofD4+xdr77FjMvMyKU/nwppsb8kg6d5Oktv/tGe1iXobmpxrUzm9NXIzW1Ltqd1MfLZ/3VxwMA2eusxL+zJQSzd7QuIa4kbEJEFUSoGPeSlr3XKeGKCag0thOUPEsjmEpHwaatYKaankvyQqP4wXAqnhKXtHdAO/YmHqJ4QUtG1nVEfXeV6/Ayw5Ox2w3jbvStu8tE69CUWngplzR/bDHC4pafR2w0LTTl0C2l1ZBzB26OKdC7S3/31jcMqxXwbvlCNICEOUiI+j50u 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: From: "Mike Rapoport (Microsoft)" Make functions and variables that are exclusively used by numa_memblks static. Move numa_nodemask_from_meminfo() before its callers to avoid forward declaration. Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- include/linux/numa_memblks.h | 8 -------- mm/numa_memblks.c | 36 ++++++++++++++++++------------------ 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h index 07381320848f..5c6e12ad0b7a 100644 --- a/include/linux/numa_memblks.h +++ b/include/linux/numa_memblks.h @@ -7,7 +7,6 @@ #define NR_NODE_MEMBLKS (MAX_NUMNODES * 2) -extern int numa_distance_cnt; void __init numa_set_distance(int from, int to, int distance); void __init numa_reset_distance(void); @@ -22,17 +21,10 @@ struct numa_meminfo { struct numa_memblk blk[NR_NODE_MEMBLKS]; }; -extern struct numa_meminfo numa_meminfo __initdata_or_meminfo; -extern struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; - int __init numa_add_memblk(int nodeid, u64 start, u64 end); void __init numa_remove_memblk_from(int idx, struct numa_meminfo *mi); int __init numa_cleanup_meminfo(struct numa_meminfo *mi); -int __init numa_register_meminfo(struct numa_meminfo *mi); - -void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, - const struct numa_meminfo *mi); int __init numa_memblks_init(int (*init_func)(void), bool memblock_force_top_down); diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index 7749b6f6b250..e97665a5e8ce 100644 --- a/mm/numa_memblks.c +++ b/mm/numa_memblks.c @@ -7,13 +7,27 @@ #include #include -int numa_distance_cnt; +static int numa_distance_cnt; static u8 *numa_distance; nodemask_t numa_nodes_parsed __initdata; -struct numa_meminfo numa_meminfo __initdata_or_meminfo; -struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; +static struct numa_meminfo numa_meminfo __initdata_or_meminfo; +static struct numa_meminfo numa_reserved_meminfo __initdata_or_meminfo; + +/* + * Set nodes, which have memory in @mi, in *@nodemask. + */ +static void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, + const struct numa_meminfo *mi) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(mi->blk); i++) + if (mi->blk[i].start != mi->blk[i].end && + mi->blk[i].nid != NUMA_NO_NODE) + node_set(mi->blk[i].nid, *nodemask); +} /** * numa_reset_distance - Reset NUMA distance table @@ -290,20 +304,6 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi) return 0; } -/* - * Set nodes, which have memory in @mi, in *@nodemask. - */ -void __init numa_nodemask_from_meminfo(nodemask_t *nodemask, - const struct numa_meminfo *mi) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(mi->blk); i++) - if (mi->blk[i].start != mi->blk[i].end && - mi->blk[i].nid != NUMA_NO_NODE) - node_set(mi->blk[i].nid, *nodemask); -} - /* * Mark all currently memblock-reserved physical memory (which covers the * kernel's own memory ranges) as hot-unswappable. @@ -371,7 +371,7 @@ static void __init numa_clear_kernel_node_hotplug(void) } } -int __init numa_register_meminfo(struct numa_meminfo *mi) +static int __init numa_register_meminfo(struct numa_meminfo *mi) { int i; From patchwork Thu Aug 1 06:08:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749755 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 875E2C3DA64 for ; Thu, 1 Aug 2024 06:13:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 21AC06B0095; Thu, 1 Aug 2024 02:13:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A4666B00BD; Thu, 1 Aug 2024 02:13:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01E856B00BE; Thu, 1 Aug 2024 02:13:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D66306B0095 for ; Thu, 1 Aug 2024 02:13:10 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 93ED2A6301 for ; Thu, 1 Aug 2024 06:13:10 +0000 (UTC) X-FDA: 82402658940.18.33CC42A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf24.hostedemail.com (Postfix) with ESMTP id 5A48618000C for ; Thu, 1 Aug 2024 06:13:07 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Laf97Z1e; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492743; a=rsa-sha256; cv=none; b=bxxMQy0gUYFVa5YfYoHV6VQoL4+pV2KyQ42SWEi/neBhWhH9pTcrlh4Yhp7Wx8SX4UXWLR eZmnZegyR4szz6KEdEz1e0NQ/K3mtYshv7Q5cRKTVttWLqcbzhXEiJFFixZv9bYZkj8QXK wl8arqX79/KA+IGkQ6Bi+DSq/ljDvSw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Laf97Z1e; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of rppt@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492743; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zt29HZs++2acMgTN2nsFuMGC1lkrkHmW15IBWfbwFGQ=; b=Q9winugdlCn4tiyL9F4JAwyhqoW3E0KT9xllaB9Cow4Zi7usecXKQ32poo22/AFeraASiq CoEreWN2MH23KE51Q2wGaAlCEvhll+0BQ7i/GloJs2XJagxMWr1ZSqyAPrv1pCftk/JVFi Z0NPwa4QZMF7NwfY7IiWqxtwCCUd08c= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 11EBBCE1805; Thu, 1 Aug 2024 06:13:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22222C4AF09; Thu, 1 Aug 2024 06:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492784; bh=u0DwIdv5Q0LC3i7GMDCjqhk6wXf4CoZ6Rdfjx53JnRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Laf97Z1e4hcu9PBv68jQasZmlcl44jxPkm5qsqBEaVcHPy1G/5p4hKyAOv+GaZ0cR YzGEBoSsm6ig7pKVD9TjO3YNDG12FuhrWOfM1+LkJPNNGqnc92putV4qJJm07pe0Jk LkllUlfZzz+53zk09otVS6H6hBwgc1BL4Qyegx5TvwtRxCPrtBIksSg00eK9Vzkhyc Ink899LpOi3D7p4U/+xT33YUBQNQq7ixjxSEIEeqox4fLTYDyVmqpNc/IT8slRHXis DjPDz1cL0BiU3e2k2Vtc4UuiwWZ3fpIzM/UbIqLOnh+wePPY4zbYTedpRY4xDGv1r4 +GfsBnftVLYvQ== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 22/26] mm: numa_memblks: use memblock_{start,end}_of_DRAM() when sanitizing meminfo Date: Thu, 1 Aug 2024 09:08:22 +0300 Message-ID: <20240801060826.559858-23-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5A48618000C X-Stat-Signature: sb6oreueb1umrawqcmeg7dtmh6ne16k8 X-Rspam-User: X-HE-Tag: 1722492787-832639 X-HE-Meta: U2FsdGVkX1/esa4+AKedjSpoKjeuqqIzg51UONavvH4dP+iK7i6XHla3TKwEjfIG74tR+S3A+JxY/4+HDhAN7CBKnE5lccDJ0lrngFLddXVL3X5utWwHvGJtS/D5GH+fGkoSScU6f3CLm89mHb9gvP6IVwoQb8ZYiDEJEXJu8NS9P8GLina+D7c3xSOR+Q+gok3CvTq0rWlDdY36vgLnqF9z25QeMKWjG7JAJSW2qE5TvrdCYHIC7c1qZGd7DA1ExdBqiVCOjo4q00BLEameI4hBl5Y0XrfEUZdu6TvALa612VSGu58cGC41HbGY8KIE6dNY3/z8EsMahyh5pMzyL9S8SBZ4umwds6JdhP6oZ4WVEMpeP7BRyKwbtSutEAwjN/1NkwTX4ZkvwKT7EbIi9qjSaFJRh+OpctaTyBlZKKdWqLpJc9TkKcQt1vT+mD9jY48tYctv70nIZffqBhahIdCfPs8UXtBN3CdfzsPsxykUuzgqwNaKWteT8W12KwKj/hcQboVZZgl5G7XsWLaauee5slfjAml5eYHkxGQcSga9lEQqx8x8jJvK7HtxIvEcQ42ZtPXajLg93f2u4xfB9aN9WgAy/e0b338KGGP2S64d3qP+xk2NB7m0YK8/AIVtujwM7HKI75fw/oe19jAt8PjCgZmhpPOy/SnwvvcjH+HKlKaKKj9zNcdCYYVQT+fl23MaYcWAmW0LuOr9bS61lV8UdQSeazzGMy+uPgV/A+a/0pkjNuJdHLezDsLUCnomkFl4RVNFcIJFn1K24j+gxE4N7x7F025yE6IHpvH9fbr6duZawqXSADQjSVLojcg2MNDmxMyZE4fw7SBkDgkWtbd4oVVDalLf7sg87vnQufi4Dt2/fGLI9Zq8P1q9YWG726iyAbj2nKbaPvp0D4e1sUrAXXk3dvMLVzwrztoq+qI23osQ0ClJLDhJzIFfQJigqRNzR5Yn9EolI/PD0cc Gaul3snb j+q6MLS6UpgyOrcCsfnU3eNqtOQJk4kFka6RszTVm6M6fJh0i7LbbGC4lr/zxEpl6hPWyb3kdCLI5/gRqz2iuLtEMYmOAFN5gE+DvLoHJeMYpaweT3jL4+FZt7yCCZQmOdfagcHhUFoH56Np9VGu1WbtyFdTaPqGKTZqAntQ8E7w1pespfQQg0qtUwfsjnegy4frvbnY1HEMv++2r9XIFjhvMXb3dlzCJkfLbjOqq2rE0/eCUnyWwC+yGqmsxRMV2l8zsgalhYm2kNJiicQk9Yb+/M12EF+am1eYw/Zui3f3ntADAUBg62pTjuqzupOq4K7wdwKWMD9oD1m2/l2AhewLfjZJO25Hxq0Ly 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: From: "Mike Rapoport (Microsoft)" numa_cleanup_meminfo() moves blocks outside system RAM to numa_reserved_meminfo and it uses 0 and PFN_PHYS(max_pfn) to determine the memory boundaries. Replace the memory range boundaries with more portable memblock_start_of_DRAM() and memblock_end_of_DRAM(). Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- mm/numa_memblks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index e97665a5e8ce..e4358ad92233 100644 --- a/mm/numa_memblks.c +++ b/mm/numa_memblks.c @@ -212,8 +212,8 @@ int __init numa_add_memblk(int nid, u64 start, u64 end) */ int __init numa_cleanup_meminfo(struct numa_meminfo *mi) { - const u64 low = 0; - const u64 high = PFN_PHYS(max_pfn); + const u64 low = memblock_start_of_DRAM(); + const u64 high = memblock_end_of_DRAM(); int i, j, k; /* first, trim all entries */ From patchwork Thu Aug 1 06:08:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749756 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 58477C3DA64 for ; Thu, 1 Aug 2024 06:13:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E50306B00BF; Thu, 1 Aug 2024 02:13:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDAD36B00C0; Thu, 1 Aug 2024 02:13:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C52DF6B00C1; Thu, 1 Aug 2024 02:13:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A5E326B00BF for ; Thu, 1 Aug 2024 02:13:18 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 602421608E1 for ; Thu, 1 Aug 2024 06:13:18 +0000 (UTC) X-FDA: 82402659276.15.94B9FC2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id BC444A0009 for ; Thu, 1 Aug 2024 06:13:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pqPSECnC; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492750; a=rsa-sha256; cv=none; b=TjKpecyQoy4wPuxizLQwXjHSd41aswCelgo3off0sBmthwhZSedskLF6XuK6QXyspdEQ2r lcSgjJ+80j/7Smam1pSS05aQ//6TUx5zslJBif4nzZUh+O4RzTVPGYHHGbCQ/ruYipZ0dt r/m6R+0KF5qnx0qiHVRKMl+YyJUx360= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=pqPSECnC; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492750; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QRa6MsaZCxWeQl/Ai32u7E5M5KUGTAfpa3fP02pDjE0=; b=hopkK9iXceuyduEfsFXbVtJSKlf50d0gJNoeln0feH9oldRs4MCWiPnzhSIRHaVlzwVawN A4imWi8etflYYp3Li4+3JPEjr+VEelkBSy8hvlSGpZQhS5WlDQ3U6u+trWpN/wVHUjWS5D 5favl6zq/ZLoIuP/JuDIYEPRs0gCcdQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 04D8B62779; Thu, 1 Aug 2024 06:13:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9FA9C4AF0A; Thu, 1 Aug 2024 06:13:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492795; bh=wgBkv6gb0pPzoMRiWhD0EVSQTy0zZwrH+GjPrFy0JG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pqPSECnC0eM5g/zSNnOAmjrOasiIzwPA6z/+g6VkF4/et9bbVvssBzCmMrT2fH2FH s8h76/CNsq3n19tI98+vSyv3i90mhkvLpBDaWko03EvTXamnFlNQgmpdo+G83yUOyx QyLtENSdzXa9vkqCaNUDnt/UF6i2lx9sq7bccco42lDyUnUu3rXB+g1cBh06tVNc9Z O/TqPVS7+0XmmBYN3tsp7y8r/0t3RnE/Zo1cRWYh4hXoZOIuKMzLdquIzKitbNSpQR n3IeWHly9yw4naiZQqSAl7QY2ittG7QUqkHNN9dFTUw1WtpMMeCmArHNdljr08O4Fn RoQH6f0HaoqCg== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 23/26] of, numa: return -EINVAL when no numa-node-id is found Date: Thu, 1 Aug 2024 09:08:23 +0300 Message-ID: <20240801060826.559858-24-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BC444A0009 X-Stat-Signature: 5m7yew8564wx9kb4n39mio7y8ytx4sba X-Rspam-User: X-HE-Tag: 1722492796-922861 X-HE-Meta: U2FsdGVkX19d8Ev4/YJZc6R/UxlTA+P5XWu1+IIE0DtOXzhpnb3rWdGzyxO/4WVfpu6u0fDD6p97q+mct/H/RGSgQo8RjFz+rUEPJbrqdrO2h1fSbMEjTiqrFGhqH93ii+32RwL6oe13Uo6blMfB3eGqDDzSWtB6l+CDkU4tiBFwz6qpOhrouKuAgFiuGgPrPoz7yORsrS3xxbo1g8ZF95xd/KJvcAezli8z38jplCzKWYtxFlal8gIJ+E7uwSX1A1t7ZzKNO9St/M3p41vV7bv86H8mhmf+wuFrCbzbR2e3hY7s6atZ14owWq5cN+64D+uu1P65Ce2VsgaDhPuLew97S60UgYpOuTimRkqFGI00jr9fP2z8DK0HlB/7ePDat3dGWBdj8hCVjRlGPph7MFF5ilQbD3M3YHz/QPAUoS/RPshwiUK/0zkFAVA8lZuJuj+CTkpmj/YqIKdNU9aX072a25EApfPujdRktT9wdTS3jnD3lrVjI4nnBfFw9k3dA5moQwhwGt89/w+14Ma8KkMWwNpd+LkYCL+r7if+R5r5xN+ULaX17JYd3OAPHemACcpLTn0dkAk33SFhbYQDAIsjNRNyMXxSjdRpLNP5Z8VlzSr2XpS6J/ZSVhJ7RU1sSmrlGQN4jbMBjSYBQUSWmmdFhzMliRc2d9OF0BWRFGoarMJYSQErnFc8NjcFjMkhaFq1SU6wzB+Xcw9rOR60Q8gtISL0n2DdxfHEc3QXb9UC99Uu8bNE4HU5+CEqTPB5pB/zMELQeFzQyOcwMb5o+cFXqWGBDy0zthvtyjrvpo7OicSEjtNev+S8t2ZxLQ4i/3bjBMC3qnd66Idx+jZu8lDCHp2SpioXfLIT0Kh7JwovoTdqawKH1S+MZu5eis68n7IRNivPERwES9iIzrzS5/iWrTL03TzwaQlmgth450mUqXAiPnblkoA4QHnvDLVSWZwv1p5T8wqokdPEmIP zo13nBf2 dgxLNfRoIuUHo65cKUUHeb8Pk7p2aAyLDdNBjcw9RqJHYiBp8roiM0n8f0e1AI7wkjk70vR3Y305L5MTzbJE5fH6IjZaWSNWOEwI7PIbSbcPIGhE8oejPICECT3yRMhwfsIJD1eVqGDHNUy0vhfE30vHGrOaQ76jdVfB4roPymvyHkKHcadWIn3cjZzI7reLKpSSrPKkj1B/U4UDslbWO3sW+mN30mfnaz1eJ4B0VF1emXsBlidHTDudFiJ7cGHQX0H2TWJUZoHLqpWi4mcM8IG7Mag== 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: From: "Mike Rapoport (Microsoft)" Currently of_numa_parse_memory_nodes() returns 0 if no "memory" node in device tree contains "numa-node-id" property. This makes of_numa_init() to return "success" despite no NUMA nodes were actually parsed and set up. arch_numa workarounds this by returning an error if numa_nodes_parsed is empty. numa_memblks however would WARN() in such case and since it will be used by arch_numa shortly, such warning is not desirable. Make sure of_numa_init() returns -EINVAL when no NUMA node information was found in the device tree. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- drivers/of/of_numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/of/of_numa.c b/drivers/of/of_numa.c index 838747e319a2..2ec20886d176 100644 --- a/drivers/of/of_numa.c +++ b/drivers/of/of_numa.c @@ -45,7 +45,7 @@ static int __init of_numa_parse_memory_nodes(void) struct device_node *np = NULL; struct resource rsrc; u32 nid; - int i, r; + int i, r = -EINVAL; for_each_node_by_type(np, "memory") { r = of_property_read_u32(np, "numa-node-id", &nid); @@ -72,7 +72,7 @@ static int __init of_numa_parse_memory_nodes(void) } } - return 0; + return r; } static int __init of_numa_parse_distance_map_v1(struct device_node *map) From patchwork Thu Aug 1 06:08:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749757 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 1C7D9C3DA64 for ; Thu, 1 Aug 2024 06:13:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACE8F6B00C0; Thu, 1 Aug 2024 02:13:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A57156B00C2; Thu, 1 Aug 2024 02:13:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 882566B00C3; Thu, 1 Aug 2024 02:13:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 657446B00C0 for ; Thu, 1 Aug 2024 02:13:30 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 16C9A80863 for ; Thu, 1 Aug 2024 06:13:30 +0000 (UTC) X-FDA: 82402659780.14.DA7E4A2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 66967140010 for ; Thu, 1 Aug 2024 06:13:28 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IsTaem3p; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492733; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QmAgG12nizdwxcd/wUyhJsLMSBewCcjrbwOB0RrzhlI=; b=QHFRZCtOJXc17Ebf5SW1gFtM6fO5fClS+qVQjvgAa8eTyxhRMLnycu/W6Ux2+NFZOmXLVk JVumx9vQt+FrqFgavIPWKh0mocWyq/UrlB99q7IufP8mpG/GUvY8TmcEprt3vjhvg11GUi oYNift6L6qfxFPKS1UBukdqw/dEDV7A= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IsTaem3p; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492733; a=rsa-sha256; cv=none; b=AKAKWedYp7QE8qwJTe+oqZL/R5tki2Ra7mBNIDIaviz7q1wyojSDqosOSNiaoWmnZh8IJI kw2dubzKcWP17O4xn7FacB2KdkAxzZ1GVBFsb4Gpqy3EVtZ881sOCEvg1dgoz96dx5omIa E98SBvhKwG2yOzLAeqF8xZtpGQIEOr8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 90FBC6173D; Thu, 1 Aug 2024 06:13:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F39BC4AF0C; Thu, 1 Aug 2024 06:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492807; bh=SaBSVUDO2Ywu0lfKasK5lbf2LNVdEu13LVuRuAKcVek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IsTaem3pcie0pvA39AJYcaqeNz456RI+bxurpkP+n9HFbKRaRYBYs4LbHzA1X8Gy9 SEXn+4TaEIbBoNf8pjoAD5nN+FbgEWQ6sf9q9mX8Ya0ad6ojakZiUruA8/31upVQ3Z KjvAoodGMGS/o8biYrdW3R9WzoVzSKdk3bsAQEjCFmOCLsoXX3S+XO7IPV73Uvi/Ir Ago9RVdB+JWRwheN6Px1aYvQbn4bkpH07vwgk3CvhxqtxafWTYQaauZypz8XxCygmB yunSW44enAyhyPB56DXZ3l++/uUfBfSBRcwEybzgYE9j5uaY12K53jOZq4+DOtlTZ0 ErIUdOlrDghew== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 24/26] arch_numa: switch over to numa_memblks Date: Thu, 1 Aug 2024 09:08:24 +0300 Message-ID: <20240801060826.559858-25-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 66967140010 X-Stat-Signature: g37a8bwc8daarqt6gcic6r6p7u7bshcm X-Rspam-User: X-HE-Tag: 1722492808-8362 X-HE-Meta: U2FsdGVkX1+Ez2yAvKegpkPv7uiZJm0WoXbnEz51kZ1fyslciIPuRBOrnkcgMtCHlFITpFPSm0e7jd2pZOuIV3uvgcm9ixnVh1JHjrj5qaDPdI3qQhlVVYZOJtAkSTnek/YljXwXsxnr8B2/zzA3aAWVDdvPpZ6JOkMFj6G7hpDGqbZdDBfzmUte0LLh9RomV7pB0cgIxysxGSeRNVwLhMtcqOSEduRqWGbpE46ArW0eBRRwFShRqfKKpex5VumhQG1aHkFAn4/R4W1G60yOaYyhWXzr1v3dDlS2Yh6EWJhxwID79nyOzFgfqRyxbsZmmwRX2RdHUdRWRrEPfJRIoQc15T0XHDkXiFL3e82fo8bqpX3yZomT+TwHlXTmZDdOKb/BGYRcTsYjmxrNqdQoHPhP0ugHktC5Uq/PSZN3YCU+0Tbw4Rt5byXaRR6z0YYMutq0NXvDiF5WZcHfqtZGfsaxQ7hm/TpE38kJ+rA25khGQd4mJ4lRP647ShaQV9TQPAglzGQsHehurSqeCv8NWTb4Cn6Kkol9d8P3HJKBtV2UIJ0vA234DNXaqtfQuxsudjDmCqrw05KkEjbhfVcUZ2t8lWCF0nf7OJvvqyupUm8eZTWNE8U2LpL9yDSDMElPyjD6WF/PMi3sodkYTCKtbN4cXYBpooqKoJUPMWwtDM+cWgy84jph3fkZAH0SYoOrA37fWj/tBJxOWmLIeh85KUrfpy7EH6E470q6oVG1gGq0tPdOpzCNRaAL700Drkr88IvDj/+qtuf51faigX7OHmYu+vMxhendvNm+RGjG8hdmS/D+b6PL39HOS4mncNvvmqO4JPPboZMBmAY884IAJkNP2rh5xvSkr52IuSWyNUFDTdnBZCvSmxktYKYXlYH9PQnVA+LS64HXIScEkVqcDuv4/hFU8QNiFfQmTNEawiqpdPRGelt73UayCx4IOlayV3To+95TtmA/Rq3uXY/ UwqduAAq VwRUvGEIjEfKXwPRphWYMLK2WkqGwo2qgi1A63xiKJ4t7j1Oyt9WtchMLOq1HxrbhHkRgG6SJRBV8FPWnPYK/IaazIzyKQzxUUZVWBePity+LYMo11Qrg2FUjH5bgcoH/ClxEbxk7jHOKOIa7M+jUSHNMz5BomTUTf5CToEwa307CqcC41cDzUX0rekjewX44KksMbU6Eqbt4e0bmgq3kuFJYqbKoy1rGhwM/KAmmhdE3ZPI2HbxpHQUlWNVo1VCXhbMgkMaAjM1Gtf1iwyGZQY03vxdh3tk2IuB5z30ErFQCnNt3uFbMQ9h2ppjMTNuJxKDxAvrKwHyAHE4HeKgvtFvVVe+trZ8icwur 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: 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) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- drivers/base/Kconfig | 1 + drivers/base/arch_numa.c | 201 +++++++++++-------------------------- include/asm-generic/numa.h | 6 +- 3 files changed, 65 insertions(+), 143 deletions(-) diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 2b8fd6bb7da0..064eb52ff7e2 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -226,6 +226,7 @@ config GENERIC_ARCH_TOPOLOGY config GENERIC_ARCH_NUMA bool + select NUMA_MEMBLKS help Enable support for generic NUMA implementation. Currently, RISC-V and ARM64 use it. diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index b6af7475ec44..8d49893c0e94 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -12,14 +12,12 @@ #include #include #include +#include #include -nodemask_t numa_nodes_parsed __initdata; static int cpu_to_node_map[NR_CPUS] = { [0 ... NR_CPUS-1] = NUMA_NO_NODE }; -static int numa_distance_cnt; -static u8 *numa_distance; bool numa_off; static __init int numa_parse_early_param(char *opt) @@ -28,6 +26,8 @@ static __init int numa_parse_early_param(char *opt) return -EINVAL; if (str_has_prefix(opt, "off")) numa_off = true; + if (!strncmp(opt, "fake=", 5)) + return numa_emu_cmdline(opt + 5); return 0; } @@ -59,6 +59,7 @@ EXPORT_SYMBOL(cpumask_of_node); #endif +#ifndef CONFIG_NUMA_EMU static void numa_update_cpu(unsigned int cpu, bool remove) { int nid = cpu_to_node(cpu); @@ -81,6 +82,7 @@ void numa_remove_cpu(unsigned int cpu) { numa_update_cpu(cpu, true); } +#endif void numa_clear_node(unsigned int cpu) { @@ -142,7 +144,7 @@ void __init early_map_cpu_to_node(unsigned int cpu, int nid) unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; EXPORT_SYMBOL(__per_cpu_offset); -int __init early_cpu_to_node(int cpu) +int early_cpu_to_node(int cpu) { return cpu_to_node_map[cpu]; } @@ -187,30 +189,6 @@ void __init setup_per_cpu_areas(void) } #endif -/** - * numa_add_memblk() - Set node id to memblk - * @nid: NUMA node ID of the new memblk - * @start: Start address of the new memblk - * @end: End address of the new memblk - * - * RETURNS: - * 0 on success, -errno on failure. - */ -int __init numa_add_memblk(int nid, u64 start, u64 end) -{ - int ret; - - ret = memblock_set_node(start, (end - start), &memblock.memory, nid); - if (ret < 0) { - pr_err("memblock [0x%llx - 0x%llx] failed to add on node %d\n", - start, (end - 1), nid); - return ret; - } - - node_set(nid, numa_nodes_parsed); - return ret; -} - /* * 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; } -/* - * numa_free_distance - * - * The current table is freed. - */ -void __init numa_free_distance(void) -{ - size_t size; - - if (!numa_distance) - return; - - size = numa_distance_cnt * numa_distance_cnt * - sizeof(numa_distance[0]); - - memblock_free(numa_distance, size); - numa_distance_cnt = 0; - numa_distance = NULL; -} - -/* - * Create a new NUMA distance table. - */ -static int __init numa_alloc_distance(void) -{ - size_t size; - int i, j; - - size = nr_node_ids * nr_node_ids * sizeof(numa_distance[0]); - numa_distance = memblock_alloc(size, PAGE_SIZE); - if (WARN_ON(!numa_distance)) - return -ENOMEM; - - numa_distance_cnt = nr_node_ids; - - /* fill with the default distances */ - for (i = 0; i < numa_distance_cnt; i++) - for (j = 0; j < numa_distance_cnt; j++) - numa_distance[i * numa_distance_cnt + j] = i == j ? - LOCAL_DISTANCE : REMOTE_DISTANCE; - - pr_debug("Initialized distance table, cnt=%d\n", numa_distance_cnt); - - return 0; -} - -/** - * numa_set_distance() - Set inter node NUMA distance from node to node. - * @from: the 'from' node to set distance - * @to: the 'to' node to set distance - * @distance: NUMA distance - * - * Set the distance from node @from to @to to @distance. - * If distance table doesn't exist, a warning is printed. - * - * If @from or @to is higher than the highest known node or lower than zero - * or @distance doesn't make sense, the call is ignored. - */ -void __init numa_set_distance(int from, int to, int distance) -{ - if (!numa_distance) { - pr_warn_once("Warning: distance table not allocated yet\n"); - return; - } - - if (from >= numa_distance_cnt || to >= numa_distance_cnt || - from < 0 || to < 0) { - pr_warn_once("Warning: node ids are out of bound, from=%d to=%d distance=%d\n", - from, to, distance); - return; - } - - if ((u8)distance != distance || - (from == to && distance != LOCAL_DISTANCE)) { - pr_warn_once("Warning: invalid distance parameter, from=%d to=%d distance=%d\n", - from, to, distance); - return; - } - - numa_distance[from * numa_distance_cnt + to] = distance; -} - -/* - * Return NUMA distance @from to @to - */ -int __node_distance(int from, int to) -{ - if (from >= numa_distance_cnt || to >= numa_distance_cnt) - return from == to ? LOCAL_DISTANCE : REMOTE_DISTANCE; - return numa_distance[from * numa_distance_cnt + to]; -} -EXPORT_SYMBOL(__node_distance); - static int __init numa_register_nodes(void) { int nid; - struct memblock_region *mblk; - - /* Check that valid nid is set to memblks */ - for_each_mem_region(mblk) { - int mblk_nid = memblock_get_region_node(mblk); - phys_addr_t start = mblk->base; - phys_addr_t end = mblk->base + mblk->size - 1; - - if (mblk_nid == NUMA_NO_NODE || mblk_nid >= MAX_NUMNODES) { - pr_warn("Warning: invalid memblk node %d [mem %pap-%pap]\n", - mblk_nid, &start, &end); - return -EINVAL; - } - } /* Finally register nodes. */ for_each_node_mask(nid, numa_nodes_parsed) { @@ -360,11 +231,7 @@ static int __init numa_init(int (*init_func)(void)) nodes_clear(node_possible_map); nodes_clear(node_online_map); - ret = numa_alloc_distance(); - if (ret < 0) - return ret; - - ret = init_func(); + ret = numa_memblks_init(init_func, /* memblock_force_top_down */ false); if (ret < 0) goto out_free_distance; @@ -382,7 +249,7 @@ static int __init numa_init(int (*init_func)(void)) return 0; out_free_distance: - numa_free_distance(); + numa_reset_distance(); return ret; } @@ -412,6 +279,7 @@ static int __init dummy_numa_init(void) pr_err("NUMA init failed\n"); return ret; } + node_set(0, numa_nodes_parsed); numa_off = true; return 0; @@ -454,3 +322,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 cpu_to_node_map table to use emulated nids by + * 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); +} + +void debug_cpumask_set_cpu(unsigned int cpu, int node, bool enable) +{ + struct cpumask *mask; + + if (node == NUMA_NO_NODE) + return; + + mask = node_to_cpumask_map[node]; + if (!cpumask_available(mask)) { + pr_err("node_to_cpumask_map[%i] NULL\n", node); + dump_stack(); + return; + } + + if (enable) + cpumask_set_cpu(cpu, mask); + else + cpumask_clear_cpu(cpu, mask); + + pr_debug("%s cpu %d node %d: mask now %*pbl\n", + enable ? "numa_add_cpu" : "numa_remove_cpu", + cpu, node, cpumask_pr_args(mask)); +} +#endif /* CONFIG_NUMA_EMU */ diff --git a/include/asm-generic/numa.h b/include/asm-generic/numa.h index c32e0cf23c90..c2b046d1fd82 100644 --- a/include/asm-generic/numa.h +++ b/include/asm-generic/numa.h @@ -32,8 +32,6 @@ static inline const struct cpumask *cpumask_of_node(int node) void __init arch_numa_init(void); int __init numa_add_memblk(int nodeid, u64 start, u64 end); -void __init numa_set_distance(int from, int to, int distance); -void __init numa_free_distance(void); void __init early_map_cpu_to_node(unsigned int cpu, int nid); int __init early_cpu_to_node(int cpu); void numa_store_cpu_info(unsigned int cpu); @@ -51,4 +49,8 @@ static inline int early_cpu_to_node(int cpu) { return 0; } #endif /* CONFIG_NUMA */ +#ifdef CONFIG_NUMA_EMU +void debug_cpumask_set_cpu(unsigned int cpu, int node, bool enable); +#endif + #endif /* __ASM_GENERIC_NUMA_H */ From patchwork Thu Aug 1 06:08:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749758 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 E12A4C3DA64 for ; Thu, 1 Aug 2024 06:13:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63B686B00C2; Thu, 1 Aug 2024 02:13:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EAD96B00C4; Thu, 1 Aug 2024 02:13:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 465056B00C5; Thu, 1 Aug 2024 02:13:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1EB166B00C2 for ; Thu, 1 Aug 2024 02:13:42 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CD48FC0749 for ; Thu, 1 Aug 2024 06:13:41 +0000 (UTC) X-FDA: 82402660242.14.FB28762 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id 2BDEF40018 for ; Thu, 1 Aug 2024 06:13:40 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SwRgUpUT; spf=pass (imf07.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492764; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=beSa2ytw03vDtMUwO44+OPbO35DnjhtJo4a2n5sRPP0=; b=tsZlYifCK0Ms9G2KClLQnYDG9e3IWQruIxhjX09pUybC+xaQliJLyYot04vZtgWXCfzoJr icj5HA3Q4d+3myjMwHBodcPALhMEbnORPptHe4Znu5lB/0QX+7ud2DyA3S+KNHtIKKmIh2 yiB/SFqeB+/4wwRfUHzY8RH2v78FcRM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492764; a=rsa-sha256; cv=none; b=nxn1/ED3UJ684PrYIG4Ycl76rCeW/Me6BypJp+n23ULLJmjA1IKx9o5SVhAO1Cm8xy6Qod 7o748XmyN9VKuUvtw0Cc9InQbz+DbmPpM5aiVqRXq4bAZ+eryphFhDUpnN2fi9bVvtwX6L 1EUPiOqruXici0yV1XMc2pwU27EIn8s= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SwRgUpUT; spf=pass (imf07.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5E0476140C; Thu, 1 Aug 2024 06:13:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C93C9C4AF09; Thu, 1 Aug 2024 06:13:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492819; bh=0axTSQ1nxfv7D2ZG6wVeXqDKtmMcvnEWpPqy/9HH1Dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SwRgUpUTHSOGIldRInVeyCqw6m80FayJa3sU+7J4u7V5TbZwPWPsgG+eYe3gM1J3i KCO0CT47JVeiIbo3tNqDb6wQ9CawD5AQVmdlKLyJIOfgjBi60mrNlsEGUGLf+3w3o8 KT8AztBWuT1E6ZDQTEXkforNio3hhU3Cz6dWl8H+F/BO8cjctRqCFk5UWzb0qWBdbD OQkLeE7uqwXRDiiFSipOue9T4zSE/ClH3dexHbfGIBEXJXopbAT3hINNtGN5HDNyu/ Db00sxmjRdAnze9D6TYdtzsY3ajT+qwjcwzZZy+T4mv+CqIrSf+byLBfVVSSVDuFSE rMH52h/Xye5cQ== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org, Jonathan Cameron Subject: [PATCH v3 25/26] mm: make range-to-target_node lookup facility a part of numa_memblks Date: Thu, 1 Aug 2024 09:08:25 +0300 Message-ID: <20240801060826.559858-26-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2BDEF40018 X-Stat-Signature: akwhsexr59yhoaaoyczx1o85enfsw618 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1722492820-12830 X-HE-Meta: U2FsdGVkX1+Y7QSexYMy9EucTCpWbxq03ae1TLR4vWRiD0A/o23Q+AHdOSofgXTkh5idnJxYjUyq2ro95mEnayAcEIwjYxfqAnmK35mKCUmC+WobTuVj2j7RM5BPh78Fy7ZnhsOaMw1dKmDG7kdw8Eys/T6iQQvAffaq4buAgn1z/6Si/TRRGI+EyDUnxZUB06g9l9Sg77DXX1BPPh8uJWbMigzB6gFJqwV6Kx3inPi3k0gmGxOZl96x4uXZ+vCYv+RrndonH1LOlgI6ew0GkvMR8mmle/Q869q9+iXnD4IbleD2F4k14SmYAR7oAc5wfBJqIeSVEcurRlqdsavz4pAbYWvx7PfVKXg48/XkmlHpPnoDCT+tNi46vDtUK4vUidoVgbaubmX9eAGovlBD5mk3vqhx2R4rcjOKsBDSCUCghjaNp6V1sd6VVvljzESOR7Z4kwskaW6H/JSfDu+AFjSIyz3PfcVL+bjc65ihOhLJsSApLBPFTkiUQu7ebjePvJ9iL4JZBFAreMOfDaHmEp4ZXhaI0YAhCjkEWMJqcYtAU1zLMIZMMixtHfrUaI9iKAdKs69SJ3Le6t/zv+slYb5miQqhoStffnpJG4g74KXYKC+kpGlTUU7Jb6EdTZkIqdur5Rb6FAhKiE2ace3shPw3ypcQizP7NeqyClS0IMDvjFTaLFf2RfsiqsZRzodfyrcK+QGLPWjGbMHLdbNJOCtxnVx6P9wG+KEQ7mNnsbAjOcQ4sz8u2O3f5+8uG36AP+x33EPVVuMtM/4AZgUK7Fde8NqnIfYPXvqSzOjeMqTCwEQxSV5dpjbbTzrOINhuD0WKIrujo95abPtvvLwPR8aiHRJosZ1G6t1F5oYQmi4KUn2ylOg3cUH5gX+sA+PWWSWR6qvpdIy4YOObooIXh1t2ltRyGW5MRU12wwcKEl57xvIXF7G1BdkRmG/++S5ZWfbJezD8wnk+/27ronu 9TodRiXq VEOMcmzCzNtzQ+6m3qcRzsrH/bcqmNtzeLgsoP0r2QYg5UT18keHemetE/7XUS0DAIt4CLqKTQvOM/MaWePKb15fyWgAUr0IZZNm/atrFZO8Wy8GtToC2umc0GBsGNNsxJvX7rAplJscuSFyaGsxSaEYRqS8yp+SjJyB1jxUOwhzBehOCxThXxbEK0wq7QAaS2r21rf22JaO+e64NDvBD2IJuGEPWTtLUArct5C0Bu1uliJQAW5TfFcbowx9WpVLRsQdRm5SIS84/oR4tLHzJOgJYu56T8dnqUuAi717FQaKftrf5Pg+DZiVG/3KTY+xCpjOAJi6hfu/aTdyBqrmL8acN7vC3wrM/oDJRC0rBQ+8IEprYEjQZnzU+cg== 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: From: "Mike Rapoport (Microsoft)" The x86 implementation of range-to-target_node lookup (i.e. phys_to_target_node() and memory_add_physaddr_to_nid()) relies on numa_memblks. Since numa_memblks are now part of the generic code, move these functions from x86 to mm/numa_memblks.c and select CONFIG_NUMA_KEEP_MEMINFO when CONFIG_NUMA_MEMBLKS=y for dax and cxl. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Dan Williams Acked-by: David Hildenbrand --- arch/x86/include/asm/sparsemem.h | 9 -------- arch/x86/mm/numa.c | 38 -------------------------------- drivers/cxl/Kconfig | 2 +- drivers/dax/Kconfig | 2 +- include/linux/numa_memblks.h | 7 ++++++ mm/numa.c | 1 + mm/numa_memblks.c | 38 ++++++++++++++++++++++++++++++++ 7 files changed, 48 insertions(+), 49 deletions(-) diff --git a/arch/x86/include/asm/sparsemem.h b/arch/x86/include/asm/sparsemem.h index 64df897c0ee3..3918c7a434f5 100644 --- a/arch/x86/include/asm/sparsemem.h +++ b/arch/x86/include/asm/sparsemem.h @@ -31,13 +31,4 @@ #endif /* CONFIG_SPARSEMEM */ -#ifndef __ASSEMBLY__ -#ifdef CONFIG_NUMA_KEEP_MEMINFO -extern int phys_to_target_node(phys_addr_t start); -#define phys_to_target_node phys_to_target_node -extern int memory_add_physaddr_to_nid(u64 start); -#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid -#endif -#endif /* __ASSEMBLY__ */ - #endif /* _ASM_X86_SPARSEMEM_H */ diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 16bc703c9272..8e790528805e 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -449,41 +449,3 @@ u64 __init numa_emu_dma_end(void) return PFN_PHYS(MAX_DMA32_PFN); } #endif /* CONFIG_NUMA_EMU */ - -#ifdef CONFIG_NUMA_KEEP_MEMINFO -static int meminfo_to_nid(struct numa_meminfo *mi, u64 start) -{ - int i; - - for (i = 0; i < mi->nr_blks; i++) - if (mi->blk[i].start <= start && mi->blk[i].end > start) - return mi->blk[i].nid; - return NUMA_NO_NODE; -} - -int phys_to_target_node(phys_addr_t start) -{ - int nid = meminfo_to_nid(&numa_meminfo, start); - - /* - * Prefer online nodes, but if reserved memory might be - * hot-added continue the search with reserved ranges. - */ - if (nid != NUMA_NO_NODE) - return nid; - - return meminfo_to_nid(&numa_reserved_meminfo, start); -} -EXPORT_SYMBOL_GPL(phys_to_target_node); - -int memory_add_physaddr_to_nid(u64 start) -{ - int nid = meminfo_to_nid(&numa_meminfo, start); - - if (nid == NUMA_NO_NODE) - nid = numa_meminfo.blk[0].nid; - return nid; -} -EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); - -#endif diff --git a/drivers/cxl/Kconfig b/drivers/cxl/Kconfig index 99b5c25be079..29c192f20082 100644 --- a/drivers/cxl/Kconfig +++ b/drivers/cxl/Kconfig @@ -6,7 +6,7 @@ menuconfig CXL_BUS select FW_UPLOAD select PCI_DOE select FIRMWARE_TABLE - select NUMA_KEEP_MEMINFO if (NUMA && X86) + select NUMA_KEEP_MEMINFO if NUMA_MEMBLKS help CXL is a bus that is electrically compatible with PCI Express, but layers three protocols on that signalling (CXL.io, CXL.cache, and diff --git a/drivers/dax/Kconfig b/drivers/dax/Kconfig index a88744244149..d656e4c0eb84 100644 --- a/drivers/dax/Kconfig +++ b/drivers/dax/Kconfig @@ -30,7 +30,7 @@ config DEV_DAX_PMEM config DEV_DAX_HMEM tristate "HMEM DAX: direct access to 'specific purpose' memory" depends on EFI_SOFT_RESERVE - select NUMA_KEEP_MEMINFO if (NUMA && X86) + select NUMA_KEEP_MEMINFO if NUMA_MEMBLKS default DEV_DAX help EFI 2.8 platforms, and others, may advertise 'specific purpose' diff --git a/include/linux/numa_memblks.h b/include/linux/numa_memblks.h index 5c6e12ad0b7a..17d4bcc34091 100644 --- a/include/linux/numa_memblks.h +++ b/include/linux/numa_memblks.h @@ -46,6 +46,13 @@ static inline int numa_emu_cmdline(char *str) } #endif /* CONFIG_NUMA_EMU */ +#ifdef CONFIG_NUMA_KEEP_MEMINFO +extern int phys_to_target_node(phys_addr_t start); +#define phys_to_target_node phys_to_target_node +extern int memory_add_physaddr_to_nid(u64 start); +#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid +#endif /* CONFIG_NUMA_KEEP_MEMINFO */ + #endif /* CONFIG_NUMA_MEMBLKS */ #endif /* __NUMA_MEMBLKS_H */ diff --git a/mm/numa.c b/mm/numa.c index 67a0d7734a98..da27eb151dc5 100644 --- a/mm/numa.c +++ b/mm/numa.c @@ -3,6 +3,7 @@ #include #include #include +#include struct pglist_data *node_data[MAX_NUMNODES]; EXPORT_SYMBOL(node_data); diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index e4358ad92233..8609c6eb3998 100644 --- a/mm/numa_memblks.c +++ b/mm/numa_memblks.c @@ -528,3 +528,41 @@ int __init numa_fill_memblks(u64 start, u64 end) } return 0; } + +#ifdef CONFIG_NUMA_KEEP_MEMINFO +static int meminfo_to_nid(struct numa_meminfo *mi, u64 start) +{ + int i; + + for (i = 0; i < mi->nr_blks; i++) + if (mi->blk[i].start <= start && mi->blk[i].end > start) + return mi->blk[i].nid; + return NUMA_NO_NODE; +} + +int phys_to_target_node(phys_addr_t start) +{ + int nid = meminfo_to_nid(&numa_meminfo, start); + + /* + * Prefer online nodes, but if reserved memory might be + * hot-added continue the search with reserved ranges. + */ + if (nid != NUMA_NO_NODE) + return nid; + + return meminfo_to_nid(&numa_reserved_meminfo, start); +} +EXPORT_SYMBOL_GPL(phys_to_target_node); + +int memory_add_physaddr_to_nid(u64 start) +{ + int nid = meminfo_to_nid(&numa_meminfo, start); + + if (nid == NUMA_NO_NODE) + nid = numa_meminfo.blk[0].nid; + return nid; +} +EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); + +#endif /* CONFIG_NUMA_KEEP_MEMINFO */ From patchwork Thu Aug 1 06:08:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749759 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 56C37C3DA64 for ; Thu, 1 Aug 2024 06:13:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E02DC6B00C4; Thu, 1 Aug 2024 02:13:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D8E986B00C6; Thu, 1 Aug 2024 02:13:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C06496B00C7; Thu, 1 Aug 2024 02:13:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9B7AE6B00C4 for ; Thu, 1 Aug 2024 02:13:53 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 59C5F802E9 for ; Thu, 1 Aug 2024 06:13:53 +0000 (UTC) X-FDA: 82402660746.19.F72E450 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id ABA3314000D for ; Thu, 1 Aug 2024 06:13:51 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Krg1nriO; spf=pass (imf26.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492787; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/tY3zNJs0sdp+mLC80D8l7ZC/gwnw93Ga09MvkFIaSA=; b=csKKnWR/J0zZycd67vrO4CgzB74AYdd7j6vsI+ULoHxwHeu6l1UtiDbEqAqdTSUoT+v5OM 5U9grrmCwcdZEWNCjIl4PwJQiNYnOTfUeuEcrOHrIdyZpG3hxH28MNuhFOf8xwgk9CFTci SYYc7Uz1UtzHWgEmS7yrP+Bvg/H6xyw= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Krg1nriO; spf=pass (imf26.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492787; a=rsa-sha256; cv=none; b=GZNg7DpRbJnQMHNc7Vs3kDE6C6vVUhy9FurV5s9LTLUTH0DBOLB6EY3WUZvH4kmmqJujc/ 9yEuRzZJY4OFeOKrl5VkMlniqBsjtpBjFLXV719M75RDUjvwf5pshx4TbMQJzCmxjHiybm yuoWQMTCcLuJNxU2hGxNVS7UxXsJMto= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E980462769; Thu, 1 Aug 2024 06:13:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97316C4AF0E; Thu, 1 Aug 2024 06:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492830; bh=2z4bHnWIWcvxAiFTLgSYfPcGY4CSFltdU+BtR9hEENA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Krg1nriO+eqnJw/SwdbuG3fCazMoLJlQMveWlRkHWmGKjUeBAV7SPEb3qpYrtisDR zcMTZ9ucUhsZWHm5P0W+e7OwiQbmCzYDNW0O0KB9bpGyPbYgbomgp6evmqSqJK760o G3tlRtfaCIlHRTSAxX+B6jfurNE/P42/ILnPuKFYuvjt2jr3XDTpBGpJgTe69srkyE T7HP4P7RrEbKkHv+Z2WcA38kANShZuYnsFLoO9R+x/ze0wRTfzDScZQnHsTT0bkqEp r3/pInPgL1sn+CE/kAYEoSxGqH/IFD6WOJQ4wImNEhfM2qe3oPpI8DAV+mZ7uJVllq swnBD4lW/yIiw== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 26/26] docs: move numa=fake description to kernel-parameters.txt Date: Thu, 1 Aug 2024 09:08:26 +0300 Message-ID: <20240801060826.559858-27-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: pe6ny6gtuz7wrp47eacj7rkq5gazuwd1 X-Rspam-User: X-Rspamd-Queue-Id: ABA3314000D X-Rspamd-Server: rspam02 X-HE-Tag: 1722492831-653807 X-HE-Meta: U2FsdGVkX18BEEX6w6W0hUpigfPC/iDW/68ZyGyQXOrzRGD8F0jtdBvBYESQn2GpevN1KxA/hf/Je1xab66m9NeALN3rTJxsF4iFUMXgcHyNFs/O7y4IYbmlstdgWIhbX+epekgCGwqPpRBQ/H7soN9hOpX2Z9B36ktxhByxmRaZiOaaIWeFhJwwfieOvob8Bdfp6m80sGKdmji5Eb5m/Ex1oKqfMqz6j9Y6GeShycdCJ+PsWyWL0OV1A3D4zhegHuKSWuDmkvEqhMHTBYx5tGpfURv8NX1zU+mqat3X1Bymd6r9d/23feMCaclPMoQO5XkYNYSVdbfzy+UpL8YBHt3ARhNAfD7xohur2rRmXSQce4q9fQYDs3IQrUvX8KpXRWf0Ui5eRwiXaUhyl2Sw4bpO2Wijfo72YL5l8ij6pO9IgPQ/4RR5eOo5LpdLJ8EUGbdaOtfMd/7nYiydp3LKpkRS5WqDeWUj5Me1wYGvrB2qgoh8j9Z0mCErAOYtTH8oPV02xReU5086240aEKQ8zpoJkFl+fUBLgMlBiGhtfQvJ2vCS8lOCRIzvES9XI9ciPAKotnSSOAs/y0ZDUbeyO1KNoAGrOO13ZQ3Z45s4clA+cMXOGnncayio2qlKeIfz6wtDY8L5MxFdhSl8kGvOcZU7RWAh/PSbjknMkuxOymegxt0OczY9mjNSYfodDzn9DXv8eCGgo2YLqHum73Q8ZkMuefC94mRGUY0IFDjUynBxfSmdyxOHF17F4HJalmCgr2bl1c8JkveTGDDlFJj9Tn6IV6OtZxrg0Ghv/e6B+ZxQGJZTI+W1rt1xhu6X2dBf5w3y9O6ce0WXG99rMiTJCyBIx3mDGuu53ihK0Au7jZcnCvYF7eaRiyNHS7e1fwMoa36x2W/Hzvz7JFKa45Ua6EQzhGYwKWQwZeENZnqbrFmEVQBUmMMQJaaKGF0XunNgMU0Fukwvgf+LIS+Yfek qeMDlmRo YXA+YeLqVpCgbcwC1GQRubJ/HVZYwfzaVE49lSDrHJgQ9bp7tBcRLyNDyyAJedtQNdrj+BJShQznKDdMftt0l1UYGZ9O7tcnpCT8YoxQAgfsl+fN6N09lX6nRIuuoqNe06ZxLYHbl7FV2jg1HMUXNym9nV1Xw/V+4l+l9R5bUK8j0dxzY+Yo/93V3qgvQYlS9rvMjXOMI6aI5z62xjQwBgdevXxJ5aQhBIvI23RBkXqlphZUgW0rXAIZyby1MKQN61BxubkCgAgwoEyNLLGBCz1piCQranP8TWTIORkt8wJI5DH8= 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: From: "Mike Rapoport (Microsoft)" NUMA emulation can be now enabled on arm64 and riscv in addition to x86. Move description of numa=fake parameters from x86 documentation of admin-guide/kernel-parameters.txt Suggested-by: Zi Yan Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- Documentation/admin-guide/kernel-parameters.txt | 15 +++++++++++++++ Documentation/arch/x86/x86_64/boot-options.rst | 12 ------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index f1384c7b59c9..bcdee8984e1f 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4123,6 +4123,21 @@ Disable NUMA, Only set up a single NUMA node spanning all memory. + numa=fake=[MG] + [KNL, ARM64, RISCV, X86, EARLY] + If given as a memory unit, fills all system RAM with + nodes of size interleaved over physical nodes. + + numa=fake= + [KNL, ARM64, RISCV, X86, EARLY] + If given as an integer, fills all system RAM with N + fake nodes interleaved over physical nodes. + + numa=fake=U + [KNL, ARM64, RISCV, X86, EARLY] + If given as an integer followed by 'U', it will + divide each physical node into N emulated nodes. + numa_balancing= [KNL,ARM64,PPC,RISCV,S390,X86] Enable or disable automatic NUMA balancing. Allowed values are enable and disable diff --git a/Documentation/arch/x86/x86_64/boot-options.rst b/Documentation/arch/x86/x86_64/boot-options.rst index 137432d34109..98d4805f0823 100644 --- a/Documentation/arch/x86/x86_64/boot-options.rst +++ b/Documentation/arch/x86/x86_64/boot-options.rst @@ -170,18 +170,6 @@ NUMA Don't parse the HMAT table for NUMA setup, or soft-reserved memory partitioning. - numa=fake=[MG] - If given as a memory unit, fills all system RAM with nodes of - size interleaved over physical nodes. - - numa=fake= - If given as an integer, fills all system RAM with N fake nodes - interleaved over physical nodes. - - numa=fake=U - If given as an integer followed by 'U', it will divide each - physical node into N emulated nodes. - ACPI ====