From patchwork Thu Aug 1 06:08:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749640 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42FE9C3DA64 for ; Thu, 1 Aug 2024 06:10:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D150F6B00A5; Thu, 1 Aug 2024 02:10:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC52B6B00A6; Thu, 1 Aug 2024 02:10:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB4006B00A7; Thu, 1 Aug 2024 02:10:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9CCCD6B00A5 for ; Thu, 1 Aug 2024 02:10:58 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 500A8808BD for ; Thu, 1 Aug 2024 06:10:58 +0000 (UTC) X-FDA: 82402653396.12.C3D3F00 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id AE86EC0004 for ; Thu, 1 Aug 2024 06:10:56 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bNC6SBuY; spf=pass (imf10.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492581; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yodlQ5GPZgxCEUDYWONn6pEc76uoISXos/NtCDyc9Oo=; b=8V3B33AHxMvrLbbSd7DyW/TGvcvp6vvY7zZQlT8Qe5Z7vT0OMfFy3ZsmwXb6hvqN8oRC0q AoKPXBDt9sffG11Zn6uuWD7QubdnjJ4jU8QBuBWVnvkH3iiMCMEIVBVCPV1sMkVHY9f0pX fV55lioobTc+V+Gjo4J3GBof1N0UMqY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bNC6SBuY; spf=pass (imf10.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492581; a=rsa-sha256; cv=none; b=HEwNZmDkyr99tsIPzEMS+RvKUlKQsWUGkG05+B24N3uAhP6qpR9BOqbQLyXAXSr9R7K/wl fpPZaZNsnYYjsbLtyZ20vQyMD6st7XKQXlZqnUNPD9QvKaAPZURkca4LuETy+mL3TQomQ+ B2iY9YJPkBDpfcqwbHhXdae7nAGOrno= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E93086140C; Thu, 1 Aug 2024 06:10:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 959F9C4AF09; Thu, 1 Aug 2024 06:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492655; bh=Rjf0iRc+VbNov1IXYA1f8/WuGCpuVfgjGuHB5zpeQrI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNC6SBuY+2C9vgNv6AmEuNkLzbIiXAVs/wMzl1r36Gs0k8CLoQWb0q62HVoiTSgwA yQRxQAj2MPhJPq0x0p/VUMiIU9P2gj0sy8r4TrFGEl5cblhhm6dYAsyBqUDMFH+X+W +D8Q7EB3niaXdEH17S/n6XfMr5sBAkGSoqR2/AdaFEBFqO95ruILiTWlbyxMwoc2Ih gyipgDPNN380SXng7+cEQlO6DS0+22xe+S8kPgh/BsQ9oW27iWFyuyh5YutwywPGcT LFaiTvhOfihkxBHZNNKH6590ZbIZ1bzu/P7b+HwhiGgpJyPBVSvwX30a7PsrsgvCDJ El5tISvg50iFA== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 11/26] x86/numa: use get_pfn_range_for_nid to verify that node spans memory Date: Thu, 1 Aug 2024 09:08:11 +0300 Message-ID: <20240801060826.559858-12-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AE86EC0004 X-Stat-Signature: dode6445p41ryuq8mkdioq5de315jjwd X-Rspam-User: X-HE-Tag: 1722492656-691607 X-HE-Meta: U2FsdGVkX1+DZ3m9QqBJJkEdvYDF48K4Rdb1waVGFpzeZhVyKUGBrAghEuuIlDyB+bZGZBh7OWPPsQjsqIw8LppN+7UG67B3W8VVOGKbkMYXAT/fjZXd7I6lBFHIfcdSEA4aXYj38Q2fNOwR8hxWZdFJvs62GGX8f+HjogwSgYKazys+9YWqNeaMez8tIVThS875HV2nEmvbo3xAFXX+acuiD9KweRx4FPtYpu/3no21gseh1jzBjM192JHmm8BwmJDdG4jTsqv8vuWqHdqZO84yVwbA6XS/fhxHHsj3qA/oOsmsdJESRGX24Tkp+aJvmVTtLBoReSJlgJAJXZnsJmc+ZaX86I6lz26kEKHa7it2/e4h84FTwbxwrotjTfMOczFKLsX/w0Gv9n/dNjglRtOnGSLkkhxspm2/U4S+GbMQ05ubyWfKTdBze/CIqueI3G1a838LYHl+2YdFxaFY+vFRIgGhn5OsSXOTYvjeFLo2lRS3CK1aiSyX13ti5hoQOAiiRNhyKpFDFr43sSk9Isq4ed+tlP0wJ1ZS/QQRvAEfLwNE9bt6gpH3Mh8jd8fx6Jo1pRoWoc8OxiVDiUNACOVZqi23r+9C4W7RGmCcenZnkhvG2I4f75ZWkYXdzSyFVwW+rd5lbTvCWNm6WNopQ14F6l3sNks5r56c1H1JvtsNTgGwMbsFJX4DqjPaEaSZWrzLF940ahgWSVGb2po2QNWXocb/jgcTXM1NOHsel3WCBT58vQzMaUZiHjklbiH8hLEUUX7KDdMhKiHGf+1ZsGp8/hhyiJWONKZi1jwyS7NbyuRaQBMsXHrszScRPjOwwUCWcesv/3mXe6CHYQkCsDuEJgauxQj7WikLJyXvupyE0qcLYU5ST4FR3bxUm1ZXbwi0xKPRxmzPnHgBbABSS6nPTadNjt4IrUBf7/Kef8LjWpbwNNhqeVuXdDpRVlpMWbQKN0AbCZwYo/9Ncz8 mG+w4DNW cA+C/JPpcSQCStcL/YBKggIX887r1HoEu21x4rRs9d+J/ubKbFTAvUyyS8C574qHSgC+uSZDHSCPmpnoRTqVdcyjFitZbL7R2eV6UJsPY3b2zN48dX74lLki8GcHevf2WEVCsHL7vMG07aPyVNhNNO3S7csIgfo9rOT7Aka1h3TdQq7RJ8oXiPNb0XS1tSxIWKlmHytrGw3btLNEsSOeY1zIXIIXw8/M3VY3NlyeZgcFz1yUbo5kkrkaPyxcN40mru5QUjseZq8bYM0CfLg4VT90W2RMM53e3EJYS+VDyyIEUFDrXeyrzV5v5InsD6OUWGCOiNX/cY+Yf3VKPhTJXlTy7AzMMFqTePnmq X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Mike Rapoport (Microsoft)" Instead of looping over numa_meminfo array to detect node's start and end addresses use get_pfn_range_for_init(). This is shorter and make it easier to lift numa_memblks to generic code. Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/x86/mm/numa.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index edfc38803779..cfe7e5477cf8 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -521,17 +521,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) /* Finally register nodes. */ for_each_node_mask(nid, node_possible_map) { - u64 start = PFN_PHYS(max_pfn); - u64 end = 0; + unsigned long start_pfn, end_pfn; - for (i = 0; i < mi->nr_blks; i++) { - if (nid != mi->blk[i].nid) - continue; - start = min(mi->blk[i].start, start); - end = max(mi->blk[i].end, end); - } - - if (start >= end) + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); + if (start_pfn >= end_pfn) continue; alloc_node_data(nid);