From patchwork Tue Jul 16 11:13:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734328 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 E194CC3DA59 for ; Tue, 16 Jul 2024 11:14:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 589386B0085; Tue, 16 Jul 2024 07:14:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 538DF6B0088; Tue, 16 Jul 2024 07:14:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DB116B0089; Tue, 16 Jul 2024 07:14:20 -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 1DCC16B0085 for ; Tue, 16 Jul 2024 07:14:20 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 918B6A17C9 for ; Tue, 16 Jul 2024 11:14:19 +0000 (UTC) X-FDA: 82345357038.01.6665C58 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id E8929160004 for ; Tue, 16 Jul 2024 11:14:17 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VkMJWuO9; spf=pass (imf08.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=1721128420; 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=zWg0PKdshCRZzaRBEBKaa7gNylRwIb5MiAbQ1E5YHbo=; b=hoedF6lw5U660ZtD//+cmBIQGMdzz+R67wYSttGS52OWYe5AwTFyqvXyQxNAdTLXiWYT3T CHIY/bGrDwtBqDH0CNK99qvZ7kPr7Qc/yUuBGb1v7EkRiK0Rbutyeoh+SdMYAfiZ0cF4aH dx6wdM0oy0NsjmjYNb2Q12rtruqBtuE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128420; a=rsa-sha256; cv=none; b=hSQdOFB86gMJ/4BG6/+iffvrwsK/eB5gI9T2alf8eM8ixx2VnAIDRc26OUDMkzZbkbw7Ax gJkXdpSQlgAhWsF7JUDxkRwZNTNYbtRsyP2YQRX7gInbjECmkL9NJ/1mDreNC+/dnpFRoK E2ZyoORG4/IKD6yfg1yRZU9QU47uByQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VkMJWuO9; spf=pass (imf08.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 C8FC9610A2; Tue, 16 Jul 2024 11:14:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF837C4AF09; Tue, 16 Jul 2024 11:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128456; bh=y3TD89E5xgR+cEB9zJIVa1MhEE/ag71T+percuJb8Jk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkMJWuO92ZVIqTdQkBEULX1mdRfTUE6/w4UgTHJ/fo7CztNbTtED3l85kzn8gLFLR LumfY8sNSw4PSPj6yPSVQ8T2AEm8DCptdeO4INOBYjWuTbnE/JBCrfMzXTkNp8RXXu PBbS4LvDKghzVJNnNuLWmFVcS9ZKXPYXnKmA2ypjS6EXUEizahbhRrvw97jmJUis9x t5wpJsRgWDGJfWMC3y9xWDYl0Ok0JGcYB/caEAlLDVVeg4rOAYZV4nWqDO8bTw2kQj 43/rV7DDmhcC37yK0DUqUAJAzU4bD2511EnJEtmeEXsRdvV9Uz2W5zZnfn3J5VwvF8 0EWJpUJP/BkOg== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 01/17] mm: move kernel/numa.c to mm/ Date: Tue, 16 Jul 2024 14:13:30 +0300 Message-ID: <20240716111346.3676969-2-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E8929160004 X-Stat-Signature: k8fdmpskd4cbjcdg7uuuhba6gjmdfpsc X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721128457-920723 X-HE-Meta: U2FsdGVkX1+TIqNqHdd2aNkq979/mY8R2sHJCq/gndmhfNqhPQPn0fXYFWyIwqIWYxZpRHjCFg1QsCkmVcIQnumJSSxDZNo/vMo8BRUfQfZ4eTgo8OzXTmhnofOc8IGe9KVBuLUXKblfayoRjlx64ujkaK/c8pDXvVDybiqltiQuGgQ2YPPd0DOX+VYXY+m5a6Xu7kgyvdnBSN+ghrwdHv4MifvFTXnccOn0IkbmRDWOjhXV2AwXyiOh6kUapcpqAgl4lej7k0NKs/iw4LsRMvIlVM9X7Bls7HVvF//MO9Pxdga18HIRvLvhwayhTzlaLYkmQGAxZIWSYlWOMJkoX9mYUFPuef5oi4mPpSNpcYvE+9duN1GABg9T4TN0MwvDWk2RGqM8SXUGV17Kwkre9CwsfaxvT5kGIA8riLFfaFflE7xhZqDsB5VBVlHsK+8+YneUv7XiqdlyGfaUIsnfFdnSaa4N6VJ22JP+y5szyZxCDnvNuW/vJVsF3ZLu2tEvnPFfIw5jTpCcnkkovEk7FlKKzczFNgprmPmSPOgJKUpzZDUtU1UmXEwfrqth4lmtkyg/ebUz04VlZJjG9GaeoNM8i18v/AZVs4sq8vvfHSh4uucI0I5i0F+yfIHv72EjjHlVmOFIYfM1yzACEPJfX+YV57FF3p8SR187i/MDmLYM4eaGkdClShvW4rT6cnk7uP7u0jIrfQMtmTYnqdcJIRqYyWlpfKOSHQLQ3+PpfvloX5ZwUVH89Io6H/FxvVoKQ6M9FJ9kq4GgobBiuN4N00QjEq26aNLCggtcMzB0otGipbFKQUC43Oc4NaMwI+dNOFYTv3qllUapBueZvc1ROK4EelXP8tzc9T8XEwbNYd/XNQagvYyXWFws5QGot1SLCGyUPEwzUEdLbIpksQ+G47l0t0RWV4oV/JTnqrsLzEHWCbIurH4pWXtBbic+oij0ZbYXG3Eo123Jn+7D2i2 OeNWFdjT +Vgoej8qrlsEcGx7Smwmo5QySsKk4nQLmluf9rxB2YLVPRWaIKFutrYtf3mQ062KQWl5SUWyJkn3lIfTE0skr3DEmjgZGJdVzAnFEFjTZqBuI5r76yLXFsPQ0rqF/3p5VcsDtJMPMDO2E0W5Vb2sPG3eeLzgf0Z7pmRyE5VT2JtJha3FsvKhuO1wAjiLGQ334eSp4jz5c7E75uAdIIBuU0Nhq4ym+0xpaVA5jrG/rCcNbVrA= 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 --- 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 8fb85acda1b1..773b3b267438 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -139,3 +139,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 Tue Jul 16 11:13:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734329 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 55E04C3DA59 for ; Tue, 16 Jul 2024 11:14:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEDFC6B0089; Tue, 16 Jul 2024 07:14:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9E6E6B008A; Tue, 16 Jul 2024 07:14:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C3F186B008C; Tue, 16 Jul 2024 07:14:33 -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 A2F036B0089 for ; Tue, 16 Jul 2024 07:14:33 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 50B62A17F2 for ; Tue, 16 Jul 2024 11:14:33 +0000 (UTC) X-FDA: 82345357626.20.A0CD8BE Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf13.hostedemail.com (Postfix) with ESMTP id 06B7920026 for ; Tue, 16 Jul 2024 11:14:30 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AHYvyTyo; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.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=1721128443; a=rsa-sha256; cv=none; b=lOJ9XSNcomqedrlX2g0VoHsdeDbzlmX8pvRwHfsMef5XSnahNOL8QmBXTT8lAi2JJXu3Pt UCZ3ef2z8Gpwa5GJwDgA9aJ0CfPgMuKHvyf+veBNOJBHXDRsmIvkfZHsYUhJk8ULxAf3px R3+hgoP7LE+gKsXdyUvN3I6iPjpqUWQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AHYvyTyo; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.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=1721128443; 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=xMQk762TFOEvM8mpn87cs4m43b118cut+/w3Uae1kbAtcGXu1aPvlDWlAulALIut950QRK Ki6atHJBKt8/SX1ibH/2zLLEMvNBFwLYcREs+uvEe0U9Y/O3ZjOci0qLCuo1X4Msmyff5N 6EXzdnjGneegKEtx8R2PmQ1ho1qh7Tg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 698F0CE0F1F; Tue, 16 Jul 2024 11:14:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 097D6C116B1; Tue, 16 Jul 2024 11:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128466; bh=wE9udk3T5PUOzWhffSqfqF0jfi91yVWMRgCuaEhaWIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AHYvyTyoQdtcDKaKGfRvbH/k6v/hYcWwLrOx1jp5xLw1rY+jYz5xGTfikSNNSgM5P ascExz6fxmydjPn6HZfKq/ZFwMEVIfa7bUZ2QS8KH7HiYeEt/cUiiL7Sub9UT8l1Bd 6wPGKVTyk77GsDwySVg8PytwHZNiRILMoy+qXJGsFiclG9JJZKiYDLIa1jUCOsNevf BgHd+H1v9JSol1EQej2nbJdR5kwI7HAr89McG9tCtJdGaMXxdLX1lHfHiL0p3WZm98 779qc9KY7u2HmJdGGMjD8egQ1Sahkt58uZg5grtiNbPXEXWw+GPNTO+QZBPuQYFN27 CjsEuBDQRRH6g== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 02/17] MIPS: sgi-ip27: make NODE_DATA() the same as on all other architectures Date: Tue, 16 Jul 2024 14:13:31 +0300 Message-ID: <20240716111346.3676969-3-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 06B7920026 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: e6jepbd1i5ka6azcf97n6p8ku4ggfhmn X-HE-Tag: 1721128470-232242 X-HE-Meta: U2FsdGVkX1/Bxo65XUhpl233lekzfNsvjxypaKW3yboxC+L3F8sbMiUrEcAsL6bBJATgA/Asjw3PN75uTYdZDu1/ClaDoJXUh2N1IMH90W7sIegbt9cJgi5A0Z4gd2zUmKLu2I2GnyTSWS54XjqhtwmeR+8Dh4jWn6s5v7Zu52odlYM7q2fw4pNY+8l1572VhwgjggMXFeRtPQLmeI8gTMZXrD6KLkaaNPUGA9aSr4AADmq1+/qfY/yw/q97Dtkiz6UbzGrN5BxiIXelYXfmayfEcfvVgf/CP/hHVvtZNW0HUjPShIDga4q01guf7baty49uV/r7gxz9u6Dx0Vlrpc6KHpU40NyAADwQ5D1JovpkkgDFz6CnnwQ2tUjYj6doSBVaGsVxKjnnvBhJUirA3hcRMOmzdkP+/Atl25jYYnuyxhSPUGeQIfD6kkhZlkYbr73U60kSlgLwSOhUNDCrBY0PcPtbzN8jqJxsB1UuEPEJNuEPF8Mqoj3GynFPBqVzCVWh4x9vrIHV+RJ/1osGAZibwUZlV3O+mRUgVD9tfetHXuJDC4PFTgviMvEX0eAFS8CzJ6JbGDfl6BWeXLNM5e1GW2LTRZDlQvGJJEFO1zKdVbZR/abu5+GhcxhqjcFE1pIl4OFW99OppNeaWPTDtgpFZzzLk1Tb4z+wlNyP5RlXI1rEgEBK/giVOaha4ioOQbICWg/umIQEkJlyhXif8Pl+syBocC73LAFAFsovdr/3baK7NiWE47KwkU/X8062M7NdBULSDTb+VwUnE2PWr7N4Moh/k/v/xlTLxfFnKhKL05T0Zvfa7VCXdHcWEwwKfdZ/S+n6L2UawiIFhogfVhS7AztUeAi/fGKPXZ5WIwPf0Az9L9BbY9vQ+Ag9wovC+Hkci/jzyslEfO50Dlu7dlEwopgavOTeJPyrqCVHXq6Z35zQykc5EmdJV3JWwKKSRxDDdJw0i89ruwV4N7k wWdvUl6j hHP26/1J2pVdOVCAGi9pJpVKl2fCVjOhpRMQskE5sTN3Gi/XU6akHTsYLrPoO9Bxdo5N6X4TBS4I86CymXD8/zITa4ilk8NFaC+CA2vty8Je5I/BaPPLqHiI9tD3qrh0SZ+Xoj9RK0Yd3HWFP6Fv8HY7zMDv8Zsg6RHMdJmyGy4oWHKXmRjPdBCDby5BgaIFjQ+ZCtMte5wtTXJAGw0SLay5AflYb34V6ZPXGw44YYaWtxKIovWXWed+TCyfo8sbcZ2LfAX7Fmg8QkepwK5dfLJ8g1ToAlpFUQP6a 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: 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 Tue Jul 16 11:13:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734330 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 24EC6C3DA49 for ; Tue, 16 Jul 2024 11:14:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB9406B008C; Tue, 16 Jul 2024 07:14:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A69E46B0092; Tue, 16 Jul 2024 07:14:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 958896B0093; Tue, 16 Jul 2024 07:14:43 -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 76D4C6B008C for ; Tue, 16 Jul 2024 07:14:43 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 25F43A1729 for ; Tue, 16 Jul 2024 11:14:43 +0000 (UTC) X-FDA: 82345358046.01.0CA7072 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf13.hostedemail.com (Postfix) with ESMTP id CEDB520021 for ; Tue, 16 Jul 2024 11:14:40 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JUSkGz6f; spf=pass (imf13.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=1721128461; a=rsa-sha256; cv=none; b=1dJMqU5uxiWs3OoJFc7rmVmHszCf7jrGVgF+qNB1kO8io53RjRjd125w46Xst+rjQPjWlM 6T5kCw8LHdVm6V6X84aDNQxyPdR8YlG9W5DJ4HROx8JSgc9GDC39L7LrMMKb8xhh0SIfqd IeJ8Y+FSptpzVOf9SvI35BlYVD6ZArg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JUSkGz6f; spf=pass (imf13.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=1721128461; 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=JbNx7SissqVvr3P2a3scVG7ImD5v5VJmKt/CBRQTJh4=; b=w3b32enx6VuALoh/SEpuRF9WSW/eyY3lIhWGRTe3HzbMu8FY1W8GgMW4EAoq8hTFSOqGfW eDymLNCFr+SsmKBP7uGAaXz7GABp/pqmrY6AMCPu59FoeYU+spA8lSAu9autfS/uhgk9tG B/5ioovUH/5nCxejXCc+ciqOQKRFbtQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id AA97CCE0E1D; Tue, 16 Jul 2024 11:14:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A385C4AF0E; Tue, 16 Jul 2024 11:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128476; bh=RMpAE2CkAm0ph0owc8UMf/CApdEgCHWG5AjQKQzc8zQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JUSkGz6fNvh45k/VgAFPAJJWZLxB2KUqDgyy4TrA6XgfVUJTiLh4zKv9kO+uyFdE+ epJdWSRmxQe4hkiezTNX5k6uXrVfClzI0Qj6pg1Zsi/vY/FUW/9ahbwq8FO8i30WR/ CCWxbWfMmf8bq3BcU0S5xB8sbnBV9kJKryOe5db/whn81qZotEcVDB74TLoxZxANPp nLDupHb7yaSRj+yNoIU2ENv2MMfYojdUGirJDhNik7vr2QAtpZHOXRh2MD8O35cCUi Bl0Ov1SKBTkhGaRT8XDyOLq4GxQiS6O4sHzo3TCd1dzchYh6Ys7XcWv/FwwRGQX2co f+d3OUZCqU7MQ== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 03/17] MIPS: loongson64: rename __node_data to node_data Date: Tue, 16 Jul 2024 14:13:32 +0300 Message-ID: <20240716111346.3676969-4-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: ca1y5y3ypus7qsc1dskw3wgmnd53hdbp X-Rspamd-Queue-Id: CEDB520021 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721128480-383357 X-HE-Meta: U2FsdGVkX1/FbHL3+YUMMgOIP9f2KOj4slukWKa3doZqvvdzgF1nXWPN/L+stYVVF5+WPKc4vtpEree29Gb8xi6+KTpRjbjo7UYFRfC+gnPJdJB9CgbIJerZM/CI1KyFARxbnQHeD8pKH074/G56WGqFMT+57vjIVXZlG+s9qxTzBPSfEKJZ+XWmz1mm6ipP2FOnThX93g8/Ja+37i+lRZzZqYfyLLSk979P5c9AA/BY+NurDROrZ40uKf368+f4EAh9yCh9i9ig8JRlGnbKbdZdd9avHRl+uF5Gdvrgi1tp5n4r3M2IRCB2IQ0YNetq3LBii/U1EUA5RRqmt3gUCku8P4aG39S+KdI3UwytkIaph83Ht56ITmxGJ4ZTcNB16E/MksmQRnbagQn6H08V2f/GXJRLAqBPyGoca6NSBFOJiSyLVYnjJehf6BbXWHGjXNZLuvbFXUZc4zo6RRdUELrTd+7cwEeOP6uyLBm3EPiKP8EMmsxxOn30PIy90RGt1QvKHmAfoMM7sG9qaU9mkug3uyW/fAmwybn/42I68e8xOao1fdR8qq/NzOhKny0kYO8GcMOI4mWTKxTb2Rth83zYFTOiDcnSlMzbro+J8KoZc3Z7dIHWWZ+JVD80oHGm7Mq9eGibh1N3hk4vgPhJQftf/U1/8Lvc5HesyjzhKkTIOZGggax9IlBa/iudLXqmxtxPubYU06NVzLR/sjr5NdME4nLOhK51BTWGvY05xTEIvZJNzf7GBkhneUS5+Ysz0MpOl5qTDCIxY6f2Kq7204OtRlzg57USjqLilSgPCQESzaKNMbhjD+pjlgIZDa+U6cGGL4y4QE096kYzImrbTFGrWU/52qtheiG3MzZ3XFpmtheaRQ66voCCZuur/hG6C/Dt9w1/0N97zO1ER67l0T7DhBUK4HDZsCQHkkvIvxswO3BM1wCR19pUyZZPZuahZDG9L765RiY7EjObqhE mDIDw0Tu HyV2DbmErgnXKVYqIlPRNX2bSPORcaLtUo0uSrw3sLXx3PcmMwKLjFnUSZuFMjFDK36u1CqBWUxkkg/Jvq9EtCk7ocxXahSlg/ZRZxZDLHrNG/4Ew9MEBIDe4nGB8x5O2QOddHF8DQ2daU9bDvpVHKF6thEjF17tRBBHSiANgG3VD5EWUlv1qQD86t7pViwYjuNw7kxXtAtjZDLc+JX1PJwxGCk7VTjem0QCSTprVLDYYCUkJo5zs26hYQp+x9IRbaC2pd+wgypLg9m12ZS9I24qNVvwWZut/ho7+ 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 Tue Jul 16 11:13:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734331 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 C98B9C3DA59 for ; Tue, 16 Jul 2024 11:14:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53B266B0095; Tue, 16 Jul 2024 07:14:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EB126B0096; Tue, 16 Jul 2024 07:14:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 366016B0098; Tue, 16 Jul 2024 07:14:51 -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 102496B0095 for ; Tue, 16 Jul 2024 07:14:51 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 880F7804F6 for ; Tue, 16 Jul 2024 11:14:50 +0000 (UTC) X-FDA: 82345358340.19.003330F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id D188AA0024 for ; Tue, 16 Jul 2024 11:14:47 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GjexjOL0; 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=1721128469; 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=40r+vjOrAt0JH1LjI4fTzSZxbQx5NcF7cO6La0oPBKc=; b=IXVe+1XyBnHKHTOzxDzDUZTm7B5apnuMOezZJifrq4WdaPXRZ19fI0oZBDUbxIiY3Ri5a6 wrcfBMpdedoOo72hZucOmTwD1gguckVzJLHipz5Zqf4ERIy/shQ14v42nHq7CJ6ur6P4Dt mNzuTrpjIo9EW3CaZB3GUru09EamLK0= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GjexjOL0; 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=1721128469; a=rsa-sha256; cv=none; b=G9ELa6Rj9dnKosBrzGZ0WoXVGpq8ERxjirILWN9nLaO+H9OE4mw/moac1li/pZzHQV7wDX pijN3Hcxwe2Uho1WWWmlzJxKQ/0HIcMv42h+JqGioa41lLE0oqBPAgfKXahzMM2oyDh0xr zNmEhb0VTz63NC+/guw0y3zguM4PsB8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1DDE5611DC; Tue, 16 Jul 2024 11:14:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 462D3C116B1; Tue, 16 Jul 2024 11:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128486; bh=Nr0Xw7zE42/4/hTaVLwV3ANQ3x/5Q4ZVMXCafLjg0Z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GjexjOL09BiuFQEHIh8By2bwUyeMgrDmM9SBo2Pr4kPdXTVFWM62g0FJZ19vUHJwR B65j+HkX+5dZGbwDYkpB0VNqKnQQnzS/MTJcAspTh3d8BHFAsY3BjsC/hPIJmdQh4O qu405udnWhPInMrkAWsj23ZIqom4hYGxlqn52gs67k2L1+GG3Zq3qdXmRZZkuytI2S s0+GASzo9c4RqLCwSvkAm5f/LZlBvKH1t4eDhNBYz99o7iR+ukhngfdRcg8BBv5mhT bJpK3XQYKNamG9GocS6ai+U+AcNbFU1qardPhZWj51aJjb6kPHLONR233BHYnZ8JO4 JarEmI9SqpgkA== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 04/17] arch, mm: move definition of node_data to generic code Date: Tue, 16 Jul 2024 14:13:33 +0300 Message-ID: <20240716111346.3676969-5-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: D188AA0024 X-Stat-Signature: 7izmj9yxjy3ph43sbu8ujg4qhtcierno X-HE-Tag: 1721128487-153822 X-HE-Meta: U2FsdGVkX1+Ki/0a+V+BUf4SpbGoBKhFqACVLsS1I7zc7fUFOjdtrUEsvDIb/v6VwuJI0yXm7vHfRfbMq/oJsBFwbktzmAIWjA9bqBbvC6M/z4gHRC0Jycph3GI3EKTVEYr8/qORJCOu933vEZfZUwSjVYq0z6ID5/QrBP4KbdqEdzNcyQe3Ap77OhRH8WfIlXVlu3bQ2BrHQzqnimUMultzmz9JFn/slSIZa9AYXgWqho366bog4UJJRzRXUWy+BOfY7jRvKZCamWHecHBO9KCjwusBNDmnndi0qqhRtksLxnJ4hUyJRXKQs4eVFWd1gXEfXNbNt1CGAb99SpECWSPNl1kI/mitLejP97EmViE3UoqvUbP7stB4E4VicRpMhFkkX9GZHPeZgAkzZy/1XBawUCRtHTNeaSdFa5RAdrl6JLkHd7G1c9sAbpGChNLKhsIXzhA/8q3M+mgQhGvPUjT/M98WjCLejUD3Q6w4eAPRS/hnMM5fjg7gnlR3h87dytO287DYkhg+eQegoWq6DqfJ4ioimOK5LiCgQqkfSuDa9JPOiJHP0ch+okQEdpTRetYL14VNbIVGrnx/urWMZ6cMUONbRd6Q0l1HeOtacNLG2iISaO10WzWwd4Boa1ylbSBkOFCdzr5dIs8BqyDAs1ygXXvrroxMg6PcT37qiVOLoZuXfLl11KuDtXo6UqPDZbMT1p3D8bXf2CPE/LNKY2LO2yJdvG4f6Z3HK5/7Hq50T3IO8WTZsVFue+qW9VpHUyLSZoRDudReR/x6J+QK0g0D6KRmGleX6CgJYB+Xt+15K5uRVpXtzCv9FDa3eopmVTluGRmKSf3GMZSsyrFvmJU0lGU04/tOIvgeLNMXPhChJTxLOVxZ0qd3iRGRfM+QRDAN8R/upPjVL1Bavl2cnWEpyIGmr3C96MzUHBdgfB6hTYvyYoy1CnxA/TE776NIW9zarRMVFDjJXcjHSqB E4GewxIv wl+N6hLVJKN3zL4nf39gMJi49uDmYi9W82+U3x4J/Ri77IdIEgTmmkt5ukPi8D2wTEiLTgtKG3RfMcZ/WrZ8dr7DpB19ptO5LrOb1q3IWCOXE1AphgkxP0YjzfBr/2emkw7RAg6yzO6/Mxl44TgNLwmlW9KMZ3i0HojAN7E27dlnLBYTjs5MYeYJrMAp6wt5K/1/SS8iwXgY+Tzr9ZTZHDtQVZxaqX7nB7m9JUHomqmMRgZ358dOTmbc7EbuYZ7fgYZSVNQK4NgamYUyUATHQ6keD9TQ7MaTiLgo/w+3bSVnn5dClzK9UmPZLUw== 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 --- 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 4b6d2d52053e..4aaaa821ab6b 100644 --- a/arch/arm64/include/asm/Kbuild +++ b/arch/arm64/include/asm/Kbuild @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 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 c862672ed953..2804f2a2ad61 100644 --- a/arch/loongarch/include/asm/Kbuild +++ b/arch/loongarch/include/asm/Kbuild @@ -15,6 +15,7 @@ generic-y += fcntl.h generic-y += ioctl.h generic-y += ioctls.h generic-y += mman.h +generic-y += mmzone.h generic-y += msgbuf.h generic-y += sembuf.h generic-y += shmbuf.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 b50ce28d2741..9208eaadf690 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 c30ef6958b97..31e1d85b4fb2 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 a490724e84ad..8c18973cd71e 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 504f8b7e72d4..e44f168f60fc 100644 --- a/arch/riscv/include/asm/Kbuild +++ b/arch/riscv/include/asm/Kbuild @@ -2,6 +2,7 @@ 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 00b247d924a9..3cb698204609 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 5b59d133b6af..9b71ad2869f1 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 Tue Jul 16 11:13:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734332 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 E8E8BC3DA49 for ; Tue, 16 Jul 2024 11:15:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86F826B0098; Tue, 16 Jul 2024 07:15:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81FD26B0099; Tue, 16 Jul 2024 07:15:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E78D6B009A; Tue, 16 Jul 2024 07:15: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 4FEDC6B0098 for ; Tue, 16 Jul 2024 07:15:00 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0FA251A1767 for ; Tue, 16 Jul 2024 11:15:00 +0000 (UTC) X-FDA: 82345358760.02.C2DE758 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 5916A1C000A for ; Tue, 16 Jul 2024 11:14:58 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Hfr0ZPQi; 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=1721128478; 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=Bl1rnEAORoTg+Rz4h11/iFfJr6mLaZez+YevyT+apfs=; b=QUnZdpkZrxCzO6dJ1Gbo3g8y2AStU3HszZ70hfQ96zNdGXI1Zf2g6AVWHB7uiqOtu8RTDZ kIyV0RnheEAd7FlpCfUGmbq4VT1MzEQucoJH5pdUzVXhjOWWpJpCFF3vVc0UuUyNsPB6kj EqUDevH99Pl9rQa0lpGqsgoFM3lC+4Y= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Hfr0ZPQi; 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=1721128478; a=rsa-sha256; cv=none; b=6Mchyq9N91UQAGMI/IaygJO44erY7uFVxmeMPkzAsOm3MR+3JjPy9sLBBztYMvAE+cV6aa WFVsNDLVjm2mh8J3OJ0/bWQPS3m4SIsOkHVvQVHxXgHXxLeJ5AUVVLzgUv3npgUEDba06Z tsmp12DS9/ieb6rX300Q6ua7pVxWU2A= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5AC766108C; Tue, 16 Jul 2024 11:14:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71119C116B1; Tue, 16 Jul 2024 11:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128497; bh=UA0klgv2viiKR0+T1J1Sg8IipQ5Blqy8qGKV0TMcN0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hfr0ZPQiq4ddVCM5js4xl2uQMjfDUsXd2/NBxRA3R7TYpvOejdnsJaRRxlMmMZHC5 EBSfwFm2L/V9FBPnbJJHEGqQhtUKP1hyHk76dlU5UNSO6fIpyhVct3YW7jgyF4EmoX okRXDl+cLkjO5sDflUKVlzOoXBQda/X7GxpeZyPafkjdXph4yb79zqSmAIZnBs8hsq EVM+DAxSS/m5UEWw0y5l8dcuiwTThvLZJ3EMDAsEVXJO0Y1fMMjgsnuWGozjPEda7j 0VQkO020JimUYLWXJ2r4f8LRfKjgjT5v6aPm3eX0VE5rNdoPwK/72mobKyyJgpGg/x uEz5GFQHUKXFA== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 05/17] arch, mm: pull out allocation of NODE_DATA to generic code Date: Tue, 16 Jul 2024 14:13:34 +0300 Message-ID: <20240716111346.3676969-6-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 5916A1C000A X-Stat-Signature: jtkw8d18xueyr34mys4o4h661sprywcs X-Rspam-User: X-HE-Tag: 1721128498-243571 X-HE-Meta: U2FsdGVkX19Scm1RfqN1OwHzVwZyW2X17Ak+qO+T17Rpp8VH5he6WaWndveD+dLdU6wNum5VF91lTURpBQWcFUPK/cA2UCWw6aayv8p9+eCDLM8abCLprua3ldm4iVK1UpKEOrMr4J28eofiY3oc3DkP/bNAy8HMgBnLIc/THlxnyB+oC3RszCOl/j+2VvdjA4xqXMNeQPtLp4YGsJDmIcaV1iyWowSBwzaTQbEfONu5Hilw1usNw/WFC0YhiNGlkOvwRGTkwdZNhnfAEo6b0rsmNIYgOjgxzuoi674ubz0+Qne5NWe+DmSxtLzPVyRbbIp3BCD79Nd3cBhiDdIQGGvFQjY3Zx2fjGp479Y1vzb/PZaXyDRiqqMqCdbOeOwKgxt0A/Eho15WS+VqtN9WxGffehazCwj3OeYw0cbFz4oWNc8kEv8ulrA5aBdahrUJtuF429Gst9Mygw+rlnVYENK1+oN4+dKcux8YDLSZh9gMV3tt0jYVKrArd5DFfs5v30nDqgv53/iNswbsYaMwDaWtUZ5rzNNNfe/ygrcKfYtR0nFYqCzLPupxNrd8ALYurJyt23C6IZ0A/u84xyyfFb8b1P8cRe2xu+O1m7TSQR9J/tvKpP+vihhCahMG9mlwf8BgI48yYTbCBiX6eu6ysir6EyZuPS9Xl67U8ikQzlzieY7/L0r4UMiNjRdQoG/hx8wXDFbLWBya1/Z4NROvxkslU0Ka1AY216u+mCusC8U0kTeUAwOT7KYh64IBEAvyNV9AEyOOcXHX+wuR72oRymIHeGUGlgI918/f0lPbC8l76LJGw4wv5HnKwG6D7yk/pEPDQMlUfRc35eQdbxOozj44JQEE/RiRys2Nx6l9sJQkT3Zrs77MenTmvDJs3v0hmkljf6Nnliq062d7nlbeo21nl55espm8EqPc01HqqnLLMWGgA5pKohI9jjb2Wuqs1eITjtdYmKXQJ6O1MKW Sn/yZWs1 1qvaoQ9UZFCx1w3noXcDj2kDQVEpjyA7VrvAqita5KboYcgv6Kiaoh1LTVy8NZkXV/mhYcx+T2OWsR5wuLa7XCruYWcn4FyZkNQWgSeD/A1CechxZamZkoCP3NDWgAyBSrAye2p+f5wFCjyKxgmCfh0/AG0Asx+0IPqpdiy9YVszVLfHFz1bkXof7K5A2BQzRvQWdDumOKpCLJxRwcWXTjBvFxbDSbaeYc0PgbiuVpaiCSyRiq/dewXWxFyh6x8r71reXkY0iQIzeeV36AYhY/cAPmPOGhygc5JT4 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. Signed-off-by: Mike Rapoport (Microsoft) Acked-by: David Hildenbrand Reviewed-by: Jonathan Cameron --- 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 9208eaadf690..909f6cec3a26 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 8c18973cd71e..4c54764af160 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -1081,27 +1081,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 bf1b54055316..5cc89a0932c3 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 3cb698204609..83279c43572d 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 9b71ad2869f1..2ebf12eab99f 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..0483cabc4c4b 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), PAGE_SIZE); + 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 Tue Jul 16 11:13:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734333 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 0EA36C3DA49 for ; Tue, 16 Jul 2024 11:15:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9CFB86B009A; Tue, 16 Jul 2024 07:15:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 980A16B009B; Tue, 16 Jul 2024 07:15:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8473E6B009C; Tue, 16 Jul 2024 07:15:10 -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 6781B6B009A for ; Tue, 16 Jul 2024 07:15:10 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 198534052D for ; Tue, 16 Jul 2024 11:15:10 +0000 (UTC) X-FDA: 82345359180.07.9480848 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 45B631C0030 for ; Tue, 16 Jul 2024 11:15:08 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eUYe44Ch; spf=pass (imf20.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=1721128478; 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=P1YS+euSMVkpWWJuwys7wR1kvUQs2d7FUlc59UK+jLs=; b=nUPgFpo/fik7f7OcgKw6uk+6LzMRTGi+uYlyiOlj/S65zLBiCRHJMhf404J/bCQtg3/tvc UH0JbxjZJZpcuXQnyQEp2FUdoTrwBxzqh8/dE9yipp+aalgJbJ37GJjIupM/2m6diY0WFe 9kY1MXRE4GEn9sAHrMTzWjt1/z5GgCA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eUYe44Ch; spf=pass (imf20.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=1721128478; a=rsa-sha256; cv=none; b=fN7C2f87DXX1RkVw40aJCnhsoWzdeSjOdF06R6VhHuS+nb0zRwJpP2j3rtMxXbn0stHXaR MfMOYPOqSuyuYulGIWV3Nq2V8mS4uyJIlXDM9RX4Q3YBJ84BNEniWcCBPEoY67soDC+TFB Bu1A7xhkiQ60NjLBw/+sPlwJ1lHZZTM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7886460B9F; Tue, 16 Jul 2024 11:15:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DCECC116B1; Tue, 16 Jul 2024 11:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128507; bh=GElWHq2qRIT8py39Ko6uJRewjseLB9ydLgZveNWdQ+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eUYe44ChrhAY+EIKXqRBxJW/GGnRiqr4keNuzA8k+5ofeJ4HBvR/n8QM0J61no1f2 abiQBz3/QII7idJTs0afg3rMGY90A9xGmtBhYCNbiK9q4iubegCmxJf7NrcoovNvKG qQRxvsWN8oXJMXkni0JawCEhHK8wA6sAxUA+cca/xtj4Q9hkmUftsVcp/KiDWJ6cLF 921Vh4BmVDEODNmwHfRepZDaSRiM/CEFqWbhNtHQKO/A34nitM0llJ5YCV7ixvsAcB JHNcrvbEtQV/XUjf4mxX16sZ1+VCT2rSdlrKQOTKpNfcPTqTHU8isN0T/2V75O32aW WPUTqww3gzW2A== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 06/17] x86/numa: simplify numa_distance allocation Date: Tue, 16 Jul 2024 14:13:35 +0300 Message-ID: <20240716111346.3676969-7-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: k841wwpzug4st4b1hopi844ko59i5g8d X-Rspam-User: X-Rspamd-Queue-Id: 45B631C0030 X-Rspamd-Server: rspam02 X-HE-Tag: 1721128508-917918 X-HE-Meta: U2FsdGVkX1/0OUv17F6EwPE59g5rx9hXdQjWzNhLHQvPIzQ1OUii5f48upgC3RU0IVlTv1c63vKW7lgQXIsjlurbEj4qyHBZlYYpAhQqRUMAA3jup6NRpYm2Oiqi4dBX53rPIvf1+r0IMatENPHPRz1WTXKRNdwp9/CITshwc1Zzr24cGQi7P6mNC2BFdFg1O4pzjQq5TxnoyfMpazPcDD37UxptcH9PxTijvHN9LJ9JnFIeLuICt9U6mN4EapxNJ1WZMcgSLEdbo6RKpa5b/qQwiqM4qPvkp8xpz40f2ROX9lLwadsyWtoRA7a7NRXGy/7JLJFwMhBNl81Z9L8FLFXkliuNJzkqJFgwQOeSruyReriWfnE74FqJFHlo+TKu8S2IsWFlG1wQRPaigeT6hOa3/BFAVqzQXVZ88C7ykAtHmz92/SlUZArYrnrOp9ShC2WK/hJ13VLRZe4Cxex8aAtx+OJqCPnNIhp1fYBhazbnNvotk5e4/TX6FYhfZmuTc+eQ3EeKdD6Fup074BhPD7UTiZpYiq7bbYztVCuAQJTB1bftMSaYJZ1ANtmw53/oQIlyssf5UnTqChS9mu2pjl9KTv//LEX0AE5V1v817yV30gdHL0FRYPxZgbOsbNAZuFTgqGYYfP+YTNP7KrDdtVBvFXoMQD8Hf+7ub2TjSvlyJ0XOSKEf2rVMQUFPPQyvxKVDthTCVYfTRTCfBEgFSkuravmtXo4s7z6EojSjCYbI5qEiRE4+ptFbJ8gN5UZtA9pOZSnGy68DKzRGVlKotK0j9PCfqwbLJ0ozxV3wTVx1ExA3L8KK7g1/xWQzDBDPgOKR45bX2ujdoV8HUOxCO5AdlvAEp+q5FQsAtqC5MSCTeYkGaJZrZTQadCYq9BhluYs+Q1m5sLkNVqdR+ehCjbFfbuvATyjf45PZAFfTFtN9+uLIrHjVf8RiZKv66G3PL1BzYp9rjhGoiKsfc5S qUlwwwN6 2+vZbMK/GZVBnTMtd2KzZnAsNY6n8zANUIJzHZx2X5++T8Z+OwnE+JMxLfKeRkNohPa/XMLeq/bzoTv0VakVBY/rJLJOOoac6ZlyOnrfVjZ9J3SMhLOCWYeNh2npBN11iu4igXQP8uhW+V0Ct1YMkKbBLiQJnDcwMrZux1lRqLCvztQhZdZNcD6kQPQ563xBcKsay4uhpx4PY33jVBE9PgmbXVcay4MF+tLXNMoiCLEyx3yEj7YFEAFqT+sSUrWeeZgtNK8dadHgnwC7HQ7gvBZpsmU1furBzLpGT 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(). This makes the code clearer and ensures that when numa_distance is not allocated it is always NULL. Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/mm/numa.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 5e1dde26674b..ab2d4ecef786 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -319,8 +319,7 @@ 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) + if (numa_distance) memblock_free(numa_distance, size); numa_distance_cnt = 0; numa_distance = NULL; /* enable table creation */ @@ -331,7 +330,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 +340,12 @@ 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 Tue Jul 16 11:13:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734334 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 3EB37C3DA60 for ; Tue, 16 Jul 2024 11:15:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C67F76B009D; Tue, 16 Jul 2024 07:15:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFB516B009E; Tue, 16 Jul 2024 07:15:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB8036B009F; Tue, 16 Jul 2024 07:15:23 -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 8EF7B6B009D for ; Tue, 16 Jul 2024 07:15:23 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3777D1604A2 for ; Tue, 16 Jul 2024 11:15:23 +0000 (UTC) X-FDA: 82345359726.22.23F7AA3 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf30.hostedemail.com (Postfix) with ESMTP id EEBF180009 for ; Tue, 16 Jul 2024 11:15:20 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RcsB2+p5; spf=pass (imf30.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=1721128484; 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=8N1xO2TuVSKANfO1WO0x6Q2I49YoU0BQfNYjAuSOBuA=; b=Ii4QjLPWjh3Z3VzcSWc4lb71XZv+URH9i2eSP0qndyYbvvcKNcvF+hY56f5IVL8NRLcnz1 p2NBQP/F5vnGqDEt6V2rO9G+pYGGq/e5SWwEXkdfR8HXIgizbxMji7BsxUhwtHlfH3RgzC ydrCQ6Yi96mGjinmRia6+Qr8fn+txeU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128484; a=rsa-sha256; cv=none; b=HZyfw3agWiapXdRyPdYGOGFl5oin92FkAT+2sJKd2PSd3TGBxIziungNvf58fH+0GTtupB ca6vqZOd+A6iDFqy4e/42/m4nL6Rgdx6pWL6b9tvUb7cF/H0pvM3qw7F3PFh87iU2+hci8 nl5gZJmRmVZ9LJWm5iL6FAsfUEq9SuE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RcsB2+p5; spf=pass (imf30.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 1DCEDCE12E4; Tue, 16 Jul 2024 11:15:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD63DC4AF0E; Tue, 16 Jul 2024 11:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128517; bh=xrJFUSIui5+3tWKM7Qfe5mEbY1VRxe1m5uYa78xjxbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RcsB2+p5QHBap1vUNzky7TEU4+Tn5z4k+AWvpXJWK7FJN1CZhMEKfjUb0nM48ukl5 i8gN4HNW516pgCT0OD2NQGIKEhZpQCmvW+FnncHa+T2rZ4KUCYsxX54ArgLBbRccvW /M4/82T1OQbmPY6lAIvDiNuYTgsZDmRyYwZFvrDAfzZEhTXQ7LmI1Uo9xig4RDhIVe 8umplX4XAEATc0RUK6AVqsoePJFhu07FX3c1e1566RQ0tcb/MaNe5IdDa9j4GrGdjD S8M0nenFB/BUBHnEHESMvZVA1n1kLJWjGQP1MwZdrCrNt3LpuQ9gp1Eu/ZbsxcO864 i7FoOB9zttDRg== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 07/17] x86/numa: move FAKE_NODE_* defines to numa_emu Date: Tue, 16 Jul 2024 14:13:36 +0300 Message-ID: <20240716111346.3676969-8-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: EEBF180009 X-Stat-Signature: nq9x4te85zqykazhk3agi5qw3qiy65a7 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721128520-257208 X-HE-Meta: U2FsdGVkX1/7VdSXczPtfx01ZOJzWlQpn/A5Mv3zJsL+Q4Yv3nLldDJLU2WkrkjHqq2UiASiIpRZYQmF7XkYMbTiuBNMr0yA3Nw6CDV8uKtA6dp7UYtUzcMCJ3eJIU52FlxSvZ8kbCg1fiVjm5zVRJMpAmH+3AEnSDfv4WkeyVHUpm+LBYxJYH2xMX5RjmvjK+Gy94Te2apS3DNogqac6Aa8JYbw7wZ2aevXAWgj9j+Rpu7GflQ4foOPOjtVDH9UZTzH78VmppKChprE/KPNimf2WSyEo7QjfmB8tmRj/2Dw29J00NWM8ElpQOM1mmYkCmCt0tBIK3B3LIf4/BpF9NqVqOkZi7CNEMgwq5tR8GoBzNHmx6kvGyNdoVmvaVirFwuFI/MrQPCjxfZnvzEd50EcFjcRyGdq4av4k+F9gR/Y5KJ7goLChFMovvTe64Z7hpgOeL3xeK2KTiwReHNdgQwKHI4DHX+WmVHooDp+k6pY9kVI94W9PEv6e2tZ+trpW5KMicQaulVWp3VQRPk8bQjHhfN5axTUDW3Iq3RgOXaMabJzRWrrQx3BNoMU7+bWLVAI+BZljOgUH+OgrCheoosAN9ORHlLkOufgfx8x4560jABfgQOgfVyr/p6IdIWInxLAekZ0vCrs2VtgCRym5xG2pj+VibKEKEUURukLyIhVzF3jboh94d2xZ36Y6ufMC11RVjkK2TYgfeCPj1qqAfNWPZGg837OkFUPteIjmdnayt0KZmo7lj2dlOZ0Yv7tx9wa6tYTiOMiTKFRGaLpiOz7kWYrOVojTNMWf4yQIWLF54iWUZcuUzfctKWkzcVym47Au9qTHSYx/n3JuFGKYEKenDop/A5tmZSgmPlu1lF0wsVKVzhHsfJBDxKP85AywciKZwc9C0g7BGGIHhYVA05qnRkQHO+udbh44W8ZM0bXSuyjbv/6N8ADhWB5Qdnu6QRrA6lY1kcP0Az/l8z 86dwVKg3 UTc18ZU19oCwuH+XOjevmjUsOj2ay+fmHreaPejeytKxyMeQrBgZlFS6nI+HzMDz2G0FM1Pn8y20qfyojH2U/ctP7oOhiz3h7NQUQIQoAf7NDiJFvDFCWzfJZBjumCEwPlMpjpGjEnmVqFkfLV9Iy+CC+q5AVyC8+e2xv3bKcN+1mYxQ/YBpX3m1tR1EERMrwdG+Qx7VHlDioaTvPxtP1PxlCvYJ0tffrStlS/a9dtygeiiNxhd1j96emQl6yNoJ+SPJDg/Y5AKKrhg9iaxD0yKwKTOMiA2r+jcWu 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 --- 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 Tue Jul 16 11:13:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734335 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 E081AC3DA59 for ; Tue, 16 Jul 2024 11:15:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 738EA6B009F; Tue, 16 Jul 2024 07:15:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E85D6B00A0; Tue, 16 Jul 2024 07:15:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 561846B00A1; Tue, 16 Jul 2024 07:15:31 -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 34C8A6B009F for ; Tue, 16 Jul 2024 07:15:31 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5C526A4F58 for ; Tue, 16 Jul 2024 11:15:30 +0000 (UTC) X-FDA: 82345360020.28.4D0E5C9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 80C3940009 for ; Tue, 16 Jul 2024 11:15:28 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=URbAiLv8; 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=1721128491; 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=n3zGa4nacsbBJXSOfEQISOWNqxdB+lCQQh30s7NcvRc=; b=C8sxIxEsChpeSm1gwbDLXEsfVS0LYvppWY0gGolBSjvvrph0E/NFpHva/alnYsZ7eBLJaF 3Ab6phyleXY+mCt8OKTs0Kt7hbXeMlcwnCMcQ9BQtnTq9Kalz5A87ygC66xQnu0FORJtl4 UslSOm5mvtVZjMOFBE3R0xczUAwM3b8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128491; a=rsa-sha256; cv=none; b=T0CKSFvBlAlm5WB3W/PGXo+IMcEJk+iunrjj3FE5Zg1x11tagJDc73GdJjeC2drFwfixXs dHr5xK3ANYkNb2a99aUmQG5b1YRM3z40MUDgV9EiObU3TM2o7Ble5pGB3k+x75yAQkSZHY 9b1ig2XD1dyumCqRYeXvouv+lDsD0V4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=URbAiLv8; 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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B711260304; Tue, 16 Jul 2024 11:15:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEF0EC4AF09; Tue, 16 Jul 2024 11:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128527; bh=R1HYu/q0PoN2gQIJtANqh+F+EoZWMXY7KpfVYIoY6/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=URbAiLv88ym2VS9Q58AhtnAFyrGYaubMDdKwbWkdIbHr3INoicWooyiqij2rcGTHT +4uVloqcrFWaKgkSVLwOi2GKWFYn79atdQgv0rNsp4t3HskUvXzhm0udxqwJRAWgrE O98eH7xSow5aI9/ojq/n8x1XfHWRoi+5IFptPwgYdPgBmnR3VVIouaFE6RZYlnzcCQ nzJbMcAu8TmI6JplcHPmnjMiIGd3JROQVFdBUnF9BTZoKr7zwu+DlOC00OgoRrCDFF SUZ+vTsVTP+36B1NwfZzzR2+vh+gCVMYEJgMrxrB5OWAAMROR5TkqKDI5IJqTrTnED 8D9sGaOuF7KRA== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 08/17] x86/numa_emu: simplify allocation of phys_dist Date: Tue, 16 Jul 2024 14:13:37 +0300 Message-ID: <20240716111346.3676969-9-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 80C3940009 X-Stat-Signature: nmimwoet7w4ae5s8qfkqnuw7c3cuke6e X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721128528-801815 X-HE-Meta: U2FsdGVkX1+r7Iv+yoxhsNH6jGXCF1YBwk8dEuSUiM6XhlvRfXyRsfIR4aZAgDtSlNduQ9xaCtgisSM5ex4ENYAtivctXL709+sFPi9LW+IuhNKuYs0AG+TsOnL2w5c0rkC2kMR/+mjtwSkpx4cyGvWckYCHi7OCuBl/iLOhJumvmTYfbko3lfdUuR5Lx+IcYiz/XuWETbBHdAX1EitEVpU+yZE2yn2YJgsa+T/rLyf1UKqMh1q8MXv1oAHspoRmm9anDSw2SegHRb7DCgQo3gWYsSRoRJCoe69nxGrGt7TYEmTAmwo2nT4GKxXup9bEHmSgseAP002M+oUUQVSTafwPBcdUL+H8KInkvpR4BmwCF2DxaDsBDukICKnWM5p8jaAsf3SWlRC8GaDIMR77zvVSHn6H8Qw6AyVCxoao/8rbMuuMcJBDUgky3WYFU+/22SSVgrji5o5Ayxt8uAlDHvw1uVj00I5xg+YD5EQ3TDdb1R24FcCrr9DtVP33NN7ZaFZTWmZzVYAt7gnx6fwx6n9dK8FjoJmJrZdfaI+IDheyUtZFfcIWQWV4MtQYiJR0nc9LQ+MFQitar0MNDNgd0iVKxHdmboSkFxV+Tf7ssfQGngY048GKVzymDx8r7mf8nbLLwx/MDlJ6lYN98qcpyk4y3B9y9uUlr8qMtNiAmUnK/obbslqAez9Tid7uPnUpuax4kndAOKSBF+Fo7x0RE4wLOVbj8EyKN4hkYyp9I10YGlW+k95drYGrvMC7b2f6wpz0gSJyhsIK2bXlGUhZ+HbsmgRLOJx4yT82djU3JI4RdjTMG21kOLDpCY2o4wot+o2qXemY64B1wI7JRQ7yYLeWPN/ItagEkDJPaE7AbPMfvYf4q1/nYJIO44MxndE98ijK1YFccI28FiLDR/dUm5h5Cc1IpTW7KgxJmLaJLTNYLMds/HaphIQERzTXomz9kBlcghEcimiJUtmgq4U 4tP1wO3K B/AYURk7/tCKJjw7wR5010b/zHT78zaf215yKojbrVvQ8pKASuMvNlMVPp7WcbjmltQ//cgrpQY5rzqeKyD8yfUv8tSDG6sMmISqoQbsz1BnQsNKW/fpSUgsmDTNHKmrdIY9ThzbADFe7H9/zlltBDGogiquySlORBWe0nb6m6BdHzy96/EC7+aExC+H47kW1BttLvJQxgtbBS5+2XFb5Tht24rmwIAg51c2SS1FHlmp5vgto0bb+UGuozcYHlONVD0/8N6iosIUeQCRZIdGQWbI3wd0tD4d8XfTS 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 --- 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 Tue Jul 16 11:13:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734336 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 895C9C3DA49 for ; Tue, 16 Jul 2024 11:15:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22B006B00A1; Tue, 16 Jul 2024 07:15:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16A8D6B00A2; Tue, 16 Jul 2024 07:15:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 031306B00A3; Tue, 16 Jul 2024 07:15:43 -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 D82786B00A1 for ; Tue, 16 Jul 2024 07:15:43 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8855C1C36B2 for ; Tue, 16 Jul 2024 11:15:43 +0000 (UTC) X-FDA: 82345360566.26.862CF51 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id 3E42814001B for ; Tue, 16 Jul 2024 11:15:40 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U2KDJ8Qq; spf=pass (imf23.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=1721128504; 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=A+/tdVLHdUu5IiSLs0ToB0NcWOw5qRePM1lcfecBvTY=; b=ZWXCJYVByKpIjouNVTH0qLw8/8a5Bc7gRvg/swqnqJY9n4mFOGt2Am8tJ+aJPLeomjkhNh AUj82rvIyUwRS4xCgueOVL72r6Id9LX6hE4ceA2AaecigyTYXh2wWEnp4OxptfZdsqRTbC eG8/M6ROTUanmXzQAsjuJqbBRt7/Rfg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128504; a=rsa-sha256; cv=none; b=DwthIPCqJpDY6zhxj+/c0c7+UO2dhZJmP5rXFQ/uJBc7krKV6n2lAwgi65favNYp2vwlUi /pm2UdH/7n+XBnyHGAy9FW9j0EwGT7EPMjv0R4ydH+fGXJQD5v5uf/1x/h43VEBkScBiyV GXwu3gkSY8f37JoueC0JALgJ2cZgDvo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=U2KDJ8Qq; spf=pass (imf23.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5465DCE12EA; Tue, 16 Jul 2024 11:15:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC052C116B1; Tue, 16 Jul 2024 11:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128537; bh=TtK2o1XZcHSBtZCo/iztzChwQXjabLP9TIYCaEXwnLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2KDJ8QqsZ6ujc8t3TBx7FtuEY8O5WaX+Pxrz/aCCWpcNBESgqGzhlnFbOkmiGPh2 BJDM7n8YGnKhU5qvx5xGSCARdDsfvYgNqD8EAbGRyHyYeTH+Yslikcs3PSkxSDepVn cxfdTAdceSRM/JpCQqHkRcmntPwLxiy+SNTlSghcM4k+ANvJAHDPnWL7Ti/RdZmlx0 v2w/71QyzD8CSAR0b0qE+uBtAq2mpnIqwFDRPgutMiYJKCqg5n5OjpsTIWeyFQbMWL v38YxQomZehHmcgvvjOMbeO5+ArCF4brt6hJKVfzRxVp68ChSZcyOHFg3sWrxXeNpQ BKm8ZNJsG2pkw== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 09/17] x86/numa_emu: split __apicid_to_node update to a helper function Date: Tue, 16 Jul 2024 14:13:38 +0300 Message-ID: <20240716111346.3676969-10-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3E42814001B X-Stat-Signature: x5s4a8krd8nx7re6181i898cczsuh734 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721128540-237439 X-HE-Meta: U2FsdGVkX1+ldMp6IYPBVLPyrvDd8T67oAIVzO+kH51DTe9XhOfqPXFanQ/6QZF7oYhW5ip2DPMW+jbV6KGZOX2TNMxkQR0q10Rh7QQddgLxrwYbTJja5clhNsa6xlCNJfiKhoJHgBGg7ogKO8ZVKB3SjY9iJZiqmoXMIv/trUULK5LNDM9XIlT6nBxsmPVk10wTGtEezvAxJgw8NyKsfwvNGRz28P09tDzDuj8R4O/rOjeEpVYoudPJEak/AsJGvaS9GoxdZEgM65ATfIjNFuzAGxWHfE4IY4cCE6XFII7AIa70hh1ksQSVZCbLuyOhuWXu+eypkzWILjThFmRON0dG857Y+oa7na6pjLMWsO7RER2r9OZzffGw0yoY+/b3Ga8lueNGMhKnIcaTG1lmA/A+lCrOEE0s7xZChJUKK7FIB5gUEc2DkYOtx0QlGHbkjZAdbmN0ynPUQUOA+cWieuplGMzf494JgUxpLW07YzazrcA2OnMhIWnir0s0SWG6z827xjIZRpFHMU96u8wUzfI2eu+r+1f4uDOWatVoWeUy6vc+3h/G9gamIS99sDgWEpl3TkMqyYv/mBrGIe3xxHiHqWKHTaOd3Cn6B24z8PsZgi5mQM4y7bQByA22734r3eBHcnLbkfQ3zI2Xoz/BrlJifYhu9MbrowzG2sfqRjgGoXgMtdIuWuYmFfKWv+LqTHNQ9VsMdBubmMm09jZmKlC35MRAiYpikE2tuHN+hG0FTN4eoHAM+m3OFXZ4Bp1mQYFZJhfmVFqO1Cd0MXFPXQ/ZUmzAJq49AK0921KkGoldiw0AZPj1LSHXsvQRdBQAZhrzrw07gCQaql+K2BrQUuV5T8qgBz82GPh6pzraZjirdgyJcG3WCwpFvkxomMTWkzbRi48VYQhhEQBQglDZ5g6KejevwB/FEFD6Q8gXaxR/dJzimbubkBXQPTtyGks/7qoGb6pXHqq/w8CwN0X j3PGFdTM YphpbTzm3uYHgz2M1bO6XNq2mBIrjW0fFMX6Tn1dNM/D38siFjA+BmI4A3ipT+988HaUbHghmcQPMIT2amzHWhaeMEhTqsLXHz3IYXpis86Ia7HmQZGqr4d8quF56fFHzS9hyc0S60hXIZpfSvWHaGZ1WkMRVosdZhwpXDu4msL8cjUgcB8o3No9QrLaGUfY3CV4trOaW5AeI9wCLp6XUWLVTfIMEflkr2531ywhrth78P0wx8An3AaNWy3VUluqjm03di8ELSYh5ldarlBOMW9HO/NMWZF7ymjgy 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 --- 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 ab2d4ecef786..1320d776caed 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -852,6 +852,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 Tue Jul 16 11:13:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734337 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 AA0DCC3DA49 for ; Tue, 16 Jul 2024 11:15:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27E0B6B00A3; Tue, 16 Jul 2024 07:15:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22CC26B00A4; Tue, 16 Jul 2024 07:15:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CDAE6B00A5; Tue, 16 Jul 2024 07:15:51 -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 DDBA46B00A3 for ; Tue, 16 Jul 2024 07:15:50 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9BA9CA0FF2 for ; Tue, 16 Jul 2024 11:15:50 +0000 (UTC) X-FDA: 82345360860.11.F7A1207 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id D272C14000A for ; Tue, 16 Jul 2024 11:15:48 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aUg6c6D0; 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=1721128517; a=rsa-sha256; cv=none; b=ncwegf+lFAsBjxfQ1VuyiRRW6k24RjhY5xjCOuw5h6catD2iEcf0eOzmEbEY2jQlGPOh3t SEtcGRNB+3BLylTM4Q30XemnG34NU1bdxSYj4aySZK9pHHAFJq9+9VN23968E3RskYKXAQ kkySlxp4PgQ3UxD8Wd4YHcaDIwH4ASg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=aUg6c6D0; 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=1721128517; 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=WM3+3K2HURRB4LS7nhsTxW1sAjVNg46Hs+3r1H+lfbc=; b=By6kiyoAqZwjVIV9igAXrD/o8V72GjITgBc5TE9W+mCAVvwbVRfiepRelOeHE0tuaZ+7UZ kjPVwhOeyd7Q1AsWMa9n2UDZVdyvJpOcE4GzQn8+n7f6uMChtPOO1GXW+7cermqoaSUMmO pJBByzXqE0NNl3m+1tQHfXPNjth9/D4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F10CD6108C; Tue, 16 Jul 2024 11:15:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17FC9C4AF0F; Tue, 16 Jul 2024 11:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128547; bh=ym0kawqEGV0FNmvOsYm3DWOKfdlDmSXOdSkjneozt3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aUg6c6D0pXxFYfxdCla0UlGGSb+fzaMJ98PhtEuPZ4xlpOrwMZNzxrunxPvcfDdc7 NXufJhNRBO67I6yVAwRrB24yf+HtAH8pnnvS0xcP/IRbHEWL7yqiHMbLPL3az/7dke kLw1+nQiaSDwkyvjoNw2D0R3dN+SnBi06HG1s3TOoOvNCDUXV5ucaNQK1Kbys49hx6 /juYk12sHgDnrQrIMEwtmEumKOES0H1okVRE5+R168aRmF+qYQ4ppw/Kfra4PrNfW3 YhaZIeYTe6w4tK9Ox3H4968ZbRGp43kkC7vp81Gd13qPzugi8VN9tKHerIr0CKBuPG CUc4ZCR6v33eg== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 10/17] x86/numa_emu: use a helper function to get MAX_DMA32_PFN Date: Tue, 16 Jul 2024 14:13:39 +0300 Message-ID: <20240716111346.3676969-11-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D272C14000A X-Stat-Signature: d1gtyixdzt856i6id9pg75hfpw3myn43 X-Rspam-User: X-HE-Tag: 1721128548-877932 X-HE-Meta: U2FsdGVkX1/ge6abe4bS/zBMDNu+onqSF65pv4L7IIHbnuHhNHXARaIJGOgT7r9XXSg/5QYFM380M4Fr5up4zYmIzo4y1Y/RgNHNizZ88gtxl0IFjkf2FLVbkZ6jl1Sp7wFqzvjkvRATmTY+aK/GDTQ91Yumtm6n4frmNcGKL97zg8/mE7hUos2UJC0uTzjVVPpmaxmgB1znkd7ZdR5dMUpRRRkg8v0dEdJ5ez0YfBES3f/CsCYfSh09ZVWJuC2V1tC2bRFn7BerWd89rQgNhW5i3jNewuB+tUE6AIjuR8JgoIWO9ra7qb90GWaLp4glFFEvK7bjGeSL1KmfBq2j67ODn7qAbhDF4HI0fa37b888IGnrE3hbdVLZOG98sMHQwqVHPAVpN+tVt69kaHqKj54gdaWVnt6/00CPvMIU3H2KbNP1vYfSAVMzUy1DT8MsoPaF9qfY5MmZS/tZFl/74WnTpKRbKKvYwHgiQrIfNuNXpJ5EqrWlnRiYPmSsXyPEPJQfdcOy1db/uJC45HIi/CKQFknAraagxPK9PVE23tpRmy/6/He3YkdjnCqAfATjCykJNibT/Es4YxTyPCyyEbH3wG7Gtb5H0Z8AsQQUqh5bAHFPBNutLDI5uJAXzyKHj+Xlv5w3uvvJuIp6uQ16u22Y85TwyfXXDzzpVX6/tbtFR88PxZFbck7BW6jFCphW0mnLjkdP+yke5Elm6n8BKc/MPvCd+U9ff3ekJuWyaVF4Kimb03jkJ4Un+zlfAWN2bDGYzctx/QtLqc2Jg9hfoX33HkQc/dz7USnbYll6SG7gegRcHx+B9JhxY9a6dMcxe3uuJm+XyELCiXar4tscj8DIt3+4vEx6VzQqRsPD1X9dPWXbNASaCgAfcOO4YOVA7Lc476LNCHecUvTkffD+vh3MY2Nb7A9SxrZrbxNovTRUk8iOCqcDSkNF1XlZlyuVWD7iSTrQzE16syu5uq0 bp8M4Fkv PEjr7hHlL5/SurZJ+U9muckbMZeuTn0pfKLUMaDqBj9hNQW7k/qenpF6lwbpKazpVqnfpc0IGw41nqvk8JfXtivHvUjpjix37MsepWqmYQx3ERtxGgIquUK0E257jh/Nqyu5QJ9tS6rrAli5Q9vuxTt+Elw+uBmw77eq3ArDzzWfaegHrvK1PvFC301h9Yuas6HtZpZa7ERLXej8OKxQ+tGvUG9AdyDyh0o9t2Aa1jXMS8+3894KjtE+HmUyGuO+5MtAIMxkRpK0JF0xslAY2SjmHVy+3sKNhTqF9 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 s that it can be moved to generic code in following commits. Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Jonathan Cameron --- 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 1320d776caed..0a59e3ceecda 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -872,6 +872,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 Tue Jul 16 11:13:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734338 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 7B77EC3DA49 for ; Tue, 16 Jul 2024 11:16:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F71B6B0088; Tue, 16 Jul 2024 07:16:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05A4A6B00A6; Tue, 16 Jul 2024 07:16:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E16686B00A7; Tue, 16 Jul 2024 07:16:00 -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 C18E86B00A5 for ; Tue, 16 Jul 2024 07:16:00 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7DDEF4161F for ; Tue, 16 Jul 2024 11:16:00 +0000 (UTC) X-FDA: 82345361280.15.DAC1829 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id D3D0840020 for ; Tue, 16 Jul 2024 11:15:58 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jTqJhb+J; spf=pass (imf04.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=1721128539; a=rsa-sha256; cv=none; b=S2/LPmYhGIFbYGPBxMqsySbdu6TIf1YY8niRGbN/yVy+HvVjnpLfBjnQQ+5lntf5QWNvvx ZHX/KrSLZZoz7DqsS9rr3H+JvNMRbU7BmWsFalvdMPIIaGcdWWhkwulgj2PdNMAxL9JhZY zuekVSg2sIV5RJM7lMmSfzFwxWitjOc= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jTqJhb+J; spf=pass (imf04.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=1721128539; 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=GsHM4en1ORUNmDX+9w/oBAP4Y8AolH6zdlJ/OX2HJNI=; b=r3/vg8R5yQt6Zti45ej+qchvvZu4rEtRZATvcw0lzLT6jKY/JdAr5ukPUwT4gnYpCvuKEO 0rjSkdIA6Q6yy73Vz8QzB7U6Y6uzhPO4x79zb222Bl4o8lZ6G2eBps52cFNBgTspg8UtYd zpOsorfkieihLNP9LdVzASdpV1/hBcg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1D31060FDC; Tue, 16 Jul 2024 11:15:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 336BCC116B1; Tue, 16 Jul 2024 11:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128557; bh=6ZFGRjYd+QNIUdrgNxjtQqFy9oztOVb4PVdQaCr1DCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jTqJhb+J/VW8s8FQhoWIm7JmyR7Sc40Gf1abzPVEtyCJSyOeruE4iUvKzhPwGcHZq Gi4WEguWl1O/anPnXyjcLo96X7Rifluaha+hVAmP+qOfc209n9oCyWPBZRpMoYnPr6 Z5AaKpJTWx4q2hkMglcJA9vMoAHkQ8xT0oT/X8MLKWMqltWUD2nJJ2C/UHWolUSTPw xVAV2MG3lf4D6NoKqyzRsu39aHx+4G8biXYYgL3Uj8BUvthEwCiNO+ydarfCknuyZl 1o6FotWt7NVXmkyVxnHnLouc/cneAWx4CdKbtUK9MU4VFqae25h1qRS7if/PMSm7r1 zsVdwrWEOeq0A== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 11/17] x86/numa: numa_{add,remove}_cpu: make cpu parameter unsigned Date: Tue, 16 Jul 2024 14:13:40 +0300 Message-ID: <20240716111346.3676969-12-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: ftgfp8494pito9hasxuhys4m4cmmasc9 X-Rspamd-Queue-Id: D3D0840020 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1721128558-171505 X-HE-Meta: U2FsdGVkX19x3tDTxUCnWsvUQSHQBETYmxG3CWkQ/Xy++TRPNGVJn33aY3Cn7mWcevc2AVCcQUdq10NQMRZobDzuQYndCg4Tjq7eYqUvjbSBEm4drWWsHZeqyBe0k0lAFgboRjktRLyrPE4lHUNLWEuIJLyAWBKkaZRcC0q70PPB7F4M6KEaFLWFc7WyS9/DXIA+VOiLLzClLdmmP4WjW17kd8ayvg/ZzmWM0rMVDuClGEXpfQwe/khURgim82VhRLqXZTmQVxvE0GBDil6qUYv5q3Uqs60qK56shdhcGNqSRLZVy0RryMD+Zi/uMthJ/72ngpIlmpCIdJlQSx/QwGtg95xTofop36NzcNoCVPmP3oyuF4GJONjhI/AHW28H6dh2r1lBEI6k9NM7lvdH6D5YtPjS+tCXT7gMWUuE8aN6v3HNMVkpos59ruvaRY9Hvsidv6apuRv7VWl5kWzaHXWsv0urVw+lI6wsqobb3CcSW2dk+Wb6yJEVYE1F5pf6dO0UpBgbWakSoXlre0Ml9L9Ze26LtU4gTv9VjaQMOVYi2Kug+oYdbno0bHF0xPQXWISI3KtdhGoQN+aHRIZchi/BcwxDhYw5r4zt5vxOL3GTSoKsiAbZUjRRmTHnJZS+6JMccYVzgaYOB3V+2aIaKSexwHReK/GKXcU8WZe1pbpHyFLqEwvp1WhULaQq54pPiGPMTfd+YxBD5MJi6/VeioQ1GgNnTvkImFEqK2DzoVNbNUjeaiSLJkFx4YBZX4e37Civkc37P6PN5UarEkTty6wusZTWbgcT456j/ooAds583Nqkq6BLCmKZYG2ISovuY4423SlWqc/SBStDqOBcXXSgJzSU9dZ+BdM6IvrEXPBu4SkjcKUrCmA/xgKTM8W1TqGQPk9X7SClsjxEeRqsffbmELiLfpqsUf1B1Sp8KGXorKn6u9EkzwMyEX+icTJsLywBkNenCCbWH0hU56U MWQ6reFx /udSRquJeFDUuf6l4Aqnj+c1/wFC11gZeceSTffvkUZ1oyvQtS3OhodrCOiIztq4bQSxpvQrYinfTrpJkyNJ60bqIffUZHJNFVKOP1d9IC9mg5RTymExIFSZIaoych67bmWSkPix2sQmkDQ06K7ufKrtptTv2+2mlnfopCCqP2eN8NtJV3ADvbxj8+xB8jLw36nTDGiJ1mrTlwFSBNiUD1buIIeP7o1vRYPUSadMoQUY//p0gcfvcZrHdQLzvT7ACNLuf+IVslPD9rFT16wr4sfxs3XfCe+BQl0ny 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 --- 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 0a59e3ceecda..deaa4816a895 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -741,12 +741,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)]); } @@ -784,7 +784,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; @@ -816,12 +816,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 Tue Jul 16 11:13:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734339 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 168B1C3DA60 for ; Tue, 16 Jul 2024 11:16:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A93496B00A7; Tue, 16 Jul 2024 07:16:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A43486B00A8; Tue, 16 Jul 2024 07:16:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 896976B00A9; Tue, 16 Jul 2024 07:16:11 -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 659236B00A7 for ; Tue, 16 Jul 2024 07:16:11 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 158E71604CF for ; Tue, 16 Jul 2024 11:16:11 +0000 (UTC) X-FDA: 82345361742.30.5E2A84B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 4C561180021 for ; Tue, 16 Jul 2024 11:16:09 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=E1cC44Rl; 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=1721128531; 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=uwU8juq8XSt2w6G2OvxRqz2ZKYdz6zFnIoMiYmm4NRU=; b=nHG7DLi+FDet3XrW8Z2kIxVzhuK0qLXCajXSXrifjhtUeKzP7RjMJYmFo0S5rWRhgMIH+8 RieN1xxyWo/PVtPPM05C9lz+jHlVTJ3fNUzMQjfwLZW0h78QUR/0xagSmcnH/1NxyIsdU0 r3CT2KqkA3IgFqEpDJiQzVLloiJV0fw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128531; a=rsa-sha256; cv=none; b=WjGp8m48Vw+g6vaSliJ9cz57I8ceTVAKyvVklM5mYap2Uwvg6V5Q54L9VzZnYiw0WDipl0 UVrd81VHWKNOKqQm7lHtyTDGFZENf38OXN0tfCEqOw2Po3Ba8fHLe02/HuTSKVnWnSqktJ jP8GAc4uA40bJnMNNJiYHyhpcST+OfQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=E1cC44Rl; 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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 72F4460F33; Tue, 16 Jul 2024 11:16:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 513D1C4AF0F; Tue, 16 Jul 2024 11:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128568; bh=NBbg4bTpsle816bs+vGMOalnfukfZgf5d4h8mpXCbtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E1cC44Rl7h+3OKKUMvISK8NCO4PU+e8RBd4AZjqocXaYE+wL4cHpF9TcDnsF1Dg03 tueh1OrzM2+ZvDM3nFoVAT7t9SPwDgr9e43dzw4hJYyvkKFg5ryxJXTao8qjSyK2hh jqmNuoLpLlXhxjpg6kFGEjqeQjT1QcWEEzo7szYrm7o/abd3+yVE7SybNsKmv57h2d Pj1CS3kn5ZJk3JBRblbeJ5MAxoJx875hFDM/V/UHLHGBj1jMoJL5N7naYN4nRA20/I r/kJF6tPV5fJnjC8Od9Mc7ObofEgrnrJKcMa8NnIhU8XqgGWIs7aHzDIh8YeHQ03Je HLV+OnOurV7RA== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 12/17] mm: introduce numa_memblks Date: Tue, 16 Jul 2024 14:13:41 +0300 Message-ID: <20240716111346.3676969-13-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4C561180021 X-Stat-Signature: h1fb8ddbxkf933mdxrifktcd81ujcq3q X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1721128569-282138 X-HE-Meta: U2FsdGVkX18DliqkTBlH+nXoU9DOf+Vyb4RfyU/qE/SAJLpq8SmThHdxUMeJriVupM4OUggoftaOZnMnFCa9CmSepENv5WLE7pNjaQ4Z/RSP+WltPwEfabRO56dWNDr37V/0gl+UeqqkCeG7TizqW4MClfwLgAbId+xl6azSLZ8panMhiAmhf0kMdyBk2myQZFDn7cljWD8n6Es6QDOlRJAvRFn4IGjyxjUvVmlMEKJYX70H2XbHClWYJbkwDKizZci4ZM2w///bjtoubS/buRy/OV6/U/u8/vjahfr2wRBLtUx7FURNs+oMVbP626ZU3wMapeWr6gPLPdZsSGhTZpqQwS+ImbkYPTYK07V2eEqmgI7U6K0j5c1YO8OenOZQIeJBjLQ2j/FAUldne66WnycXUK31HIcptqbAW5S+xYaAtCKjnc7DLcVLiw/uG7plQw3rimTyec6YfCDQchf/mfA+RkHPrdXj4oZvcJuBwd3vtzbv8LV5P/DbO70RasCl+z7KqrLdiVd/PO1RHXB2bgGoo+O/oVrdLbUMkrpA20KbMQBtoY2KCn3Rs54HYqqJNEsTJg27PSORcLLhOZo/m8s72RRzBxcxM09w8wQ6VLqCjqXxDIWO+X7QcJqnsxOKAT8VIcbqqD9nJ0zX8LmW3D/AvoT9zc8MjVIPVlhfTkZ9bdABJQANROAMlZuK5MAZlcXXC4l2jDPtQIe3UFEL7Ps5+9tCIBJvthhrhuTv3CJp3Y6e3k4w7X4rzvHvKP8tVxXKYQTauVeeAOq+tKtSTcSpN1cpA7gpaVT9cpl0JesmUGadxEzeLPWXjRByvxR0VDexy66k5bvffAprlgjUN9pMZm91b+FaLcWXxqQDe0ZNdBRzztbavbeS42XmvFQfZ8RB3eGgyhGdBBwzKqTGCAOZF8mLlXm4TnTZUTFyeOVgTvNgblQzowPrTQhqhLWMqwz+8xBQ7oOaIGZbazJ PUGWh0Dc 6BDhHDdUNNhiqWcqjshQehTAPuxY/tZ5L46ziEezpLtYlOUmoksmLVPO1sEvMfLov7xczL+vmNBK/wDesk/OIz3QzaGCmxqrMmct8m96fUSz8YugRKG2+kKBRGPD0zzBLeFPLII8HmHcuz1SaPiFtElqhPubyUHi2u/Kv9ip7Ghv+Xa762eVw85VO5VKUVegtjsGdvNL5NM/PNcWF/XIGqrneppupcg2vZZWxee7XMHg/3l3aFv87SkojbToo+XMXIYa2pmWqOFqixMh/RrzEMB3p1ezqLlKVJOgKlUh9lT44bNkHF8HSV8v80b2vv7MsTpEy 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) --- 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 1d7122a1883e..d8084f37157c 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -295,6 +295,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 deaa4816a895..8bc0b34c6ea2 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 * @@ -407,111 +216,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 i, 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; @@ -916,76 +627,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 e3f26e71637a..6f2983cbe553 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 b4cb45255a54..15c6efbaa1df 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1249,6 +1249,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 773b3b267438..17bc4013a2c5 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -140,3 +140,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..e31307317ca7 --- /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 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 != 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 Tue Jul 16 11:13:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734340 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 BD04DC3DA49 for ; Tue, 16 Jul 2024 11:16:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53E356B00A9; Tue, 16 Jul 2024 07:16:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EDFC6B00AA; Tue, 16 Jul 2024 07:16:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 366CD6B00AB; Tue, 16 Jul 2024 07:16:25 -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 168DE6B00A9 for ; Tue, 16 Jul 2024 07:16:25 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C90E9804F3 for ; Tue, 16 Jul 2024 11:16:24 +0000 (UTC) X-FDA: 82345362288.01.BD6541B Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 6EB6E40002 for ; Tue, 16 Jul 2024 11:16:21 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UcvrWWAI; 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=1721128544; 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=GgaiSKgqUJXKL733tpFiKQI2l8CjqzHFw56GEnIDO/s=; b=ZbbUK3X4ecMgf4nzLRJDco9Ifrb00T/U+x6wC90+s5JrXkkk6rEeTpDeU92O0m450qlyUQ 4ggAaC1EhbyC1kqXZLN1utjvXLvrXPJKLlPyFMJrhJ/iWao2nfanRGGFG7Znnd/7MkCVR0 WBersm5yILx/Yw9qjX1JMlkGkOjy5d4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128544; a=rsa-sha256; cv=none; b=EayaNG/LUxERaUvIFHjXozGsYACFkj7JgK2yZ6UtgnJsqBJwYKQLq5RIMeLhAun3Xb05PI t4d5RSQMW7kb5wgdXaEoOuHkrJW65unYelMh30m+jm0/lLPPf7AA8ydgNe0oYUMiEfEByc LpQlu0RJdJOtwFUi/lErs405dVqhZaQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UcvrWWAI; 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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 2BDB2CE130E; Tue, 16 Jul 2024 11:16:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6BC8C116B1; Tue, 16 Jul 2024 11:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128578; bh=pogWMmbNnCcAMxEldEcXlIF7vDUNrHIph+oQnzUgBrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UcvrWWAIQbl3FFQkfDjwC2SdD1OdneqblN/fQ+McWzxzpiNWnDEuI9INqZBpAUiac 6cze/XMRw+pLZ4RpU2ECWQrpk+CLidDE5AX+eHrTO5kadU806iGp54d1x8DcdIqAak OaJiemO15MxhvuILcxhfeq07xTV1zBzCf6S3KqDVt+de6AuFAb6RyJ4TN7GcMFCKcF gtVUKVzIzR3D82aMj/6b6KdPivX8HT+xAiJ4f11yrAK1uSHfpLcG5VF1udrExV7zca WxUdev+0YkrJeE+HKliTiulwlxpFHS2F+nSNa0TBGPk2fH9twhvAvopvHKQVL6T0Ua VX20PF/A97DQA== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 13/17] mm: move numa_distance and related code from x86 to numa_memblks Date: Tue, 16 Jul 2024 14:13:42 +0300 Message-ID: <20240716111346.3676969-14-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 7uoy5ts3yoo9yyyiwj49u8mg6itgrdrm X-Rspamd-Queue-Id: 6EB6E40002 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721128581-824919 X-HE-Meta: U2FsdGVkX198SgKiF7xlVzovQiVn6iPYAjQLzA0PKKpEbrc2Qz/ju0D+usCQUCMssQwfXUEK21wKAYnbYlFktSFSBHk0WH28vinF6+sX7yE4+dkpcmG1HuXnGpmjit6zPLJAwj0X1ZfMyVelRrQ5Z6w0N8Cieo5ztu/L5n6sMexTYIDV3rcRF9ANqPtK3lMo5YSamnAPv9PZEbGpPxN34JRovNBdLzDQY6j4G0GBtu4fSrrsekAtW6lDCfZKdl4/AnjnxsgjAgf9qnR6koRg1NqoIZvtEsG4ZVDxWGOXLsUARykU+n/nNS2FvjqNZUdhd2CIhER2kzYDnXpO1/nmH3kO1+gYnaWPZqilMfXP/0A0mJ4Yg0ccufgQ8RL482y6D4JwZ3wDwCQX465MHkvw+95kau3B+ifUcfWZYhlVe0ekwlcFnO5X8eb0fVOEtz3wB03P6jBZHdOkAcXc7aEJ8dRQ54Dl5AffPKPvaFaM65PbXQwpHb24O0NyKHWhix8rT/nT5IfujMBjTfAQbQZadk7HN/2TTaHADAD1VdNKEYDQNGBSedyFLJKJMSSq6M62kGbC0DeDBMqDihYyZrvZrDqiVbCgFT27lZtyGIumV+d+Pmz/rPleHTa2Ftp2AKwrPRQwvniixIpuP9lMt+8JK7a2PgTBkZyiJXGGBn3odEOwT98o9BOhANt8kodP6Vs2cECYJ7BQgCEa4i7l5GGUQ2IR6P9zT8SnvYVLq7V0gLkmLzJBWB4EPslvBc+xnWkOaoH80x+7AxlieZMf9bfYc61mSKUQKzWXZBwCrJRfPVOzYZFDuOU2NLrAVhO89xY2S1DdjOVLShCKafnoOHxeAkd/A0XiuSRHkK+KNSdcgsbWiIGjjBqOE7MGB9tfxF5POg5pSwS0WGp42eNtulV3QC3CAGu3v2ALKhVjYSYRgo61S0TS0V/IEwKz10mu7tzMyHRg4P6WFhTjkJAVM7x 9eGzzgrz vLTAhnq3ELjWEQrYxcSDGrKgt87ma+SyJLgPo2fr2fokaXwDZdQsFSpIHZiCisdKibUzMLpmybSWZIiTN0JIgNJ4d2M2kaexs73/6ueJW7q/QiEtDHKciBr+QsGBzgcdTj19ayljJVoOyMEWEzaBqIsuSIkHvHPsyd68aCc5wveBTUIY0rwqnKHvF7bVJjZzFMy9Ez90rnrf6I39GhY5d/Jr5/lePf/m237TKqVCCgDB1hX0NPkAJ3RH3CwzP/Idq/+2pmPPEQ+b6jvkFto49tIQMFffgv/GrMDjG 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) --- arch/x86/mm/numa.c | 101 --------------------------- arch/x86/mm/numa_internal.h | 2 - include/linux/numa_memblks.h | 4 ++ {arch/x86/mm => mm}/numa_emulation.c | 0 mm/numa_memblks.c | 101 +++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 103 deletions(-) rename {arch/x86/mm => mm}/numa_emulation.c (100%) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 8bc0b34c6ea2..3848e68d771a 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,104 +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]); - - if (numa_distance) - 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"); - 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 i, 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/arch/x86/mm/numa_emulation.c b/mm/numa_emulation.c similarity index 100% rename from arch/x86/mm/numa_emulation.c rename to mm/numa_emulation.c diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index e31307317ca7..e0039549aaac 100644 --- a/mm/numa_memblks.c +++ b/mm/numa_memblks.c @@ -7,11 +7,112 @@ #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]); + + if (numa_distance) + 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"); + 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 Tue Jul 16 11:13:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734341 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 38BE7C3DA49 for ; Tue, 16 Jul 2024 11:16:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C67FE6B0093; Tue, 16 Jul 2024 07:16:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C18B06B009C; Tue, 16 Jul 2024 07:16:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE08F6B00AB; Tue, 16 Jul 2024 07:16:34 -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 901E96B0093 for ; Tue, 16 Jul 2024 07:16:34 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4E7A0A052D for ; Tue, 16 Jul 2024 11:16:34 +0000 (UTC) X-FDA: 82345362708.14.4AF126F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id E4CE81C001A for ; Tue, 16 Jul 2024 11:16:31 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KRpLrrVg; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128564; a=rsa-sha256; cv=none; b=RSFqIIIfNFMau+S15JE/GmcuWy3FArdncGnUIhznWeHL8ykdUJk9/bqlt/sBR9OWwvJUJV i0aouD4pCi6x4MvEz5YKCUvZD/Ffa69Sibs+6JD/wMMVtPNtSwhMVvwINXIwI8ddlB3LmK 7RN55NU9tH2pbwYI9JJOAcPC51S+pfs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KRpLrrVg; 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=1721128564; 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=Ybr38rBGNipKtypADjBZ7WIYAFVlTwCKFesuNC2cEuU=; b=UpCV2xTnopJL/dM+rAQlO250NF437RZppID73p+kvO5A0bid+JQIYMsNqjgYkiD86TtYkC QTIfbiy98NfXxibrgfEEKJAdlF814R5/pXJriQ5c4FjrQ2nSqviZRviiGcyRU8m0PdkstW i92+7o9EOQSnT66P5P99hPb8zWrO6GQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 513AFCE0C68; Tue, 16 Jul 2024 11:16:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C776CC4AF0D; Tue, 16 Jul 2024 11:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128588; bh=J5LEqR4AoCvU/KZiQsAwdFPUPPx4+6cXxvN58f3qL14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KRpLrrVgs49iPdPeTlsZTWXyagoaSsHx1E5C93i5+9P8SBlnn7Z12NbhmT4tPpRpJ 0zI+BO3Nppe5LLSfYA4/YJraT3JXfCwhgn8es8kezNFA5tq+VGZs0z3yKJaNH88eeY ko/ZZr/J/iuMNP63MEa1Cz8SPM5bEZgddW3tOQDKBjZZ6IRrZzzrI/1IH19/F20lWd U4anRDTclZV9ZpdtUMrjnLxeBd4fO7FcnGM+dt98tawWilGeWcPF4NK8RCMxjjkijt 61SQDh1+30pevGJ+NuacABT3RBSTFUm2AWNy8CJd82u176925JGY/GFFjGvjXBldU6 /v8D8XbcQ1KyQ== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 14/17] mm: introduce numa_emulation Date: Tue, 16 Jul 2024 14:13:43 +0300 Message-ID: <20240716111346.3676969-15-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E4CE81C001A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 7qayezsdi6y1s4ybeozzz47shcjqydyj X-HE-Tag: 1721128591-786183 X-HE-Meta: U2FsdGVkX1/iBKWk/qD25LeNwudLn3huAY7glP9OuCg66Jd70hgbcn2qwvvwyXtdvJU+Nx0gpWMiyMN/iv8mL4qNbYA80bHjSTDGl6nc7t7oLErckcx4e2QMDd6FxT3HXlgmvprVtTAigQkfJGOCSwGkyI0RI7+HFhyT5sssrqIaXkeSeXRktmQIahcvs6ZgrJiXgtLv6xZJGIVDGO6OjXzQxqKogWh7IK5Nn2d6TqQX9dtoHR61EyG5HbJfY1jjM4QH0nz13MMm1inJJCiSxalU3dmmu89xhDgujHwJuwF2yL0CjF4hrizupLco/3DrBFU4JARbiPGjUYLFFmX8YYravY9M2qrf/9evIi00anTJpZcAAp27wgA0S3ruWTYaJ9o476jm7fhtgSSAy7uGRTH1K6kqwcdBOz/QsS1mkwYzAVL3CXzsZq2t7p697bA5uhBhX6bsebcjZLZh7pbXkZivDWL7972a6XXu2XM2pGqnuX2rd6xMRj6Lbru+5rzCNfRXmRp8e/i686KceeMLOdeNHBaG16mjwaljHGx5aEb2s12mmA7VPXTL4qQW/IPBo4DYV5W68pAbhbVeDOGiKIlRWDQjGGcrx6O4bxueXmSpYKMqt6ccB57l4I3xTgG4hoXmPnmStUb/E2/gp71yJ9HIus7P5I2mwCifFtGBnVJUElq2o/EWLfY1XN9zTGsvGaYz7x9SrnKFDnh0806BHYUoVQVOHrOW6ZYEx8DJxSlBSYCbHmf097WJ5SCRCSzrAt7q8ytF35a6rAidENr9OD6x0h17uAeQtkiqyqFUHdFEzeAOLKD+G6NzUSH/3/dN53TxNfP3xqCOxaB1QaDzZQy4yxTF88cn6lcFHFPKLevmZpBTT1FVMxF7VpKwtcff97fA1F5ZjyZOsiph2v+SbMbq7EAIT81cxR89i/GbApRuDB7ksla7e5WdLGs5zI9EnBQTDa9wUs6zrGEHaAh GtFk7vd2 XugxKxYi7mV80OIlbJAjFPxXJf0dRRWLlVEVK+qmvwGrNTGOXu1faIHxVSVoyFNOeO6/tKePW0buOAE3AEhWxvw0vRa0wj3y8dvGon9/WYeSAw2i3/df8dj9tBC8Gs/jsZ2QldH+CU92dsMjPDjU/B2XggRODxIRxCxqFks0cXqmb1LESyBZFHbuL95NrMeU87KAl+MHoPY99lyzGwiDKTOAaxrMNm1o4bRjIR3Kdz03H5AEn1Eq7ZOInYjivEOIRBVHhgNMZzkjOd49bb7L1hkW2jyGsjt4ez+lD 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) --- 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 + mm/numa_emulation.c | 4 +--- 8 files changed, 27 insertions(+), 35 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index d8084f37157c..a42735c126fa 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1592,14 +1592,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 6e9a50bf03d4..c6e232e3c303 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -67,16 +67,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 15c6efbaa1df..ae58eecdefdc 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1252,6 +1252,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 17bc4013a2c5..d5b1b30f76e3 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -141,3 +141,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/mm/numa_emulation.c b/mm/numa_emulation.c index 33610026b7a3..031fb9961bf7 100644 --- a/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 Tue Jul 16 11:13:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734342 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 32E77C3DA49 for ; Tue, 16 Jul 2024 11:16:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B08EA6B0099; Tue, 16 Jul 2024 07:16:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB9806B00AC; Tue, 16 Jul 2024 07:16:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 933416B00AD; Tue, 16 Jul 2024 07:16:45 -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 72F9E6B0099 for ; Tue, 16 Jul 2024 07:16:45 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2CDB380512 for ; Tue, 16 Jul 2024 11:16:45 +0000 (UTC) X-FDA: 82345363170.14.EC9858E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf20.hostedemail.com (Postfix) with ESMTP id CA1531C001C for ; Tue, 16 Jul 2024 11:16:42 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="DR/UKOJ/"; spf=pass (imf20.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=1721128573; 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=PkyDQ3kNVtpMCUYxxcPhe7ap85xkfB6DrGk2TRb3Ekg=; b=2s9DiZgk2kgnSLhW23YYAknyfpldQQePKVcG2sKGe+Scyem5CFu7QWCYG2ThO6RcxLNrTz X5CMBAz36iUjsnVrnU1we0b1eIZ2WQvNmPAL6vq1mVZPM2zpjUq2qBF0pYu09y3so0bA+j S0uHPNLwuOjGBgtKod4KPY0cutgry3E= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="DR/UKOJ/"; spf=pass (imf20.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=1721128573; a=rsa-sha256; cv=none; b=TEYHtLT52nvv+esdz9tqm9rB2QE87TfyIpPB5JMTk/V1RQKi5eVCvEbCROBv8RHMfLZLKJ kImHnqlDKECqXAKQ2a3wLfOguKLdLtN0ilqamLcb3ZiY6CLUSRG7zzjIKEha6E4Ocwv7WX kgPSABo3WVuKuMRxps8QARKzYam+NOM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 4CDBECE12F9; Tue, 16 Jul 2024 11:16:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4143C116B1; Tue, 16 Jul 2024 11:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128598; bh=7Q9+Mq1OzbCzQ3l6qZ8hFadj8WwRPzHvJheGL7bczxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DR/UKOJ/h4uG7SYpNzlc2X9CWTUegBVq7/FEDSICT5v7b5oob5MruZ1Km9M+sBk9w CrSZGTKrdq+1umF3gBmMGFcaZCoC89EDdmv5WrJaNrdVnw4l1yMWg59lcltDPFCz1C c8WIvtqlHUvYvghfdoL+3hTZwAkV1bCk5YQWIGnPNU+6jfjgj4LABXzboYg8GzruEv 7bQ8ryZxvJODCU7frKDMJK8TrhBuw74SWFDmRevbWL2HWc9qWBEUfYl8qlYurs2SfG lMCnTuVPllpeAO8ytYEKcrt5eEcNZcGUU9XEKzAjRzy1dM1dHsXD2cV4R1kri25vkc +ode6C8uopYbw== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 15/17] mm: make numa_memblks more self-contained Date: Tue, 16 Jul 2024 14:13:44 +0300 Message-ID: <20240716111346.3676969-16-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: ufoik8hxo4k859mu1gh4roq3uhr8hsxa X-Rspam-User: X-Rspamd-Queue-Id: CA1531C001C X-Rspamd-Server: rspam02 X-HE-Tag: 1721128602-689356 X-HE-Meta: U2FsdGVkX1+jMbVRoQV9gqkNo1l8c5qC9dUivhzxV8/lA+jEbjweLVREP8WwUOiJjSu9tFp8g2GJTY6CZFPs7ekc6NO+ifk4gF248kDqT3OyYWpkQD54UBh9NrcLec7Lw44YUukYVTlT5HQ54FwG4oTuTNXXc14vUex+4heWCsVRWtfVTEaujhBJHuNd+xkjuHYK3wEXClTdCfll/Hn4E2DFrXbjUYCoBlQty/CqMHzUgZ0dZyCPPUkIhMS58EGT77qxRKVqz3jYO9E7S+tjPHU59kG4YlG+LbK8UsU63Aq8mOAN0KL+TcY5Ec1QiOZlBBk2bIwrBgn5DRT6GByqHvNbs1MmAqwAgsh4OhUbG7Z7ZQT/TSk1Ce8XHZ23xrpFvXvvKqgFyQu+3aH/T/y+FkXj5OyJtd+dc7Mc15cs5LLaEeaTg362uYXCS8DMZbatC8cCzydRGnBMsZSUzUhFv1Tg9ueDkZ/rkiqHpMF4H63okl58YRHRfTIcqDPLg4HPeh9aJHRzS53hZaMAkBk4aHipxi2uMnQN0KqtqMJUIAsbankgJ1Vr7bLNyWzMTvyEsC+9NgYzepxwj0E3Vu4wpgAmFULJ9wkwBCu9hkSyxcI0FjP4YNk9glAXDfPThttAVXgnvgXC8bUeFb2on1UEJHFZE16oDbfHl+GgSKP+m90u/t9UFsHFRxbHsd97PwwNN89xuVf0tkulAJ14NzSFa+UrNHKl796Kh09mx7yOYvAaSzfrdeXJgDxiH7qI+qHdVhLS4La8vyBdsdUpJTkLK4xnW8cP26Le1gcn05dSY0kx15Ugg4h0EmjAlOyHMbHUWVkg+NV4bLVWSmetzKbRAKKawfibv4ICIt/Blzi+kvA4nI7qMJ/eKWc9hV/syZ1sJ2KEpGFoFarewz0bmH9HqAreyLLYxx93L+bqHF7e1Ask//cFyJyyk7o0d7HhuuOgCIvlEBfS2wlvTLzxjud +o+Q5yBs t+Ad51/TR9YWjbbn6PNzpslivA0IuPYJNcjPunp9JoOtTb6VR3qyClHiZA16Mrkt/aQC+ceY2qwrsfKtgQso1rSBdrvS2GTAWuDQ/QiNBiWBEk18wbaztS7/WS3WDwid5AAyN6ovSO40af2l1wunKo+EZXIPl7wirM+Zxn2rXyLA2MOxHBD/aM/n4kwDTs/8+hjCd1ZE3v3ArKcX3jnKOnj/y5lQJSPQq/Iz9fwpL72sTaVZtkzTMhnPBtWtLLuVikqDFQhnfAQ746UpsuZidsjZy+Z80vkk0puzq 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)" Introduce numa_memblks_init() and move some code around to avoid several global variables in numa_memblks. Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/mm/numa.c | 53 ++++--------------------- include/linux/numa_memblks.h | 9 +---- mm/numa_memblks.c | 77 +++++++++++++++++++++++++++--------- 3 files changed, 68 insertions(+), 71 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 3848e68d771a..16bc703c9272 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -115,30 +115,19 @@ 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 i, nid, err; - - err = numa_register_meminfo(mi); - if (err) - return err; + int nid; if (!memblock_validate_numa_coverage(SZ_1M)) return -EINVAL; /* Finally register nodes. */ for_each_node_mask(nid, node_possible_map) { - u64 start = PFN_PHYS(max_pfn); - u64 end = 0; - - 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); - } + unsigned long start_pfn, end_pfn; - if (start >= end) + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); + if (start_pfn >= end_pfn) continue; alloc_node_data(nid); @@ -178,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(); - 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); + ret = numa_memblks_init(init_func, /* memblock_force_top_down */ true); 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..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,13 @@ 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); #ifdef CONFIG_NUMA_EMU int numa_emu_cmdline(char *str); diff --git a/mm/numa_memblks.c b/mm/numa_memblks.c index e0039549aaac..640f3a3ce0ee 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 @@ -287,20 +301,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. @@ -368,7 +368,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; @@ -412,6 +412,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 Tue Jul 16 11:13:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734343 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 7AFF6C3DA59 for ; Tue, 16 Jul 2024 11:16:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 081766B00AD; Tue, 16 Jul 2024 07:16:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0325E6B00AE; Tue, 16 Jul 2024 07:16:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC76E6B00AF; Tue, 16 Jul 2024 07:16:51 -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 BDDB86B00AD for ; Tue, 16 Jul 2024 07:16:51 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7198C81330 for ; Tue, 16 Jul 2024 11:16:51 +0000 (UTC) X-FDA: 82345363422.30.0E24B94 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id B89B54000C for ; Tue, 16 Jul 2024 11:16:49 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hbP8A0lE; 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=1721128558; 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=iBzGPZuMGD++mS9jOpUUPTzrt4xgBt4OXBSQWTSe814=; b=l52OLXYoJXkRZsm0EPIDkiJOKYrStEtiPcvK+q9OlXI7xYUhnrsCmVZQGBdm0Bpd/iL3eS 9+PxJ7jW1Hjq35nCMileSNNBzxoaI9Nez9TM7E2RsNwTrs3dJoWKvaSkNTVPiNtCxZMryX e7xvGVZYDVW+TBfPs93jTrm1P2xv6ow= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=hbP8A0lE; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721128558; a=rsa-sha256; cv=none; b=eotFKaSZAT77NKmNJpiVx43XrsbaROUXeXyFHJZuTDUS9CCnQG9hQa+Imc4j4BAmprAagQ 6iErR+mu4ZqhsseCr7JzGkMsfeP0EuJewIUtEekB0y9We4A9q7mIL089cVglrTCG9MgZF2 ep6eLp1RXP/f7Kuapuj7KI4Q2x14ncI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F1D9060B9F; Tue, 16 Jul 2024 11:16:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EC11C4AF0D; Tue, 16 Jul 2024 11:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128608; bh=cw/dvVFpXQw8UFABdX3d8CGu73vGiQNRy5vsiOPnGKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hbP8A0lEpqUTNDzt8jAuMvv6yCcB+FkqjrOQXQgUWcNzcZ3+xmIR/Aq1Yfp/okNoV IxtfpfmtCpeARUNWee3xrWyJ+MV8+fqdOnXDXmDSbmggoHhS8hnAQRCM6WDuTW2B8o R6ovcDEBbii5Ob4bL2Mrw5doidNTSFYtK8nUfLb31saiKBa99WjoYVfh0rLKHC3BZa mysjvhMi7gKCDFNWYJfdmsaeFEBXPXyzNpLT8adWtIYuX5w/pzCWdyzxmtYtHzySlk JM0zImcPHXvpx62YrgbS+n47aQzi3RmFdvy8Y0k7NX2M73TkKaURcJbMZJrXC8nNrw ftINNXlBfq8ig== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 16/17] arch_numa: switch over to numa_memblks Date: Tue, 16 Jul 2024 14:13:45 +0300 Message-ID: <20240716111346.3676969-17-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B89B54000C X-Stat-Signature: e7jh4hua4gr9pcnc8zzowm9y3eba3yz7 X-Rspam-User: X-HE-Tag: 1721128609-140972 X-HE-Meta: U2FsdGVkX187ZzzuoByXlMgXRhEMy/WeFrhQ3vTugLag1bU1PhWIPXEX1QD8G+fLr9BZP12YXt2i9HbO5LaoerxAYRnCdhqDbcUl6M54OrP/UiCm4CyjuYPQqfZCUJfVw9eqSqAgJisbCnkWNyJEuYfH6jxVeGt0H5diJM/ZW79u4XTx6mHXsNQqJQdewuLMOHcGuoGs5vgZdUQ/axSkhcznEmW/rKldd/NvQ7a6Pf/Obf7YMIcIqN6uk7qPWGqVKCz6qcdq8xHtNtpiwR8gscQxcewcyVzCEjKCQCohiickzn075BnuRBamxs9McaRhIraECs7K+LpAIfcYxi6rcmt5TeHMCbGcNMACtlup8oo9kUsTCLypWS+iwg2m/k4i2lDKWA1nvk0pB14GWx41OH4LDDcIl9GDJ+2ljKyxEkeyUqB2cjfBBTk6sBoQ+t4UsK34jlD1ZJxEusflndvTQXC3ncN/Rf0uPWv0kT9eDcTUT83KeuHOmuWiIp8icJDP7/ipcj7Ip3YKFq9c29Rjf0krsWwK6EWhPhjECfcHzqj5FG8CJSzqiB4WgxOJUu/oBcYwHoefhoiJUEC7UXW0Pq4pzVgwVN4TpGmZw8CCt4Ax0JIf8z7UfKHkw+9oqtJtWf+HDnpJGCR6ULe3NEFqNjitRmk8VFE1R5TFa5pbLp1OLof+feSFuivGy/EK2NhDvV3Uhqthw58Jae8umRx+8Jkuo/4bYjvVtbIY2twLEoZtIP4d5TDOuXHkU3PCs0bXvm/pIcSEYZ3qjWJU6RuBFIMqgoGS8ASZzia6h9Zh75Mvqc/y3vsauqR6Ds6j9jC4OhSOYLmHPHFxX6Rp0eeKj+RvzGutEesOr4wJm7JnRqs58HOUaC/ILJalSAV4zyv7Pp1mOPoqlDEOks8H6PzdQpBkm44V2pLWAw04XNwl13MH/VWCwxU6d2VRCwRA9ydWVtiEk4JEZiX/ZgR0wtG r9ffdK1m wWKvtGslHr8xbmHZ9vXChNhTYoBF4Bis0Rsh+TPH/+a9uMx6BZMb9vPSTM+iDvKtzQxoWOgdycNhiRrw3oqS1T8gGla09zswx7f0R9HGmxTLybG8FiciqsX1EZ4hnQbbyczTsBK4U5BIzEcVHUALSu69mqskFQQBJQRn7jsDF38KDcvFQ63FfyQxVATE5AEsenn+KXGiVEsegngZBGBE3IGizfcV9k5Xd9caBjRjiwsXHoTrOsF5OcV8QkLDf+VlACiFHENeryWa54oOaocg9IVk3EUet1+P1kw2c 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) --- drivers/base/Kconfig | 1 + drivers/base/arch_numa.c | 200 +++++++++++-------------------------- include/asm-generic/numa.h | 6 +- 3 files changed, 64 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 2ebf12eab99f..333cbbad7466 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; } @@ -454,3 +321,54 @@ void __init arch_numa_init(void) numa_init(dummy_numa_init); } + +#ifdef CONFIG_NUMA_EMU +void __init numa_emu_update_cpu_to_node(int *emu_nid_to_phys, + unsigned int nr_emu_nids) +{ + int i, j; + + /* + * Transform __apicid_to_node table to use emulated nids by + * 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 Tue Jul 16 11:13:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13734344 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 E72EAC3DA49 for ; Tue, 16 Jul 2024 11:17:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 787BC6B00AF; Tue, 16 Jul 2024 07:17:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7377C6B00B0; Tue, 16 Jul 2024 07:17:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D7FD6B00B1; Tue, 16 Jul 2024 07:17:05 -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 3DB286B00AF for ; Tue, 16 Jul 2024 07:17:05 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id F14AB40502 for ; Tue, 16 Jul 2024 11:17:04 +0000 (UTC) X-FDA: 82345363968.10.705B5D9 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf23.hostedemail.com (Postfix) with ESMTP id A8CCC14001A for ; Tue, 16 Jul 2024 11:17:02 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HMx+mv1b; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.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=1721128592; a=rsa-sha256; cv=none; b=p4rAFD9PrcFXb2WKC0y7l760KM2sBeWf6LuFBXpp86RJYTfWc+bY+VbWvBg+mTonbs9EAr n9IK/5yDIqYyybJNPmj+vLpGABpKJ2uO10YdP1K8bl0zRLV9m84iTTbJ09+bfrUJBVdKbq R3+i3OMs2PzGFpOQSA/nedkoLQsinoE= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=HMx+mv1b; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.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=1721128592; 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=UGpUDkZdNmCKVScQzjksn2iVUKFQwS8m/L9ZJGTqCwM=; b=HWaivhpgqHrbajsZ+p3HcBhVwY0SIYKBBlgAGF1FwieaWHZpxAkkuFMOkcy9Y5EEg2MA/t TWebKNg75HKxI++WSZl76reswT9RF0maEJNAbQT9DmYIMII6HtnWYbXSnamaV2Ju12fIni 7DeJjGu3LG+YBUbFKUkxPSBwBpacsv4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 8F7F9CE12EA; Tue, 16 Jul 2024 11:16:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 332CBC116B1; Tue, 16 Jul 2024 11:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721128618; bh=YeX/zOM98p7oq0+D8eMJgxNsT4zHLIp5lz3y21iev7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HMx+mv1bGMjSPO/WhXFoC7Rb6iwGJqO9+dc/PUQ7veMxE3nuT0c0YLJwrz38TAU5U 0Q11IMAbO3FNvgruj4uJVrCJo6jk1vS1LAVFC81AqQ0MuvdcmgStTZWJbieXGzd32z Q1AvmWDPdMBMJcrP6CfzjFyV8++UxYuZCQYAOp+h3jZQ5SWk7yVa1h51Es450b+Bna bZVU+zwGud/LyPykJINM4pTaM5I/ZzInZVcM5NxM3FdZ+R1KpT3irgg+XUabbvLr17 V3NQfhWGoJ5Yxgbl2OLtmxSFWA3NTbUkLFBCFfIYdmmncDx1yZMjgx/873JHAnRRkM +SJO1kobq7E8g== 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" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 17/17] mm: make range-to-target_node lookup facility a part of numa_memblks Date: Tue, 16 Jul 2024 14:13:46 +0300 Message-ID: <20240716111346.3676969-18-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716111346.3676969-1-rppt@kernel.org> References: <20240716111346.3676969-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A8CCC14001A X-Stat-Signature: 9jk3tnasiw9ca41wbc6pdpdjk3pqda4j X-Rspam-User: X-HE-Tag: 1721128622-4171 X-HE-Meta: U2FsdGVkX19uAdsT4fCS7PxU/tvTVdNfu5Guc3H/CPv3MC9yp7nM43Wpphd0a8B9BnLUVr9CEUwbiP15MIDqTS2hdOBY4KAfeF2mNzc8N4Zx1dbuOUJ/NwEFM517xNz7O4cJYlB3dJ2d3riqEitoINsKGJpF0Pgp3BTR5hzc5elXcx+t5veOoZpSA9t2mM4vQf6DzPaahfbvfrmeX5vmQ7fBqYbzOKHwIsCLxCodbaO5CSdI0CDKdtw7Wgudk977HhYGGnbvnGibX1EOP9PK4sWkqHHW3ovbWDfzNvxNm4wVBcNRkReyU7stpkQE5NSDH/kAIqMdCOrAcM4KZHXT0r/l9OyjC+b0TpWpVp5FpY65GlA7eZgO+50/oN69wNh9iW2AHKvBabNbTyzr0BnBeNalxig3oBMn8VbHybFShhTuvltwMwyp056n+uOIDsX7rYZ4NYkWaHp1dttyzKuahN/WfUKEmGBUG51y7Oc3G7gcqnbvisAiNvBBARqJsULmFucziO5+ZRFjSYhG3kN1alBUY0aTAk+uNAQ8+aDcrdX1SdsKcPp9ZC9lAcOeKIs5ewOcmNrXL3NwYp738y1RH6VjIs+Q/Ep8U0rtekcpFBroAswbSqGllqY9Tmi3mc44DrolY5rNzumklYYSHNMv9byIDZYH/RdCVEwcvXV2uPK4Lx5JeMcn3fdfVN21YsCqYtPXURcNjcLX9x4jsJMLps8WjE06WA7wwh38ws2HI2SS/d6eB4TnjclnleLHF32ei2dJR7S2Oz9WBQooDsMM+Tioe132WYluP+WVd2Lb8eC0OrDanK771GURnYKQiTKKc9fyr71yja/7jFuks9efrxdZKBLvmp474f06VxNgHLkoC9l62jneACjD4pyJQI9jdFUtDM8q1Pa/rmDLSbTjAQ6LOptXRhrOxkm3WR5BKcu93EaTKAHUPdnyeyBzGnDdruI7rOnwgy6BiE97NJP l/1nu9JB 6mX765gtuNfYSU3tLU8Hj36bqxxTAcIoZc//yQ5F+sjkrr+tpSZc/u/per7Nr3ZqAIMnUA9IsqD7kEhiTMhjuHPP3DTyo8U96ILyzav2t89XS7kIQXAtg7Fh13pXf5Mdm3ksHWOVB8EIWR4GXGbokfVP3MvhdGON1ihJgy5GRXkuKyCz3kyrhtQTKCsxFlYq2IfZzR51mu2yok+B1dZLOQQMlejRU5kC+4pyLdc0CMEH/QB3nZN7Kq0X6h3KEzYQZTvHBJJrEQ40ASrkrQd4C6RUFb41P34Y5mOAdaaPbGRkYALKzukTK5erVxw8MjBarA3/D 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 --- 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 0483cabc4c4b..64c30cab2208 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 640f3a3ce0ee..46ac3f998b4e 100644 --- a/mm/numa_memblks.c +++ b/mm/numa_memblks.c @@ -525,3 +525,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 */