From patchwork Tue Jul 23 06:41: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: 13739438 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 0C8DFC3DA49 for ; Tue, 23 Jul 2024 06:44:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98CE76B00A3; Tue, 23 Jul 2024 02:44:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9161B6B00A4; Tue, 23 Jul 2024 02:44:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DDEC6B00A5; Tue, 23 Jul 2024 02:44:28 -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 5F9996B00A3 for ; Tue, 23 Jul 2024 02:44:28 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D52A01A1BC3 for ; Tue, 23 Jul 2024 06:44:27 +0000 (UTC) X-FDA: 82370078574.01.9B128C0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 35E40180013 for ; Tue, 23 Jul 2024 06:44:26 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Za5Jhcet; 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=1721717004; 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=FoQYEEaM/2pGl4HIwB4acUSi1dkmfnQuxsBB2KFemZ4=; b=ZJZKTkKZhFUCdCZWJxrPXiave2UyY2oBPDGsOlRQbSk5Gu0hfj7sneXngLV7HOZNxpoLRC Sh3RVtz9PNpytrTjj+4rQLk5FiLUKcKN4wUaEa36YwqRWhfNpjHs0C3dQce5otJxNPGUsh glEIkJqk+m4ad4CF/cwGixrgtQ12xGQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Za5Jhcet; spf=pass (imf06.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717004; a=rsa-sha256; cv=none; b=4ang7EYObXNZw5hAVBsx1xxCP0zxpHZTYIHCXd53UonTf36fGzVDed5UwgFQNHT0f5kV3l A0xp3fBxiZ1dj8vTirLUycGXGldlyEousL1qDydNqVMIlaG5S4JL2dNYAzr809vdQDQWTm numcn/d4LC8Cd8xzwn+eAmS9SI4vHFQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6D7D6601D7; Tue, 23 Jul 2024 06:44:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F62DC4AF09; Tue, 23 Jul 2024 06:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721717065; bh=c6DgXq0zS+r3QhZ5flAVfEs4FfALF1+j15wi2hevr+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Za5JhcetTAfLRbJccTWeAUNIxgrg96br5y87BwWzZPLzZYM5IjOw4ndfZ4nIfWM9a 0kYpHEGaCq6sHARpYneu6wGWScDkDxMY9UcV7dpRLzFycumSP2BoGDaLlTOqcZLXTy MhVwp5rCs8e2OGmBS9+/Gn4wMTzHhc60AFxKa0ONJzfcOahicEDT4gok1reEmHY3m/ yJ8eHIgkq+6rm34FFaAF6eeeqrWyvK1zv4CjW5ghkagLShm8uJGUIM4w2FQQtbu2np +gfe1coXyBC8uzt0RQsU4ls3le21w36/2yCPFPHrBIKqMRwOZM2lnaFEnBfBxNNJvK Lhh8CDiwUIDtw== 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 v2 11/25] x86/numa: use get_pfn_range_for_nid to verify that node spans memory Date: Tue, 23 Jul 2024 09:41:42 +0300 Message-ID: <20240723064156.4009477-12-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240723064156.4009477-1-rppt@kernel.org> References: <20240723064156.4009477-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 35E40180013 X-Stat-Signature: k78smnays6p5wguohitrdrckmo8osj6z X-Rspam-User: X-HE-Tag: 1721717066-733792 X-HE-Meta: U2FsdGVkX18fzzjA01k4t913xMb6UPrk/k1d2wYqw7MJt+hBQQBu9ludh6nx+7BTMV0mHO780cI3EBmRnw7za+8VPinaWTurIH4QQlYHe9kcQRpG3Rz0dv/kFEgQomfCK4POesUkNUqa+6AsIQjF6bc1eEnSvx2VO3838W1AnXLZNQ8zS7fZJ402nImijoQEmkhwIG+dkL/1DW3awDFPHOeb109dtk1zqoVETeA6WTAUDjS0NquJAiMCimAiXDmJuffVIxKLsoYTfU9JY/wieWRX2zVLPlEVpdyaGtJrgGOqYbz6zmplf1miH0yS40kMoKBBBfMto7oT3R7MQL0QFNTXqzbzr2sUByNZQPwcRBd/9QgQP/jsIGSmDd49Gc4yG7nPVUIicG73//eWPFa8p8UiN5baHSDZPesQzaQG8gwLC43nOCVSMlGuIbJhwFnHyPNQIfuAaG4NJdcNKCT3LkJpdQAHyoMom+2H5pcvvy7I3VlXvoIftxbKlw/41vhxee8LRMmB0o1Yd8DcNvbxh17X+6cS6ArblNyVe2pob4S2mtIE6/wjiDyoAPtEkdMDvMCSPvOA5IhwZgN34sGkJnLxzZNdroex2J9ZJBlent9Y3aiSKIkEvaZQxMNDqlP8yxn8jrBmfZ7MLSnYtwRPzzALyZlJa2WQT3AY+4KAyEkmoi/tggJwjbDnMFnk5qhkgns+MUc2kWsssVRuC/3QmYqLhDYNemMqmnw8EfVZ4LA+HtyBxU3nqt0IzulbUFhDFI3BhN5OnFZOYAfGVNzGBehyYFncf8v+1kuih5BioNLwn+WIR/vxkq3MKE7VlajkvAQb1PJKsSzCUxXFyfZ6UOe4h7xl/ZrAdj3PWvBE99ciHmy2MoKf5oP1+EXUCTzQarfiizheLgPGNNaf4tHznN00Ev4LlarH+cfCA6YyqTzmPa/boIOJ8ZMQmgx/+K7DrmyfAb38si1Dpp4P28m zbRzJ/2b vROZgirm9QLEdPcBrGIb8uQxYI7IP47pvkzb6oZzt+bfJ5eyGAjQQw7s0v2m6nJdUjlo6+tp57bqQAMW4oqRYuf7OQq2TKIKAyxmbtnhBFt/i/ceETk+rb0pU3JySX1wppuq9Vb6tK1DVNF5OCMah8nosamEmgjC03VGs2hM2kEC1zqEFnrCr4BUXolIOmv/TP8/LBES2RUO3IGsx5Y2435/jgAM2Vt0mTR1bWCwi5XS/7uhz0ChW4wDgExlu9vFVAu4kZZg2zB05GNGwEK2ZAgzhk2iZ2BbJ1CxSuXqqXBkzekKHgh9mdpGZnEkDoTiGMGlqzz36QP2TSbU= 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) --- 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);