From patchwork Thu Aug 1 06:08:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 13749639 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5663C3DA64 for ; Thu, 1 Aug 2024 06:10:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C33D6B0088; Thu, 1 Aug 2024 02:10:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 571F86B00A3; Thu, 1 Aug 2024 02:10:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419936B00A4; Thu, 1 Aug 2024 02:10:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 201A86B00A3 for ; Thu, 1 Aug 2024 02:10:47 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CFA0480863 for ; Thu, 1 Aug 2024 06:10:46 +0000 (UTC) X-FDA: 82402652892.24.34A2E81 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 1F74E140017 for ; Thu, 1 Aug 2024 06:10:44 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BzrrpwSU; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722492640; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wo3Ohr8dRmC2rHh5s+ch0FdI2+jtORG6cyKULaZqg3o=; b=BJQdp9xrTiyxpQtZCErlMQ6l8uWe5OnAeSLNCMiBtswl5npFDxVTYsO95MqSqD52k0wlxY V1BN2TA8RaUdd/ktRccMSRWZ4FmrDlDUoNTaEkeKQH9E1tSEW7iWXnFpSNJ9MvWOIVTPHk oC9SAqxYJi581mtZ2QBzkzGhohVecmo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=BzrrpwSU; spf=pass (imf23.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722492640; a=rsa-sha256; cv=none; b=bzJBBkPbHMWzTubAyAT9aPtVXNt8aYXeg0ik/a5JFGss88Qk7ucYw4EohvfxadirPtnnEy v9t+OXjRZ6WGxp1WLUTnJ3vG+D1M9K9KSqschOxAwQ/E0X3kvKm5S7+y+JmxRpLw1C058P 4i3uOPBo0sqGXRsj+0Y2bRFstfUvg60= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5CA8C61B43; Thu, 1 Aug 2024 06:10:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EE00C4AF0E; Thu, 1 Aug 2024 06:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722492644; bh=ONCzrmemywG2vkX0T5B4JcZZcN6Oq4w/h9cKr2li05M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BzrrpwSUCZF+YtPmGe8wYoZtOINEkc03C0wjZ6L1V7Ke9yxnnMKhlxOvWTmr3xNKL RwwQ4qbUzVP72GFWRT0LGacckCL17mMefUkGOCL5lNJFKFcUO5MN1ZU5IcXIYSAsBa Ayk8ocLa9tikf+2dBzqD2xckHWAaWuGol/rUMIS3I0bensi+3b8VKqMhBWSQUxWvWz 7OosMhy+ydzopL682Cq/octMdJ4VWiYIdp8tVyjGqJJLE9jFcr4SQmDw2fW/hbasZw zsU4ENLhqEvLQCPXighzypwrPAnA2uGQICNKQ2ub5hIHuHOxXf35551P+mRG1wi1wA 3mCgasT1JPP8Q== From: Mike Rapoport To: linux-kernel@vger.kernel.org Cc: Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Mike Rapoport , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH v3 10/26] x86/numa: simplify numa_distance allocation Date: Thu, 1 Aug 2024 09:08:10 +0300 Message-ID: <20240801060826.559858-11-rppt@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801060826.559858-1-rppt@kernel.org> References: <20240801060826.559858-1-rppt@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: koaqtu46ct7g488yko17cq65th9iujij X-Rspamd-Queue-Id: 1F74E140017 X-Rspamd-Server: rspam11 X-HE-Tag: 1722492644-254972 X-HE-Meta: U2FsdGVkX18ftl58OGYTqqHWTsAjcWHllTLzrB1Lo+Qhxbz+2ETmxDlmZFqXOecN2CCTm/Miz9uBmyGs6kmm95mDLbCvIV9vk5gFjXw+FdtV4+2ufVHvDJ44Lz6mzCSVH3dB3CL0WqE5z6RxwND2EM4Mz4A+kcEoObPxbmPpDnHN6BYIPSfJIRSGrHRCK4Yjzbavh4ZfIp17P4dbaku6rQgMs11bzwqGyWaFix/n5lzoHQchTIqqfqu69jeFGugABeMKZfLY/dM0UhVBV99nNo52gcAvtHddDpkuQYj8PoxlVCk1Bc1aDIjvQMinoqznDg8MFooQ5f7MapyjHUyw/6lKWUjHRoAIOC6D1vCnQJ8uZTTGFvhF9DqZetAyBELm3Aj2bwjAA00BzdKLKvC+1cj9FGhUC++Vuw4PVdjGX4yhvqEwXYYgQ2BV6RgZ702IJzl0WvEEmwE1bJsczylv8ERbdQ3AxVRNQY+Ljgz6w0ybDgbr6ZtfyWSkpZDkWCOWwCOS3mThe0KnJHlcKjiipH4xOoN24rj7BaX6sEBVpH1O/tVTIQWkiVDOHX0M4I7WTeAB3to2tKzzJTNPKMdZNl+pu+T6kcJic7Q/lhXfagrMkButfnSPvXl++XPxlPmA6KFrNWCSroBLf7vun/qH/HGgwNhi/k6gkY2yKPbF1w4Ol19gwFbiCyXX2JqNRYrh3+kW5w/fDbQEiriSaXMWy3eIZtdWCkOgzAP9kR5zUCey+mc3hN21Di4uiU58q3HFO2aPGIw9v21ZwqaYgAfEkBL7c4Ihfn1e+zcXpEjE6gfaq109I0r7b1aqIF9IHaIZ1mP/4hit0azJhzz5XoteJMHlpLAWGZRFACIb78XU5lq8JdblXxzv3e4hxZMmjDNUjiaFMdJWnfrbEtPCojqMJc7A0K30dRY59WiigOsmeGBM6fCLrdTFGUtB6zK5i0QtM0w8HYfk4BSTQWG3Wg4 dQ22euv+ feJxjEhYNaJxFRZJmnb2pI86355AiOmb4eijb0v4vNdzbPXnP4EyjW8p5GSRQ7ympBVDMBxUCUIVjflCa9LAW4pTJYOIpA7CXnp9mvg+a1Up/z1xD+6tP5HdnWzlCuSrd5XRi2CzK/xzQfEVqfEzMd9naO86LH5jOHDC0/hqyjyZxYjWVN5e5cZTJVssXG4RIF8XiZSwi6aJGoKoeZRYswu8wZYa0ypQAqDMHIdIJfvKIy6rr/U3md1tqx9kBmUTWH/d9AKxbzH2OSCsGDOdm53LFHkg5R3g1c7/0sebGijObnWmk1PMnmrHCnZ89+sinRqw1ddqhJWF2xmki7FdSgDuuI52FYITcIgN2 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Mike Rapoport (Microsoft)" Allocation of numa_distance uses memblock_phys_alloc_range() to limit allocation to be below the last mapped page. But NUMA initializaition runs after the direct map is populated and there is also code in setup_arch() that adjusts memblock limit to reflect how much memory is already mapped in the direct map. Simplify the allocation of numa_distance and use plain memblock_alloc(). Signed-off-by: Mike Rapoport (Microsoft) Tested-by: Zi Yan # for x86_64 and arm64 Reviewed-by: Jonathan Cameron Acked-by: David Hildenbrand --- arch/x86/mm/numa.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 5e1dde26674b..edfc38803779 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -331,7 +331,6 @@ static int __init numa_alloc_distance(void) nodemask_t nodes_parsed; size_t size; int i, j, cnt = 0; - u64 phys; /* size the new table and allocate it */ nodes_parsed = numa_nodes_parsed; @@ -342,16 +341,14 @@ static int __init numa_alloc_distance(void) cnt++; size = cnt * cnt * sizeof(numa_distance[0]); - phys = memblock_phys_alloc_range(size, PAGE_SIZE, 0, - PFN_PHYS(max_pfn_mapped)); - if (!phys) { + numa_distance = memblock_alloc(size, PAGE_SIZE); + if (!numa_distance) { pr_warn("Warning: can't allocate distance table!\n"); /* don't retry until explicitly reset */ numa_distance = (void *)1LU; return -ENOMEM; } - numa_distance = __va(phys); numa_distance_cnt = cnt; /* fill with the default distances */