From patchwork Tue Jul 23 06:41: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: 13739437 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 555AFC3DA63 for ; Tue, 23 Jul 2024 06:44:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D85F56B00A1; Tue, 23 Jul 2024 02:44:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D35646B00A2; Tue, 23 Jul 2024 02:44:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFC996B00A3; Tue, 23 Jul 2024 02:44:16 -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 A264B6B00A1 for ; Tue, 23 Jul 2024 02:44:16 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 51EB3C1C03 for ; Tue, 23 Jul 2024 06:44:16 +0000 (UTC) X-FDA: 82370078112.14.FAEF276 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id A6AB714000B for ; Tue, 23 Jul 2024 06:44:14 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DDQPEURu; spf=pass (imf09.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=1721717008; 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=KdmVOEUYYLw3fo7FDdqHJYm3yN/WP9jqX/33lOGxZ0E=; b=48t++krPznHwUh34G9AKB2qjhBKAgScme8nztiqVnS8oP6ffDdwdxufuoee/IRnA/jkUkc FeCV8WgNqcwQtRs3AjFoUP7Cj7nrw+oCS7WivJ5tlPMPjNfhBpGIm589XYJUEOL486AMEM gHwOoaUdDt9x17eE4VdKcP+6OeNUnRE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721717008; a=rsa-sha256; cv=none; b=EEEAOsEV+GkDDIXZ1Zt3ZOXGceLTydGq3BQbOAhtIHHg0vaAnQfGX7shKNpg2Ua1kkYNw1 I8PpblqSqro+wqXYa8Wa6zlacK8CsZVuQbbpEDZ8f3CzLm0i9b6tyfZxolxwDPGBZClocE 6MqU5HZJmDCos4ZSLwl6/UVI+my4G1g= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DDQPEURu; spf=pass (imf09.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 DA26460B89; Tue, 23 Jul 2024 06:44:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 893C4C4AF0C; Tue, 23 Jul 2024 06:44:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721717053; bh=EH8wWBlMwsfXjtpnY4+zGDnJa6g8CExH9y2mEtavJgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DDQPEURuf/2youpPGfR9PjjP5vqWwzVt9eMvU1zvtUy1E8FR1p79NkbmM51BKspfd 8pPjpSZwbogFIC5obAc5U6evqQGBM5HUm6lxVwnbAc2y0V9AQLZvJrPIWQm3H2eDUc 0AfSs6duiMgIPOvoZ8jr4R6aW9CMtC2gm+/GLrYx+cHgiw6adzF0OS/0yTiaEKmYmh za6G0/Yrep1fQfHvALuhsHrvGHJ2rdPqnTHIGIUqj6QSFo41/n1Qco3z9vNXXkcwdU WlgTUrsz908dqxlqeUh9qqehWOyfDcAflFSCUd2WnY69Xee8sgqHsaJOe1Fv5ceY/y gEmEW190CPEBA== 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 10/25] x86/numa: simplify numa_distance allocation Date: Tue, 23 Jul 2024 09:41:41 +0300 Message-ID: <20240723064156.4009477-11-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-Stat-Signature: bpop96y4fr4m35yrm9t55gaep3y37of6 X-Rspamd-Queue-Id: A6AB714000B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721717054-462090 X-HE-Meta: U2FsdGVkX1++1Bd5GGJTYxKpU6QrLEKIZ2DVznjhxZWuOfi80PTSb7htjDacO+cNTlxzilVcBGqXQdBUV7ZVuBgaoJmz/cMSg6QqyvFBpQwwG2w4sp5IDwksWVfmNxNsmDH1DWXmNS3RN7qbZRdvFTl3M7pcZksjbihzdhHmoiNF1gr1UkyFmxGVKg8bXC4XQWkjg/U/sI9GHUi6jOAts1Tc1KGDsTdTEOBHNvgC0HGY0IVLBY8ZpJ3oPIbUTsVsFd+k4jL64WokfYPWmee00RhR4cR0G2UhL4jixqdj8NHUlO2/aGq3HfzNPGNLxXhenSySOTJ7pR+mDVPRyXemH4qsQPy48VEy0p34aMfzuig22HLHpOaB2CFZBI5K9Z4is0imQkR5S7BdagZkDOYWelV4F9S1bHKgqBLGj7H9KvIUCQwmDGdxxCSakJia7RpCFSR4PzNpXUYegU0ZzdT/9b7ZNzbKR7HDkup7y5yYTwlEEWr4XZpbO8EhaMUldeHxxyqbadT5H4FY2zxhOJoJoMoD1v4/fgSCyVwI7WZauB7mRIVznr7HRiEJyyHipV7HqJTZ9WtxJaPVVX9hNxYbdeBPo9O3sNIH9B1oDOoL7NGnRv+7gdJH6wtZNIgnforzFMRRC4cYsRmZ2HroliS616zDcyw/dUqyD+CEmKO3qrvGIzEC6r6TMtB0V3O2fMh/1SNy3vJv7O+fX/lfUgQYK8ZDd1YUKmJYkr0hDqVUGE6VDoxghW+srUpSBh7CW1MLU/acMUhg2gaCA5NPOesG1BcQDXYNv88zHnMziSvNoJt84ajW3/loH5mqTDIa0bdGZMgdBjGd58mcp/RKjUT730fq9MPj+9rsFC2g/vMW22YdKX4olnOIsVvXsGxjJNCjC++pjJho8cBQbxOto25l0+9eeuOxwONJ6lmPt028Fky2f8O/58l0t07UWzFeeHKlY2dG8Xo46W3Stxly/oh /vC0Pj46 dqqfKBIDaYfFgispNDRmpEDuS9dfb7wqVve1DZTSaxMOmquxriMo6RjXvU9/B2KHHFw8QgPUX5cJ7+rddzkW3ceBesO1zw/Mo2kkvlZnZp4WM9EaCO4yHDEQKgIl0shWk5eOOa9gJLLptYo9hT4KqIYbKCQ7+51GeXb7BiQEPcmbUbOf6F2nhNjBWlimWx08iZpk+Y57b1J1QZsDspyuFn9ve32TkBUwbSVXyVtJdPy5ztvYp1zqtwjFeQRZE2xNmnLszREtTYvxhmsPrVvFdfwUzlSo5TnqrUHvKdmwwbr9GtXfmY618LcjdjuDRMsv9FhcMyD50hs8mZvQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Mike Rapoport (Microsoft)" Allocation of numa_distance uses memblock_phys_alloc_range() to limit allocation to be below the last mapped page. But NUMA initializaition runs after the direct map is populated and there is also code in setup_arch() that adjusts memblock limit to reflect how much memory is already mapped in the direct map. Simplify the allocation of numa_distance and use plain memblock_alloc(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/x86/mm/numa.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 5e1dde26674b..edfc38803779 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -331,7 +331,6 @@ static int __init numa_alloc_distance(void) nodemask_t nodes_parsed; size_t size; int i, j, cnt = 0; - u64 phys; /* size the new table and allocate it */ nodes_parsed = numa_nodes_parsed; @@ -342,16 +341,14 @@ static int __init numa_alloc_distance(void) cnt++; size = cnt * cnt * sizeof(numa_distance[0]); - phys = memblock_phys_alloc_range(size, PAGE_SIZE, 0, - PFN_PHYS(max_pfn_mapped)); - if (!phys) { + numa_distance = memblock_alloc(size, PAGE_SIZE); + if (!numa_distance) { pr_warn("Warning: can't allocate distance table!\n"); /* don't retry until explicitly reset */ numa_distance = (void *)1LU; return -ENOMEM; } - numa_distance = __va(phys); numa_distance_cnt = cnt; /* fill with the default distances */